forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.rake
132 lines (105 loc) · 5.44 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
122
123
124
125
126
127
128
129
130
131
132
# we need to call exit explicity in order to set the proper exit code, otherwise
# most common CI systems can not know whats up with this tests.
require "pluginmanager/util"
namespace "test" do
task "setup" do
# Need to be run here as because if run aftewarse (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 "rspec/core/runner"
require "rspec"
require 'ci/reporter/rake/rspec_loader'
end
def core_specs
# note that regardless if which logstash-core-event-* gem is live, we will always run the
# logstash-core-event specs since currently this is the most complete Event and Timestamp specs
# which actually defines the Event contract and should pass regardless of the actuall underlying
# implementation.
specs = ["spec/unit/**/*_spec.rb", "logstash-core/spec/**/*_spec.rb", "logstash-core-event/spec/**/*_spec.rb"]
# figure if the logstash-core-event-java gem is loaded and if so add its specific specs in the core specs to run
begin
require "logstash-core-event-java/version"
specs << "logstash-core-event-java/spec/**/*_spec.rb"
rescue LoadError
# logstash-core-event-java gem is not live, ignore and skip specs
end
Rake::FileList[*specs]
end
desc "run core specs"
task "core" => ["setup"] do
exit(RSpec::Core::Runner.run([core_specs]))
end
desc "run 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 correclty 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 bootstraping 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
task "integration" => ["setup"] do
require "fileutils"
source = File.expand_path(File.join(File.dirname(__FILE__), ".."))
integration_path = File.join(source, "integration_run")
FileUtils.rm_rf(integration_path)
exit(RSpec::Core::Runner.run([Rake::FileList["spec/integration/**/*_spec.rb"]]))
end
namespace "integration" do
task "local" => ["setup"] do
require "fileutils"
source = File.expand_path(File.join(File.dirname(__FILE__), ".."))
integration_path = File.join(source, "integration_run")
FileUtils.mkdir_p(integration_path)
puts "[integration_spec] configuring local environment for running test in #{integration_path}, if you want to change this behavior delete the directory."
exit(RSpec::Core::Runner.run([Rake::FileList["spec/integration/**/*_spec.rb"]]))
end
end
end
task "test" => [ "test:core" ]