parallel_tests 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Readme.md +7 -3
- data/bin/parallel_cucumber +5 -1
- data/bin/parallel_rspec +5 -1
- data/bin/parallel_spinach +5 -1
- data/bin/parallel_test +5 -2
- data/lib/parallel_tests.rb +0 -1
- metadata +3 -51
- data/.gitignore +0 -4
- data/.rspec +0 -2
- data/.travis.yml +0 -10
- data/Gemfile +0 -9
- data/Gemfile.lock +0 -53
- data/Rakefile +0 -10
- data/ReadmeRails2.md +0 -48
- data/lib/parallel_tests/cli.rb +0 -206
- data/lib/parallel_tests/cucumber/failures_logger.rb +0 -25
- data/lib/parallel_tests/cucumber/runner.rb +0 -37
- data/lib/parallel_tests/cucumber/scenario_line_logger.rb +0 -51
- data/lib/parallel_tests/cucumber/scenarios.rb +0 -34
- data/lib/parallel_tests/gherkin/io.rb +0 -41
- data/lib/parallel_tests/gherkin/listener.rb +0 -87
- data/lib/parallel_tests/gherkin/runner.rb +0 -116
- data/lib/parallel_tests/gherkin/runtime_logger.rb +0 -28
- data/lib/parallel_tests/grouper.rb +0 -73
- data/lib/parallel_tests/railtie.rb +0 -8
- data/lib/parallel_tests/rspec/failures_logger.rb +0 -54
- data/lib/parallel_tests/rspec/logger_base.rb +0 -55
- data/lib/parallel_tests/rspec/runner.rb +0 -73
- data/lib/parallel_tests/rspec/runtime_logger.rb +0 -59
- data/lib/parallel_tests/rspec/summary_logger.rb +0 -19
- data/lib/parallel_tests/spinach/runner.rb +0 -19
- data/lib/parallel_tests/tasks.rb +0 -157
- data/lib/parallel_tests/test/runner.rb +0 -186
- data/lib/parallel_tests/test/runtime_logger.rb +0 -98
- data/lib/parallel_tests/version.rb +0 -3
- data/parallel_tests.gemspec +0 -14
- data/spec/integration_spec.rb +0 -437
- data/spec/parallel_tests/cli_spec.rb +0 -149
- data/spec/parallel_tests/cucumber/failure_logger_spec.rb +0 -43
- data/spec/parallel_tests/cucumber/runner_spec.rb +0 -25
- data/spec/parallel_tests/cucumber/scenarios_spec.rb +0 -69
- data/spec/parallel_tests/gherkin/listener_spec.rb +0 -96
- data/spec/parallel_tests/gherkin/runner_behaviour.rb +0 -216
- data/spec/parallel_tests/grouper_spec.rb +0 -61
- data/spec/parallel_tests/rspec/failures_logger_spec.rb +0 -82
- data/spec/parallel_tests/rspec/logger_base_spec.rb +0 -35
- data/spec/parallel_tests/rspec/runner_spec.rb +0 -201
- data/spec/parallel_tests/rspec/runtime_logger_spec.rb +0 -131
- data/spec/parallel_tests/rspec/summary_logger_spec.rb +0 -37
- data/spec/parallel_tests/spinach/runner_spec.rb +0 -12
- data/spec/parallel_tests/tasks_spec.rb +0 -178
- data/spec/parallel_tests/test/runner_spec.rb +0 -407
- data/spec/parallel_tests/test/runtime_logger_spec.rb +0 -112
- data/spec/parallel_tests_spec.rb +0 -137
- data/spec/spec_helper.rb +0 -182
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'parallel_tests/grouper'
|
3
|
-
require 'tmpdir'
|
4
|
-
|
5
|
-
describe ParallelTests::Grouper do
|
6
|
-
describe :by_steps do
|
7
|
-
def write(file, content)
|
8
|
-
File.open(file,'w'){|f| f.write content }
|
9
|
-
end
|
10
|
-
|
11
|
-
it "sorts features by steps" do
|
12
|
-
tmpdir = nil
|
13
|
-
result = Dir.mktmpdir do |dir|
|
14
|
-
tmpdir = dir
|
15
|
-
write("#{dir}/a.feature", "Feature: xxx\n Scenario: xxx\n Given something")
|
16
|
-
write("#{dir}/b.feature", "Feature: xxx\n Scenario: xxx\n Given something\n Scenario: yyy\n Given something")
|
17
|
-
write("#{dir}/c.feature", "Feature: xxx\n Scenario: xxx\n Given something")
|
18
|
-
ParallelTests::Grouper.by_steps(["#{dir}/a.feature", "#{dir}/b.feature", "#{dir}/c.feature"], 2, {})
|
19
|
-
end
|
20
|
-
|
21
|
-
# testing inside mktmpdir is always green
|
22
|
-
result.should =~ [
|
23
|
-
["#{tmpdir}/a.feature", "#{tmpdir}/c.feature"],
|
24
|
-
["#{tmpdir}/b.feature"]
|
25
|
-
]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe :in_even_groups_by_size do
|
30
|
-
let(:files_with_size){ {"1" => 1, "2" => 2, "3" => 3, "4" => 4, "5" => 5} }
|
31
|
-
|
32
|
-
def call(num_groups)
|
33
|
-
ParallelTests::Grouper.in_even_groups_by_size(files_with_size, num_groups)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "groups 1 by 1 for same groups as size" do
|
37
|
-
call(5).should == [["5"], ["4"], ["3"], ["2"], ["1"]]
|
38
|
-
end
|
39
|
-
|
40
|
-
it "groups into even groups" do
|
41
|
-
call(2).should == [["1", "2", "5"], ["3", "4"]]
|
42
|
-
end
|
43
|
-
|
44
|
-
it "groups into a single group" do
|
45
|
-
call(1).should == [["1", "2", "3", "4", "5"]]
|
46
|
-
end
|
47
|
-
|
48
|
-
it "adds empty groups if there are more groups than feature files" do
|
49
|
-
call(6).should == [["5"], ["4"], ["3"], ["2"], ["1"], []]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe :by_scenarios do
|
54
|
-
let(:feature_file) { double 'file' }
|
55
|
-
|
56
|
-
it 'splits a feature into individual scenarios' do
|
57
|
-
ParallelTests::Cucumber::Scenarios.should_receive(:all).and_return({ 'feature_file:3' => 1 })
|
58
|
-
ParallelTests::Grouper.by_scenarios([feature_file], 1)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ParallelTests::RSpec::FailuresLogger do
|
4
|
-
def silence_warnings
|
5
|
-
old_verbose, $VERBOSE = $VERBOSE, nil
|
6
|
-
yield
|
7
|
-
ensure
|
8
|
-
$VERBOSE = old_verbose
|
9
|
-
end
|
10
|
-
|
11
|
-
before do
|
12
|
-
@output = OutputLogger.new([])
|
13
|
-
@example1 = mock( 'example', :location => "#{Dir.pwd}/spec/path/to/example:123", :full_description => 'should do stuff', :description => 'd' )
|
14
|
-
@example2 = mock( 'example', :location => "#{Dir.pwd}/spec/path/to/example2:456", :full_description => 'should do other stuff', :description => 'd')
|
15
|
-
@exception1 = mock( :to_s => 'exception', :backtrace => [ '/path/to/error/line:33' ] )
|
16
|
-
@failure1 = mock( 'example', :location => "#{Dir.pwd}/example:123", :header => 'header', :exception => @exception1 )
|
17
|
-
@logger = ParallelTests::RSpec::FailuresLogger.new(@output)
|
18
|
-
end
|
19
|
-
|
20
|
-
after do
|
21
|
-
silence_warnings{ ParallelTests::RSpec::LoggerBase::RSPEC_1 = false }
|
22
|
-
end
|
23
|
-
|
24
|
-
def clean_output
|
25
|
-
@output.output.join("\n").gsub(/\e\[\d+m/,'')
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should produce a list of command lines for failing examples" do
|
29
|
-
@logger.example_failed @example1
|
30
|
-
@logger.example_failed @example2
|
31
|
-
|
32
|
-
@logger.dump_failures
|
33
|
-
@logger.dump_summary(1,2,3,4)
|
34
|
-
|
35
|
-
clean_output.should =~ /^rspec .*? should do stuff/
|
36
|
-
clean_output.should =~ /^rspec .*? should do other stuff/
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should invoke spec for rspec 1" do
|
40
|
-
silence_warnings{ ParallelTests::RSpec::LoggerBase::RSPEC_1 = true }
|
41
|
-
ParallelTests.stub!(:bundler_enabled?).and_return true
|
42
|
-
ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec-core").and_return "Could not find gem 'rspec-core'."
|
43
|
-
@logger.example_failed @example1
|
44
|
-
|
45
|
-
@logger.dump_failures
|
46
|
-
@logger.dump_summary(1,2,3,4)
|
47
|
-
|
48
|
-
clean_output.should =~ /^bundle exec spec/
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should invoke rspec for rspec 2" do
|
52
|
-
ParallelTests.stub!(:bundler_enabled?).and_return true
|
53
|
-
ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec").and_return "/foo/bar/rspec-core-2.0.2"
|
54
|
-
@logger.example_failed @example1
|
55
|
-
|
56
|
-
@logger.dump_failures
|
57
|
-
@logger.dump_summary(1,2,3,4)
|
58
|
-
|
59
|
-
clean_output.should =~ /^rspec/
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should return relative paths" do
|
63
|
-
@logger.example_failed @example1
|
64
|
-
@logger.example_failed @example2
|
65
|
-
|
66
|
-
@logger.dump_failures
|
67
|
-
@logger.dump_summary(1,2,3,4)
|
68
|
-
|
69
|
-
clean_output.should =~ %r(\./spec/path/to/example:123)
|
70
|
-
clean_output.should =~ %r(\./spec/path/to/example2:456)
|
71
|
-
end
|
72
|
-
|
73
|
-
|
74
|
-
# should not longer be a problem since its using native rspec methods
|
75
|
-
xit "should not log examples without location" do
|
76
|
-
example = mock('example', :location => 'bla', :full_description => 'before :all')
|
77
|
-
@logger.example_failed example
|
78
|
-
@logger.dump_failures
|
79
|
-
@logger.dump_summary(1,2,3,4)
|
80
|
-
clean_output.should == ''
|
81
|
-
end
|
82
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ParallelTests::RSpec::LoggerBase do
|
4
|
-
before do
|
5
|
-
@temp_file = Tempfile.open('xxx')
|
6
|
-
@logger = ParallelTests::RSpec::LoggerBase.new(@temp_file)
|
7
|
-
end
|
8
|
-
|
9
|
-
after do
|
10
|
-
@temp_file.close
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'on tests finished' do
|
14
|
-
it 'should respond to close' do
|
15
|
-
expect(@logger).to respond_to(:close)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should close output' do
|
19
|
-
@temp_file.should_receive(:close)
|
20
|
-
@logger.close
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should not close stdout' do
|
24
|
-
@logger = ParallelTests::RSpec::LoggerBase.new($stdout)
|
25
|
-
$stdout.should_not_receive(:close)
|
26
|
-
@logger.close
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should not close IO instance' do
|
30
|
-
io = double(IO)
|
31
|
-
@logger = ParallelTests::RSpec::LoggerBase.new(io)
|
32
|
-
@logger.close
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,201 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "parallel_tests/rspec/runner"
|
3
|
-
|
4
|
-
describe ParallelTests::RSpec::Runner do
|
5
|
-
test_tests_in_groups(ParallelTests::RSpec::Runner, 'spec', '_spec.rb')
|
6
|
-
|
7
|
-
describe :run_tests do
|
8
|
-
before do
|
9
|
-
File.stub!(:file?).with('script/spec').and_return false
|
10
|
-
File.stub!(:file?).with('spec/spec.opts').and_return false
|
11
|
-
File.stub!(:file?).with('spec/parallel_spec.opts').and_return false
|
12
|
-
File.stub!(:file?).with('.rspec_parallel').and_return false
|
13
|
-
ParallelTests.stub!(:bundler_enabled?).and_return false
|
14
|
-
end
|
15
|
-
|
16
|
-
def call(*args)
|
17
|
-
ParallelTests::RSpec::Runner.run_tests(*args)
|
18
|
-
end
|
19
|
-
|
20
|
-
def should_run_with(regex)
|
21
|
-
ParallelTests::Test::Runner.should_receive(:execute_command).with{|a,b,c,d| a =~ regex}
|
22
|
-
end
|
23
|
-
|
24
|
-
def should_not_run_with(regex)
|
25
|
-
ParallelTests::Test::Runner.should_receive(:execute_command).with{|a,b,c,d| a !~ regex}
|
26
|
-
end
|
27
|
-
|
28
|
-
it "runs command using nice when specifed" do
|
29
|
-
ParallelTests::Test::Runner.should_receive(:execute_command_and_capture_output).with{|a,b,c| b =~ %r{^nice rspec}}
|
30
|
-
call('xxx', 1, 22, :nice => true)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "runs with color when called from cmdline" do
|
34
|
-
should_run_with %r{ --tty}
|
35
|
-
$stdout.should_receive(:tty?).and_return true
|
36
|
-
call('xxx', 1, 22, {})
|
37
|
-
end
|
38
|
-
|
39
|
-
it "runs without color when not called from cmdline" do
|
40
|
-
should_not_run_with %r{ --tty}
|
41
|
-
$stdout.should_receive(:tty?).and_return false
|
42
|
-
call('xxx', 1, 22, {})
|
43
|
-
end
|
44
|
-
|
45
|
-
it "runs with color for rspec 1 when called for the cmdline" do
|
46
|
-
File.should_receive(:file?).with('script/spec').and_return true
|
47
|
-
ParallelTests::Test::Runner.should_receive(:execute_command).with { |a, b, c, d| d[:env] == {"RSPEC_COLOR" => "1"} }
|
48
|
-
$stdout.should_receive(:tty?).and_return true
|
49
|
-
call('xxx', 1, 22, {})
|
50
|
-
end
|
51
|
-
|
52
|
-
it "runs without color for rspec 1 when not called for the cmdline" do
|
53
|
-
File.should_receive(:file?).with('script/spec').and_return true
|
54
|
-
ParallelTests::Test::Runner.should_receive(:execute_command).with { |a, b, c, d| d[:env] == {} }
|
55
|
-
$stdout.should_receive(:tty?).and_return false
|
56
|
-
call('xxx', 1, 22, {})
|
57
|
-
end
|
58
|
-
|
59
|
-
it "run bundle exec spec when on bundler rspec 1" do
|
60
|
-
File.stub!(:file?).with('script/spec').and_return false
|
61
|
-
ParallelTests.stub!(:bundler_enabled?).and_return true
|
62
|
-
ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec-core").and_return "Could not find gem 'rspec-core' in bundler."
|
63
|
-
should_run_with %r{bundle exec spec}
|
64
|
-
call('xxx', 1, 22, {})
|
65
|
-
end
|
66
|
-
|
67
|
-
it "run bundle exec rspec when on bundler rspec 2" do
|
68
|
-
File.stub!(:file?).with('script/spec').and_return false
|
69
|
-
ParallelTests.stub!(:bundler_enabled?).and_return true
|
70
|
-
ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec-core").and_return "/foo/bar/rspec-core-2.0.2"
|
71
|
-
should_run_with %r{bundle exec rspec}
|
72
|
-
call('xxx', 1, 22, {})
|
73
|
-
end
|
74
|
-
|
75
|
-
it "runs script/spec when script/spec can be found" do
|
76
|
-
File.should_receive(:file?).with('script/spec').and_return true
|
77
|
-
should_run_with %r{script/spec}
|
78
|
-
call('xxx' ,1, 22, {})
|
79
|
-
end
|
80
|
-
|
81
|
-
it "runs spec when script/spec cannot be found" do
|
82
|
-
File.stub!(:file?).with('script/spec').and_return false
|
83
|
-
should_not_run_with %r{ script/spec}
|
84
|
-
call('xxx', 1, 22, {})
|
85
|
-
end
|
86
|
-
|
87
|
-
it "uses bin/rspec when present" do
|
88
|
-
File.stub(:exists?).with('bin/rspec').and_return true
|
89
|
-
should_run_with %r{bin/rspec}
|
90
|
-
call('xxx', 1, 22, {})
|
91
|
-
end
|
92
|
-
|
93
|
-
it "uses no -O when no opts where found" do
|
94
|
-
File.stub!(:file?).with('spec/spec.opts').and_return false
|
95
|
-
should_not_run_with %r{spec/spec.opts}
|
96
|
-
call('xxx', 1, 22, {})
|
97
|
-
end
|
98
|
-
|
99
|
-
it "uses -O spec/spec.opts when found (with script/spec)" do
|
100
|
-
File.stub!(:file?).with('script/spec').and_return true
|
101
|
-
File.stub!(:file?).with('spec/spec.opts').and_return true
|
102
|
-
should_run_with %r{script/spec\s+-O spec/spec.opts}
|
103
|
-
call('xxx', 1, 22, {})
|
104
|
-
end
|
105
|
-
|
106
|
-
it "uses -O spec/parallel_spec.opts when found (with script/spec)" do
|
107
|
-
File.stub!(:file?).with('script/spec').and_return true
|
108
|
-
File.should_receive(:file?).with('spec/parallel_spec.opts').and_return true
|
109
|
-
should_run_with %r{script/spec\s+-O spec/parallel_spec.opts}
|
110
|
-
call('xxx', 1, 22, {})
|
111
|
-
end
|
112
|
-
|
113
|
-
it "uses -O .rspec_parallel when found (with script/spec)" do
|
114
|
-
File.stub!(:file?).with('script/spec').and_return true
|
115
|
-
File.should_receive(:file?).with('.rspec_parallel').and_return true
|
116
|
-
should_run_with %r{script/spec\s+-O .rspec_parallel}
|
117
|
-
call('xxx', 1, 22, {})
|
118
|
-
end
|
119
|
-
|
120
|
-
it "uses -O spec/parallel_spec.opts with rspec1" do
|
121
|
-
File.should_receive(:file?).with('spec/parallel_spec.opts').and_return true
|
122
|
-
|
123
|
-
ParallelTests.stub!(:bundler_enabled?).and_return true
|
124
|
-
ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec-core").and_return "Could not find gem 'rspec-core'."
|
125
|
-
|
126
|
-
should_run_with %r{spec\s+-O spec/parallel_spec.opts}
|
127
|
-
call('xxx', 1, 22, {})
|
128
|
-
end
|
129
|
-
|
130
|
-
it "uses -O spec/parallel_spec.opts with rspec2" do
|
131
|
-
pending if RUBY_PLATFORM == "java" # FIXME not sure why, but fails on travis
|
132
|
-
File.should_receive(:file?).with('spec/parallel_spec.opts').and_return true
|
133
|
-
|
134
|
-
ParallelTests.stub!(:bundler_enabled?).and_return true
|
135
|
-
ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec-core").and_return "/foo/bar/rspec-core-2.4.2"
|
136
|
-
|
137
|
-
should_run_with %r{rspec\s+--color --tty -O spec/parallel_spec.opts}
|
138
|
-
call('xxx', 1, 22, {})
|
139
|
-
end
|
140
|
-
|
141
|
-
it "uses options passed in" do
|
142
|
-
should_run_with %r{rspec -f n}
|
143
|
-
call('xxx', 1, 22, :test_options => '-f n')
|
144
|
-
end
|
145
|
-
|
146
|
-
it "returns the output" do
|
147
|
-
ParallelTests::RSpec::Runner.should_receive(:execute_command).and_return :x => 1
|
148
|
-
call('xxx', 1, 22, {}).should == {:x => 1}
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe :find_results do
|
153
|
-
def call(*args)
|
154
|
-
ParallelTests::RSpec::Runner.find_results(*args)
|
155
|
-
end
|
156
|
-
|
157
|
-
it "finds multiple results in spec output" do
|
158
|
-
output = "
|
159
|
-
....F...
|
160
|
-
..
|
161
|
-
failute fsddsfsd
|
162
|
-
...
|
163
|
-
ff.**..
|
164
|
-
0 examples, 0 failures, 0 pending
|
165
|
-
ff.**..
|
166
|
-
1 example, 1 failure, 1 pending
|
167
|
-
"
|
168
|
-
|
169
|
-
call(output).should == ['0 examples, 0 failures, 0 pending','1 example, 1 failure, 1 pending']
|
170
|
-
end
|
171
|
-
|
172
|
-
it "is robust against scrambeled output" do
|
173
|
-
output = "
|
174
|
-
....F...
|
175
|
-
..
|
176
|
-
failute fsddsfsd
|
177
|
-
...
|
178
|
-
ff.**..
|
179
|
-
0 exFampl*es, 0 failures, 0 pend.ing
|
180
|
-
ff.**..
|
181
|
-
1 exampF.les, 1 failures, 1 pend.ing
|
182
|
-
"
|
183
|
-
|
184
|
-
call(output).should == ['0 examples, 0 failures, 0 pending','1 examples, 1 failures, 1 pending']
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
describe ".find_tests" do
|
189
|
-
def call(*args)
|
190
|
-
ParallelTests::RSpec::Runner.send(:find_tests, *args)
|
191
|
-
end
|
192
|
-
|
193
|
-
it "doesn't find bakup files with the same name as test files" do
|
194
|
-
with_files(['a/x_spec.rb','a/x_spec.rb.bak']) do |root|
|
195
|
-
call(["#{root}/"]).should == [
|
196
|
-
"#{root}/a/x_spec.rb",
|
197
|
-
]
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
@@ -1,131 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ParallelTests::RSpec::RuntimeLogger do
|
4
|
-
before do
|
5
|
-
# pretend we run in parallel or the logger will log nothing
|
6
|
-
ENV['TEST_ENV_NUMBER'] = ''
|
7
|
-
@clean_output = %r{^spec/foo.rb:[-\.e\d]+$}m
|
8
|
-
end
|
9
|
-
|
10
|
-
after do
|
11
|
-
ENV.delete 'TEST_ENV_NUMBER'
|
12
|
-
end
|
13
|
-
|
14
|
-
def log_for_a_file(options={})
|
15
|
-
Tempfile.open('xxx') do |temp|
|
16
|
-
temp.close
|
17
|
-
f = File.open(temp.path,'w')
|
18
|
-
logger = if block_given?
|
19
|
-
yield(f)
|
20
|
-
else
|
21
|
-
ParallelTests::RSpec::RuntimeLogger.new(f)
|
22
|
-
end
|
23
|
-
|
24
|
-
example = double(:file_path => "#{Dir.pwd}/spec/foo.rb")
|
25
|
-
if ParallelTests::RSpec::RuntimeLogger::RSPEC_3
|
26
|
-
example = double(:group => example)
|
27
|
-
end
|
28
|
-
|
29
|
-
logger.example_group_started example
|
30
|
-
logger.example_group_finished example
|
31
|
-
|
32
|
-
logger.start_dump
|
33
|
-
|
34
|
-
#f.close
|
35
|
-
return File.read(f.path)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it "logs runtime with relative paths" do
|
40
|
-
log_for_a_file.should =~ @clean_output
|
41
|
-
end
|
42
|
-
|
43
|
-
it "does not log if we do not run in parallel" do
|
44
|
-
ENV.delete 'TEST_ENV_NUMBER'
|
45
|
-
log_for_a_file.should == ""
|
46
|
-
end
|
47
|
-
|
48
|
-
it "appends to a given file" do
|
49
|
-
result = log_for_a_file do |f|
|
50
|
-
f.write 'FooBar'
|
51
|
-
ParallelTests::RSpec::RuntimeLogger.new(f)
|
52
|
-
end
|
53
|
-
result.should include('FooBar')
|
54
|
-
result.should include('foo.rb')
|
55
|
-
end
|
56
|
-
|
57
|
-
it "overwrites a given path" do
|
58
|
-
result = log_for_a_file do |f|
|
59
|
-
f.write 'FooBar'
|
60
|
-
ParallelTests::RSpec::RuntimeLogger.new(f.path)
|
61
|
-
end
|
62
|
-
result.should_not include('FooBar')
|
63
|
-
result.should include('foo.rb')
|
64
|
-
end
|
65
|
-
|
66
|
-
context "integration" do
|
67
|
-
around do |example|
|
68
|
-
Dir.mktmpdir do |dir|
|
69
|
-
Dir.chdir(dir, &example)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def write(file, content)
|
74
|
-
FileUtils.mkdir_p(File.dirname(file))
|
75
|
-
File.open(file, 'w') { |f| f.write content }
|
76
|
-
end
|
77
|
-
|
78
|
-
it "logs shared examples into the running files" do
|
79
|
-
write "spec/spec_helper.rb", <<-RUBY
|
80
|
-
shared_examples "foo" do
|
81
|
-
it "is slow" do
|
82
|
-
sleep 0.5
|
83
|
-
end
|
84
|
-
end
|
85
|
-
RUBY
|
86
|
-
|
87
|
-
["a", "b"].each do |letter|
|
88
|
-
write "spec/#{letter}_spec.rb", <<-RUBY
|
89
|
-
require 'spec_helper'
|
90
|
-
describe 'xxx' do
|
91
|
-
it_behaves_like "foo"
|
92
|
-
end
|
93
|
-
RUBY
|
94
|
-
end
|
95
|
-
|
96
|
-
system("TEST_ENV_NUMBER=1 rspec spec -I #{Bundler.root.join("lib")} --format ParallelTests::RSpec::RuntimeLogger --out runtime.log 2>&1") || raise("nope")
|
97
|
-
|
98
|
-
result = File.read("runtime.log")
|
99
|
-
result.should include "a_spec.rb:0.5"
|
100
|
-
result.should include "b_spec.rb:0.5"
|
101
|
-
result.should_not include "spec_helper"
|
102
|
-
end
|
103
|
-
|
104
|
-
it "logs multiple describe blocks" do
|
105
|
-
write "spec/a_spec.rb", <<-RUBY
|
106
|
-
describe "xxx" do
|
107
|
-
it "is slow" do
|
108
|
-
sleep 0.5
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe "yyy" do
|
113
|
-
it "is slow" do
|
114
|
-
sleep 0.5
|
115
|
-
end
|
116
|
-
|
117
|
-
describe "yep" do
|
118
|
-
it "is slow" do
|
119
|
-
sleep 0.5
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
RUBY
|
124
|
-
|
125
|
-
system("TEST_ENV_NUMBER=1 rspec spec -I #{Bundler.root.join("lib")} --format ParallelTests::RSpec::RuntimeLogger --out runtime.log 2>&1") || raise("nope")
|
126
|
-
|
127
|
-
result = File.read("runtime.log")
|
128
|
-
result.should include "a_spec.rb:1.5"
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|