spec/integration_spec.rb in parallel_tests-0.6.19 vs spec/integration_spec.rb in parallel_tests-0.6.20
- old
+ new
@@ -27,11 +27,12 @@
def executable
"#{bin_folder}/parallel_test"
end
def run_tests(options={})
- `cd #{folder} && #{executable} --chunk-timeout 999 -t #{options[:type] || 'spec'} -n #{options[:processes]||2} #{options[:add]} 2>&1`
+ processes = "-n #{options[:processes]||2}" unless options[:processes] == false
+ `cd #{folder} && #{options[:export]} #{executable} --chunk-timeout 999 -t #{options[:type] || 'spec'} #{processes} #{options[:add]} 2>&1`
end
it "runs tests in parallel" do
write 'spec/xxx_spec.rb', 'describe("it"){it("should"){puts "TEST1"}}'
write 'spec/xxx2_spec.rb', 'describe("it"){it("should"){puts "TEST2"}}'
@@ -83,13 +84,17 @@
it "exists with failure if any sub-processes returned failure" do
system("#{executable} -e 'test -e xxxx' -n 4").should == false
end
- it "can run through parallel_spec / parallel_cucumber" do
+ it "can run through parallel_spec" do
version = `#{executable} -v`
`#{bin_folder}/parallel_spec -v`.should == version
+ end
+
+ it "can run through parallel_spec" do
+ version = `#{executable} -v`
`#{bin_folder}/parallel_cucumber -v`.should == version
end
it "runs faster with more processes" do
2.times{|i|
@@ -99,11 +104,11 @@
run_tests(:processes => 2)
expected = 10
(Time.now - t).should <= expected
end
- it "can can with given files" do
+ it "can run with given files" do
write "spec/x1_spec.rb", "puts '111'"
write "spec/x2_spec.rb", "puts '222'"
write "spec/x3_spec.rb", "puts '333'"
result = run_tests(:add => 'spec/x1_spec.rb spec/x3_spec.rb')
result.should include('111')
@@ -114,9 +119,18 @@
it "can run with test-options" do
write "spec/x1_spec.rb", "111"
write "spec/x2_spec.rb", "111"
result = run_tests(:add => "--test-options ' --version'", :processes => 2)
result.should =~ /\d+\.\d+\.\d+.*\d+\.\d+\.\d+/m # prints version twice
+ end
+
+ it "runs with PARALLEL_TEST_PROCESSORS processes" do
+ processes = 5
+ processes.times{|i|
+ write "spec/x#{i}_spec.rb", "puts %{ENV-\#{ENV['TEST_ENV_NUMBER']}-}"
+ }
+ result = run_tests(:export => "PARALLEL_TEST_PROCESSORS=#{processes}", :processes => processes)
+ result.scan(/ENV-.?-/).should =~ ["ENV--", "ENV-2-", "ENV-3-", "ENV-4-", "ENV-5-"]
end
context "Test::Unit" do
it "runs" do
write "test/x1_test.rb", "require 'test/unit'; class XTest < Test::Unit::TestCase; def test_xxx; end; end"