forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.rake
121 lines (95 loc) · 4.73 KB
/
test.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# we need to call exit explicitly in order to set the proper exit code, otherwise
# most common CI systems can not know whats up with this tests.
require "pluginmanager/util"
require 'pathname'
namespace "test" do
task "setup" do
# make sure we have a ./data/queue dir here
# temporary wiring until we figure proper queue initialization sequence and in test context etc.
mkdir "data" unless File.directory?("data")
mkdir "data/queue" unless File.directory?("data/queue")
# Need to be run here as because if run afterwards (after the bundler.setup task) then the report got wrong
# numbers and misses files. There is an issue with our setup! method as this does not happen with the regular
# bundler.setup used in regular bundler flows.
Rake::Task["test:setup-simplecov"].invoke if ENV['COVERAGE']
require "bootstrap/environment"
LogStash::Bundler.setup!({:without => [:build]})
require "logstash-core"
# Aligns behavior with bin/rspec command here
$LOAD_PATH << Pathname.new(File.join(File.dirname(__FILE__), "..", "logstash-core", "spec")).
cleanpath.
expand_path.
to_s
require "rspec/core/runner"
require "rspec"
require 'ci/reporter/rake/rspec_loader'
end
def core_specs
exit(1) unless system './gradlew clean test --info'
specs = ["spec/unit/**/*_spec.rb", "logstash-core/spec/**/*_spec.rb"]
Rake::FileList[*specs]
end
desc "run all core specs"
task "core" => ["core-slow"]
desc "run all core specs"
task "core-slow" => ["setup"] do
exit(RSpec::Core::Runner.run([core_specs]))
end
desc "run core specs excluding slower tests like stress tests"
task "core-fast" => ["setup"] do
exit(RSpec::Core::Runner.run(["--tag", "~stress_test", core_specs]))
end
desc "run all core specs in fail-fast mode"
task "core-fail-fast" => ["setup"] do
exit(RSpec::Core::Runner.run(["--fail-fast", core_specs]))
end
desc "run core specs on a single file"
task "core-single-file", [:specfile] => ["setup"] do |t, args|
exit(RSpec::Core::Runner.run([Rake::FileList[args.specfile]]))
end
desc "run all installed plugins specs"
task "plugins" => ["setup"] do
plugins_to_exclude = ENV.fetch("EXCLUDE_PLUGIN", "").split(",")
# grab all spec files using the live plugins gem specs. this allows correctly also running the specs
# of a local plugin dir added using the Gemfile :path option. before this, any local plugin spec would
# not be run because they were not under the vendor/bundle/jruby/1.9/gems path
test_files = LogStash::PluginManager.find_plugins_gem_specs.map do |spec|
if plugins_to_exclude.size > 0
if !plugins_to_exclude.include?(Pathname.new(spec.gem_dir).basename.to_s)
Rake::FileList[File.join(spec.gem_dir, "spec/{input,filter,codec,output}s/*_spec.rb")]
end
else
Rake::FileList[File.join(spec.gem_dir, "spec/{input,filter,codec,output}s/*_spec.rb")]
end
end.flatten.compact
# "--format=documentation"
exit(RSpec::Core::Runner.run(["--order", "rand", test_files]))
end
task "install-core" => ["bootstrap", "plugin:install-core", "plugin:install-development-dependencies"]
task "install-default" => ["bootstrap", "plugin:install-default", "plugin:install-development-dependencies"]
task "install-all" => ["bootstrap", "plugin:install-all", "plugin:install-development-dependencies"]
task "install-vendor-plugins" => ["bootstrap", "plugin:install-vendor", "plugin:install-development-dependencies"]
task "install-jar-dependencies-plugins" => ["bootstrap", "plugin:install-jar-dependencies", "plugin:install-development-dependencies"]
# Setup simplecov to group files per functional modules, like this is easier to spot places with small coverage
task "setup-simplecov" do
require "simplecov"
SimpleCov.start do
# Skip non core related directories and files.
["vendor/", "spec/", "bootstrap/rspec", "Gemfile", "gemspec"].each do |pattern|
add_filter pattern
end
add_group "bootstrap", "bootstrap/" # This module is used during bootstrapping of LS
add_group "plugin manager", "pluginmanager/" # Code related to the plugin manager
add_group "core" do |src_file| # The LS core codebase
/logstash\/\w+.rb/.match(src_file.filename)
end
add_group "core-util", "logstash/util" # Set of LS utils module
add_group "core-config", "logstash/config" # LS Configuration modules
add_group "core-patches", "logstash/patches" # Patches used to overcome known issues in dependencies.
# LS Core plugins code base.
add_group "core-plugins", [ "logstash/codecs", "logstash/filters", "logstash/outputs", "logstash/inputs" ]
end
task.reenable
end
end
task "test" => [ "test:core" ]