parallel_tests 1.0.9 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ParallelTests::RSpec::SummaryLogger do
|
4
|
-
let(:output){ OutputLogger.new([]) }
|
5
|
-
let(:logger){ ParallelTests::RSpec::SummaryLogger.new(output) }
|
6
|
-
|
7
|
-
def decolorize(string)
|
8
|
-
string.gsub(/\e\[\d+m/,'')
|
9
|
-
end
|
10
|
-
|
11
|
-
# TODO somehow generate a real example with an exception to test this
|
12
|
-
xit "prints failing examples" do
|
13
|
-
logger.example_failed XXX
|
14
|
-
logger.example_failed XXX
|
15
|
-
logger.dump_failures
|
16
|
-
output.output.should == [
|
17
|
-
"bundle exec rspec ./spec/path/to/example.rb:123 # should do stuff",
|
18
|
-
"bundle exec rspec ./spec/path/to/example.rb:125 # should not do stuff"
|
19
|
-
]
|
20
|
-
end
|
21
|
-
|
22
|
-
it "does not print anything for passing examples" do
|
23
|
-
logger.example_passed mock(:location => "/my/spec/foo.rb:123")
|
24
|
-
logger.dump_failures
|
25
|
-
output.output.should == []
|
26
|
-
logger.dump_summary(1,2,3,4)
|
27
|
-
output.output.map{|o| decolorize(o) }.should == ["\nFinished in 1 second\n", "2 examples, 3 failures, 4 pending"]
|
28
|
-
end
|
29
|
-
|
30
|
-
it "does not print anything for pending examples" do
|
31
|
-
logger.example_pending mock(:location => "/my/spec/foo.rb:123")
|
32
|
-
logger.dump_failures
|
33
|
-
output.output.should == []
|
34
|
-
logger.dump_summary(1,2,3,4)
|
35
|
-
output.output.map{|o| decolorize(o) }.should == ["\nFinished in 1 second\n", "2 examples, 3 failures, 4 pending"]
|
36
|
-
end
|
37
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "parallel_tests/gherkin/runner_behaviour"
|
3
|
-
require "parallel_tests/spinach/runner"
|
4
|
-
|
5
|
-
describe ParallelTests::Spinach::Runner do
|
6
|
-
test_tests_in_groups(ParallelTests::Spinach::Runner, 'features', ".feature")
|
7
|
-
|
8
|
-
it_should_behave_like 'gherkin runners' do
|
9
|
-
let(:runner_name) {'spinach'}
|
10
|
-
let(:runner_class){ParallelTests::Spinach::Runner}
|
11
|
-
end
|
12
|
-
end
|
@@ -1,178 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'parallel_tests/tasks'
|
3
|
-
|
4
|
-
describe ParallelTests::Tasks do
|
5
|
-
describe ".parse_args" do
|
6
|
-
it "should return the count" do
|
7
|
-
args = {:count => 2}
|
8
|
-
ParallelTests::Tasks.parse_args(args).should == [2, "", ""]
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should default to the prefix" do
|
12
|
-
args = {:count => "models"}
|
13
|
-
ParallelTests::Tasks.parse_args(args).should == [nil, "models", ""]
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should return the count and pattern" do
|
17
|
-
args = {:count => 2, :pattern => "models"}
|
18
|
-
ParallelTests::Tasks.parse_args(args).should == [2, "models", ""]
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should return the count, pattern, and options" do
|
22
|
-
args = {:count => 2, :pattern => "plain", :options => "-p default"}
|
23
|
-
ParallelTests::Tasks.parse_args(args).should == [2, "plain", "-p default"]
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should return the count, pattern, and options" do
|
27
|
-
args = {
|
28
|
-
:count => 2,
|
29
|
-
:pattern => "plain",
|
30
|
-
:options => "-p default --group-by steps",
|
31
|
-
}
|
32
|
-
ParallelTests::Tasks.parse_args(args).should == [2, "plain", "-p default --group-by steps"]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe ".rails_env" do
|
37
|
-
around do |example|
|
38
|
-
begin
|
39
|
-
old = ENV["RAILS_ENV"]
|
40
|
-
ENV.delete "RAILS_ENV"
|
41
|
-
example.call
|
42
|
-
ensure
|
43
|
-
ENV["RAILS_ENV"] = old
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should be test when nothing was set" do
|
48
|
-
ParallelTests::Tasks.rails_env.should == "test"
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should be whatever was set" do
|
52
|
-
ENV["RAILS_ENV"] = "foo"
|
53
|
-
ParallelTests::Tasks.rails_env.should == "foo"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe ".run_in_parallel" do
|
58
|
-
let(:full_path){ File.expand_path("../../../bin/parallel_test", __FILE__) }
|
59
|
-
|
60
|
-
it "has the executable" do
|
61
|
-
File.file?(full_path).should == true
|
62
|
-
File.executable?(full_path).should == true
|
63
|
-
end
|
64
|
-
|
65
|
-
it "runs command in parallel" do
|
66
|
-
ParallelTests::Tasks.should_receive(:system).with("#{full_path} --exec 'echo'").and_return true
|
67
|
-
ParallelTests::Tasks.run_in_parallel("echo")
|
68
|
-
end
|
69
|
-
|
70
|
-
it "runs command with :count option" do
|
71
|
-
ParallelTests::Tasks.should_receive(:system).with("#{full_path} --exec 'echo' -n 123").and_return true
|
72
|
-
ParallelTests::Tasks.run_in_parallel("echo", :count => 123)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "runs without -n with blank :count option" do
|
76
|
-
ParallelTests::Tasks.should_receive(:system).with("#{full_path} --exec 'echo'").and_return true
|
77
|
-
ParallelTests::Tasks.run_in_parallel("echo", :count => "")
|
78
|
-
end
|
79
|
-
|
80
|
-
it "runs command with :non_parallel option" do
|
81
|
-
ParallelTests::Tasks.should_receive(:system).with("#{full_path} --exec 'echo' --non-parallel").and_return true
|
82
|
-
ParallelTests::Tasks.run_in_parallel("echo", :non_parallel => true)
|
83
|
-
end
|
84
|
-
|
85
|
-
it "runs aborts if the command fails" do
|
86
|
-
ParallelTests::Tasks.should_receive(:system).and_return false
|
87
|
-
ParallelTests::Tasks.should_receive(:abort).and_return false
|
88
|
-
ParallelTests::Tasks.run_in_parallel("echo")
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe ".suppress_output" do
|
93
|
-
def call(command, grep)
|
94
|
-
# Explictly run as a parameter to /bin/sh to simulate how
|
95
|
-
# the command will be run by parallel_test --exec
|
96
|
-
# This also tests shell escaping of single quotes
|
97
|
-
result = `/bin/sh -c '#{ParallelTests::Tasks.suppress_output(command, grep)}'`
|
98
|
-
[result, $?.success?]
|
99
|
-
end
|
100
|
-
|
101
|
-
context "with pipefail supported" do
|
102
|
-
before :all do
|
103
|
-
if not system("/bin/bash", "-c", "set -o pipefail 2>/dev/null && test 1")
|
104
|
-
pending "pipefail is not supported on your system"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should hide offending lines" do
|
109
|
-
call("echo 123", "123").should == ["", true]
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should not hide other lines" do
|
113
|
-
call("echo 124", "123").should == ["124\n", true]
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should fail if command fails and the pattern matches" do
|
117
|
-
call("echo 123 && test", "123").should == ["", false]
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should fail if command fails and the pattern fails" do
|
121
|
-
call("echo 124 && test", "123").should == ["124\n", false]
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
context "without pipefail supported" do
|
126
|
-
before do
|
127
|
-
ParallelTests::Tasks.should_receive(:system).with('/bin/bash', '-c', 'set -o pipefail 2>/dev/null && test 1').and_return false
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should not filter and succeed" do
|
131
|
-
call("echo 123", "123").should == ["123\n", true]
|
132
|
-
end
|
133
|
-
|
134
|
-
it "should not filter and fail" do
|
135
|
-
call("echo 123 && test", "123").should == ["123\n", false]
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe ".check_for_pending_migrations" do
|
141
|
-
after do
|
142
|
-
Rake.application.instance_variable_get('@tasks').delete("db:abort_if_pending_migrations")
|
143
|
-
Rake.application.instance_variable_get('@tasks').delete("app:db:abort_if_pending_migrations")
|
144
|
-
end
|
145
|
-
|
146
|
-
it "should do nothing if pending migrations is no defined" do
|
147
|
-
ParallelTests::Tasks.check_for_pending_migrations
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should run pending migrations is task is defined" do
|
151
|
-
foo = 1
|
152
|
-
Rake::Task.define_task("db:abort_if_pending_migrations") do
|
153
|
-
foo = 2
|
154
|
-
end
|
155
|
-
ParallelTests::Tasks.check_for_pending_migrations
|
156
|
-
foo.should == 2
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should run pending migrations is app task is defined" do
|
160
|
-
foo = 1
|
161
|
-
Rake::Task.define_task("app:db:abort_if_pending_migrations") do
|
162
|
-
foo = 2
|
163
|
-
end
|
164
|
-
ParallelTests::Tasks.check_for_pending_migrations
|
165
|
-
foo.should == 2
|
166
|
-
end
|
167
|
-
|
168
|
-
it "should not execute the task twice" do
|
169
|
-
foo = 1
|
170
|
-
Rake::Task.define_task("db:abort_if_pending_migrations") do
|
171
|
-
foo += 1
|
172
|
-
end
|
173
|
-
ParallelTests::Tasks.check_for_pending_migrations
|
174
|
-
ParallelTests::Tasks.check_for_pending_migrations
|
175
|
-
foo.should == 2
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
@@ -1,407 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "parallel_tests/test/runner"
|
3
|
-
|
4
|
-
describe ParallelTests::Test::Runner do
|
5
|
-
test_tests_in_groups(ParallelTests::Test::Runner, 'test', '_test.rb')
|
6
|
-
test_tests_in_groups(ParallelTests::Test::Runner, 'test', '_spec.rb')
|
7
|
-
|
8
|
-
describe ".run_tests" do
|
9
|
-
def call(*args)
|
10
|
-
ParallelTests::Test::Runner.run_tests(*args)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "allows to override runner executable via PARALLEL_TESTS_EXECUTABLE" do
|
14
|
-
begin
|
15
|
-
ENV['PARALLEL_TESTS_EXECUTABLE'] = 'script/custom_rspec'
|
16
|
-
ParallelTests::Test::Runner.should_receive(:execute_command).with{|a,b,c,d| a.include?("script/custom_rspec") }
|
17
|
-
call(['xxx'], 1, 22, {})
|
18
|
-
ensure
|
19
|
-
ENV.delete('PARALLEL_TESTS_EXECUTABLE')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
it "uses options" do
|
24
|
-
ParallelTests::Test::Runner.should_receive(:execute_command).with{|a,b,c,d| a =~ %r{ruby -Itest .* -- -v}}
|
25
|
-
call(['xxx'], 1, 22, :test_options => '-v')
|
26
|
-
end
|
27
|
-
|
28
|
-
it "returns the output" do
|
29
|
-
ParallelTests::Test::Runner.should_receive(:execute_command).and_return({:x => 1})
|
30
|
-
call(['xxx'], 1, 22, {}).should == {:x => 1}
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe ".test_in_groups" do
|
35
|
-
def call(*args)
|
36
|
-
ParallelTests::Test::Runner.tests_in_groups(*args)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "does not sort when passed false do_sort option" do
|
40
|
-
ParallelTests::Test::Runner.should_not_receive(:smallest_first)
|
41
|
-
call([], 1, :group_by => :found)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "does sort when not passed do_sort option" do
|
45
|
-
ParallelTests::Test::Runner.stub!(:tests_with_runtime).and_return([])
|
46
|
-
ParallelTests::Grouper.should_receive(:group_features_by_size).and_return([])
|
47
|
-
call([], 1)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "groups by single_process pattern and then via size" do
|
51
|
-
ParallelTests::Test::Runner.should_receive(:with_runtime_info).
|
52
|
-
and_return([
|
53
|
-
['aaa', 5],
|
54
|
-
['aaa2', 5],
|
55
|
-
['bbb', 2],
|
56
|
-
['ccc', 1],
|
57
|
-
['ddd', 1]
|
58
|
-
])
|
59
|
-
result = call([], 3, :single_process => [/^a.a/])
|
60
|
-
result.should == [["aaa", "aaa2"], ["bbb"], ["ccc", "ddd"]]
|
61
|
-
end
|
62
|
-
|
63
|
-
it "groups by size and adds isolated separately" do
|
64
|
-
pending if RUBY_PLATFORM == "java"
|
65
|
-
ParallelTests::Test::Runner.should_receive(:with_runtime_info).
|
66
|
-
and_return([
|
67
|
-
['aaa', 0],
|
68
|
-
['bbb', 3],
|
69
|
-
['ccc', 1],
|
70
|
-
['ddd', 2],
|
71
|
-
['eee', 1]
|
72
|
-
])
|
73
|
-
|
74
|
-
result = call([], 3, :isolate => true, :single_process => [/^aaa/])
|
75
|
-
result.should == [["aaa"], ["bbb", "eee"], ["ccc", "ddd"]]
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe ".find_results" do
|
80
|
-
def call(*args)
|
81
|
-
ParallelTests::Test::Runner.find_results(*args)
|
82
|
-
end
|
83
|
-
|
84
|
-
it "finds multiple results in test output" do
|
85
|
-
output = <<EOF
|
86
|
-
Loaded suite /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/rake_test_loader
|
87
|
-
Started
|
88
|
-
..............
|
89
|
-
Finished in 0.145069 seconds.
|
90
|
-
|
91
|
-
10 tests, 20 assertions, 0 failures, 0 errors
|
92
|
-
Loaded suite /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/rake_test_loader
|
93
|
-
Started
|
94
|
-
..............
|
95
|
-
Finished in 0.145069 seconds.
|
96
|
-
|
97
|
-
14 tests, 20 assertions, 0 failures, 0 errors
|
98
|
-
|
99
|
-
EOF
|
100
|
-
|
101
|
-
call(output).should == ['10 tests, 20 assertions, 0 failures, 0 errors','14 tests, 20 assertions, 0 failures, 0 errors']
|
102
|
-
end
|
103
|
-
|
104
|
-
it "is robust against scrambled output" do
|
105
|
-
output = <<EOF
|
106
|
-
Loaded suite /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/rake_test_loader
|
107
|
-
Started
|
108
|
-
..............
|
109
|
-
Finished in 0.145069 seconds.
|
110
|
-
|
111
|
-
10 tests, 20 assertions, 0 failures, 0 errors
|
112
|
-
Loaded suite /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/rake_test_loader
|
113
|
-
Started
|
114
|
-
..............
|
115
|
-
Finished in 0.145069 seconds.
|
116
|
-
|
117
|
-
14 te.dsts, 20 assertions, 0 failures, 0 errors
|
118
|
-
EOF
|
119
|
-
|
120
|
-
call(output).should == ['10 tests, 20 assertions, 0 failures, 0 errors','14 tedsts, 20 assertions, 0 failures, 0 errors']
|
121
|
-
end
|
122
|
-
|
123
|
-
it "ignores color-codes" do
|
124
|
-
output = <<EOF
|
125
|
-
10 tests, 20 assertions, 0 \e[31mfailures, 0 errors
|
126
|
-
EOF
|
127
|
-
call(output).should == ['10 tests, 20 assertions, 0 failures, 0 errors']
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe ".find_tests" do
|
132
|
-
def call(*args)
|
133
|
-
ParallelTests::Test::Runner.send(:find_tests, *args)
|
134
|
-
end
|
135
|
-
|
136
|
-
it "finds test in folders with appended /" do
|
137
|
-
with_files(['b/a_test.rb']) do |root|
|
138
|
-
call(["#{root}/"]).sort.should == [
|
139
|
-
"#{root}/b/a_test.rb",
|
140
|
-
]
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
it "finds test files nested in symlinked folders" do
|
145
|
-
with_files(['a/a_test.rb','b/b_test.rb']) do |root|
|
146
|
-
`ln -s #{root}/a #{root}/b/link`
|
147
|
-
call(["#{root}/b"]).sort.should == [
|
148
|
-
"#{root}/b/b_test.rb",
|
149
|
-
"#{root}/b/link/a_test.rb",
|
150
|
-
]
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
it "finds test files but ignores those in symlinked folders" do
|
155
|
-
pending if RUBY_PLATFORM == "java"
|
156
|
-
with_files(['a/a_test.rb','b/b_test.rb']) do |root|
|
157
|
-
`ln -s #{root}/a #{root}/b/link`
|
158
|
-
call(["#{root}/b"], :symlinks => false).sort.should == [
|
159
|
-
"#{root}/b/b_test.rb",
|
160
|
-
]
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
it "finds test files nested in different folders" do
|
165
|
-
with_files(['a/a_test.rb','b/b_test.rb', 'c/c_test.rb']) do |root|
|
166
|
-
call(["#{root}/a", "#{root}/b"]).sort.should == [
|
167
|
-
"#{root}/a/a_test.rb",
|
168
|
-
"#{root}/b/b_test.rb",
|
169
|
-
]
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
it "only finds tests in folders" do
|
174
|
-
with_files(['a/a_test.rb', 'a/test.rb', 'a/test_helper.rb']) do |root|
|
175
|
-
call(["#{root}/a"]).sort.should == [
|
176
|
-
"#{root}/a/a_test.rb"
|
177
|
-
]
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
it "finds tests in nested folders" do
|
182
|
-
with_files(['a/b/c/d/a_test.rb']) do |root|
|
183
|
-
call(["#{root}/a"]).sort.should == [
|
184
|
-
"#{root}/a/b/c/d/a_test.rb"
|
185
|
-
]
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
it "does not expand paths" do
|
190
|
-
with_files(['a/x_test.rb']) do |root|
|
191
|
-
Dir.chdir root do
|
192
|
-
call(['a']).sort.should == [
|
193
|
-
"a/x_test.rb"
|
194
|
-
]
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
it "finds test files in folders by pattern" do
|
200
|
-
with_files(['a/x_test.rb','a/y_test.rb','a/z_test.rb']) do |root|
|
201
|
-
Dir.chdir root do
|
202
|
-
call(["a"], :pattern => /^a\/(y|z)_test/).sort.should == [
|
203
|
-
"a/y_test.rb",
|
204
|
-
"a/z_test.rb",
|
205
|
-
]
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
it "doesn't find bakup files with the same name as test files" do
|
211
|
-
with_files(['a/x_test.rb','a/x_test.rb.bak']) do |root|
|
212
|
-
call(["#{root}/"]).should == [
|
213
|
-
"#{root}/a/x_test.rb",
|
214
|
-
]
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
it "finds minispec files" do
|
219
|
-
with_files(['a/x_spec.rb']) do |root|
|
220
|
-
call(["#{root}/"]).should == [
|
221
|
-
"#{root}/a/x_spec.rb",
|
222
|
-
]
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
it "finds nothing if I pass nothing" do
|
227
|
-
call(nil).should == []
|
228
|
-
end
|
229
|
-
|
230
|
-
it "finds nothing if I pass nothing (empty array)" do
|
231
|
-
call([]).should == []
|
232
|
-
end
|
233
|
-
|
234
|
-
it "keeps invalid files" do
|
235
|
-
call(['baz']).should == ['baz']
|
236
|
-
end
|
237
|
-
|
238
|
-
it "discards duplicates" do
|
239
|
-
call(['baz','baz']).should == ['baz']
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
describe ".summarize_results" do
|
244
|
-
def call(*args)
|
245
|
-
ParallelTests::Test::Runner.summarize_results(*args)
|
246
|
-
end
|
247
|
-
|
248
|
-
it "adds results" do
|
249
|
-
call(['1 foo 3 bar','2 foo 5 bar']).should == '8 bars, 3 foos'
|
250
|
-
end
|
251
|
-
|
252
|
-
it "adds results with braces" do
|
253
|
-
call(['1 foo(s) 3 bar(s)','2 foo 5 bar']).should == '8 bars, 3 foos'
|
254
|
-
end
|
255
|
-
|
256
|
-
it "adds same results with plurals" do
|
257
|
-
call(['1 foo 3 bar','2 foos 5 bar']).should == '8 bars, 3 foos'
|
258
|
-
end
|
259
|
-
|
260
|
-
it "adds non-similar results" do
|
261
|
-
call(['1 xxx 2 yyy','1 xxx 2 zzz']).should == '2 xxxs, 2 yyys, 2 zzzs'
|
262
|
-
end
|
263
|
-
|
264
|
-
it "does not pluralize 1" do
|
265
|
-
call(['1 xxx 2 yyy']).should == '1 xxx, 2 yyys'
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
describe ".execute_command" do
|
270
|
-
def call(*args)
|
271
|
-
ParallelTests::Test::Runner.execute_command(*args)
|
272
|
-
end
|
273
|
-
|
274
|
-
def capture_output
|
275
|
-
$stdout, $stderr = StringIO.new, StringIO.new
|
276
|
-
yield
|
277
|
-
[$stdout.string, $stderr.string]
|
278
|
-
ensure
|
279
|
-
$stdout, $stderr = STDOUT, STDERR
|
280
|
-
end
|
281
|
-
|
282
|
-
def run_with_file(content)
|
283
|
-
capture_output do
|
284
|
-
Tempfile.open("xxx") do |f|
|
285
|
-
f.write(content)
|
286
|
-
f.flush
|
287
|
-
yield f.path
|
288
|
-
end
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
it "sets process number to 2 for 1" do
|
293
|
-
run_with_file("puts ENV['TEST_ENV_NUMBER']") do |path|
|
294
|
-
result = call("ruby #{path}", 1, 4, {})
|
295
|
-
result.should == {
|
296
|
-
:stdout => "2\n",
|
297
|
-
:exit_status => 0
|
298
|
-
}
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
it "sets process number to '' for 0" do
|
303
|
-
run_with_file("puts ENV['TEST_ENV_NUMBER'].inspect") do |path|
|
304
|
-
result = call("ruby #{path}", 0, 4, {})
|
305
|
-
result.should == {
|
306
|
-
:stdout => "\"\"\n",
|
307
|
-
:exit_status => 0
|
308
|
-
}
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
|
-
it 'sets PARALLEL_TEST_GROUPS so child processes know that they are being run under parallel_tests' do
|
313
|
-
run_with_file("puts ENV['PARALLEL_TEST_GROUPS']") do |path|
|
314
|
-
result = call("ruby #{path}", 1, 4, {})
|
315
|
-
result.should == {
|
316
|
-
:stdout => "4\n",
|
317
|
-
:exit_status => 0
|
318
|
-
}
|
319
|
-
end
|
320
|
-
end
|
321
|
-
|
322
|
-
it "skips reads from stdin" do
|
323
|
-
pending "hangs on normal ruby, works on jruby" unless RUBY_PLATFORM == "java"
|
324
|
-
run_with_file("$stdin.read; puts 123") do |path|
|
325
|
-
result = call("ruby #{path}", 1, 2, {})
|
326
|
-
result.should == {
|
327
|
-
:stdout => "123\n",
|
328
|
-
:exit_status => 0
|
329
|
-
}
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
|
-
it "waits for process to finish" do
|
334
|
-
run_with_file("sleep 0.5; puts 123; sleep 0.5; puts 345") do |path|
|
335
|
-
result = call("ruby #{path}", 1, 4, {})
|
336
|
-
result.should == {
|
337
|
-
:stdout => "123\n345\n",
|
338
|
-
:exit_status => 0
|
339
|
-
}
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
it "prints output while running" do
|
344
|
-
pending "too slow" if RUBY_PLATFORM == " java"
|
345
|
-
run_with_file("$stdout.sync = true; puts 123; sleep 0.1; print 345; sleep 0.1; puts 567") do |path|
|
346
|
-
received = ""
|
347
|
-
$stdout.stub(:print).with{|x| received << x.strip }
|
348
|
-
result = call("ruby #{path}", 1, 4, {})
|
349
|
-
received.should == "123345567"
|
350
|
-
result.should == {
|
351
|
-
:stdout => "123\n345567\n",
|
352
|
-
:exit_status => 0
|
353
|
-
}
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
it "works with synced stdout" do
|
358
|
-
run_with_file("$stdout.sync = true; puts 123; sleep 0.1; puts 345") do |path|
|
359
|
-
result = call("ruby #{path}", 1, 4, {})
|
360
|
-
result.should == {
|
361
|
-
:stdout => "123\n345\n",
|
362
|
-
:exit_status => 0
|
363
|
-
}
|
364
|
-
end
|
365
|
-
end
|
366
|
-
|
367
|
-
it "does not print to stdout with :serialize_stdout" do
|
368
|
-
run_with_file("puts 123") do |path|
|
369
|
-
$stdout.should_not_receive(:print)
|
370
|
-
result = call("ruby #{path}", 1, 4, :serialize_stdout => true)
|
371
|
-
result.should == {
|
372
|
-
:stdout => "123\n",
|
373
|
-
:exit_status => 0
|
374
|
-
}
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
it "returns correct exit status" do
|
379
|
-
run_with_file("puts 123; exit 5") do |path|
|
380
|
-
result = call("ruby #{path}", 1, 4, {})
|
381
|
-
result.should == {
|
382
|
-
:stdout => "123\n",
|
383
|
-
:exit_status => 5
|
384
|
-
}
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
it "prints each stream to the correct stream" do
|
389
|
-
pending "open3"
|
390
|
-
out, err = run_with_file("puts 123 ; $stderr.puts 345 ; exit 5") do |path|
|
391
|
-
result = call("ruby #{path}", 1, 4, {})
|
392
|
-
result.should == {
|
393
|
-
:stdout => "123\n",
|
394
|
-
:exit_status => 5
|
395
|
-
}
|
396
|
-
end
|
397
|
-
err.should == "345\n"
|
398
|
-
end
|
399
|
-
|
400
|
-
it "uses a lower priority process when the nice option is used" do
|
401
|
-
priority_cmd = "puts Process.getpriority(Process::PRIO_PROCESS, 0)"
|
402
|
-
priority_without_nice = run_with_file(priority_cmd){ |cmd| call("ruby #{cmd}", 1, 4, {}) }.first.to_i
|
403
|
-
priority_with_nice = run_with_file(priority_cmd){ |cmd| call("ruby #{cmd}", 1, 4, :nice => true) }.first.to_i
|
404
|
-
priority_without_nice.should < priority_with_nice
|
405
|
-
end
|
406
|
-
end
|
407
|
-
end
|