parallel_tests 0.6.19 → 0.6.20

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.19
1
+ 0.6.20
data/bin/parallel_test CHANGED
@@ -39,7 +39,7 @@ raise "--no-sort and --single-process are not supported" if options[:no_sort] an
39
39
  # get files to run from arguments
40
40
  options[:files] = ARGV if ARGV.size > 0
41
41
 
42
- num_processes = options[:count] || Parallel.processor_count
42
+ num_processes = ParallelTests.determine_number_of_processes(options[:count])
43
43
  num_processes = num_processes * (options[:multiply] || 1)
44
44
 
45
45
  if options[:execute]
@@ -5,6 +5,14 @@ require 'parallel_tests/railtie'
5
5
  class ParallelTests
6
6
  VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
7
7
 
8
+ def self.determine_number_of_processes(count)
9
+ [
10
+ count,
11
+ ENV['PARALLEL_TEST_PROCESSORS'],
12
+ Parallel.processor_count
13
+ ].detect{|c| not c.to_s.strip.empty? }.to_i
14
+ end
15
+
8
16
  # parallel:spec[:count, :pattern, :options]
9
17
  def self.parse_rake_args(args)
10
18
  # order as given by user
@@ -15,13 +23,10 @@ class ParallelTests
15
23
  # parallel:spec[,models,options]
16
24
  count = args.shift if args.first.to_s =~ /^\d*$/
17
25
  num_processes = count.to_i unless count.to_s.empty?
18
- num_processes ||= ENV['PARALLEL_TEST_PROCESSORS'].to_i if ENV['PARALLEL_TEST_PROCESSORS']
19
- num_processes ||= Parallel.processor_count
20
-
21
26
  pattern = args.shift
22
27
  options = args.shift
23
28
 
24
- [num_processes.to_i, pattern.to_s, options.to_s]
29
+ [num_processes, pattern.to_s, options.to_s]
25
30
  end
26
31
 
27
32
  # finds all tests and partitions them into groups
@@ -1,8 +1,8 @@
1
1
  namespace :parallel do
2
2
  def run_in_parallel(cmd, options)
3
- count = (options[:count] ? options[:count].to_i : nil)
3
+ count = "-n #{options[:count]}" if options[:count]
4
4
  executable = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'parallel_test')
5
- command = "#{executable} --exec '#{cmd}' -n #{count} #{'--non-parallel' if options[:non_parallel]}"
5
+ command = "#{executable} --exec '#{cmd}' #{count} #{'--non-parallel' if options[:non_parallel]}"
6
6
  abort unless system(command)
7
7
  end
8
8
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "parallel_tests"
8
- s.version = "0.6.19"
8
+ s.version = "0.6.20"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = "2012-02-17"
12
+ s.date = "2012-02-24"
13
13
  s.email = "grosser.michael@gmail.com"
14
14
  s.executables = ["parallel_cucumber", "parallel_spec", "parallel_test"]
15
15
  s.files = [
@@ -47,7 +47,7 @@ Gem::Specification.new do |s|
47
47
  ]
48
48
  s.homepage = "http://github.com/grosser/parallel_tests"
49
49
  s.require_paths = ["lib"]
50
- s.rubygems_version = "1.8.10"
50
+ s.rubygems_version = "1.8.15"
51
51
  s.summary = "Run tests / specs / features in parallel"
52
52
 
53
53
  if s.respond_to? :specification_version then
@@ -29,7 +29,8 @@ describe 'CLI' do
29
29
  end
30
30
 
31
31
  def run_tests(options={})
32
- `cd #{folder} && #{executable} --chunk-timeout 999 -t #{options[:type] || 'spec'} -n #{options[:processes]||2} #{options[:add]} 2>&1`
32
+ processes = "-n #{options[:processes]||2}" unless options[:processes] == false
33
+ `cd #{folder} && #{options[:export]} #{executable} --chunk-timeout 999 -t #{options[:type] || 'spec'} #{processes} #{options[:add]} 2>&1`
33
34
  end
34
35
 
35
36
  it "runs tests in parallel" do
@@ -85,9 +86,13 @@ describe 'CLI' do
85
86
  system("#{executable} -e 'test -e xxxx' -n 4").should == false
86
87
  end
87
88
 
88
- it "can run through parallel_spec / parallel_cucumber" do
89
+ it "can run through parallel_spec" do
89
90
  version = `#{executable} -v`
90
91
  `#{bin_folder}/parallel_spec -v`.should == version
92
+ end
93
+
94
+ it "can run through parallel_spec" do
95
+ version = `#{executable} -v`
91
96
  `#{bin_folder}/parallel_cucumber -v`.should == version
92
97
  end
93
98
 
@@ -101,7 +106,7 @@ describe 'CLI' do
101
106
  (Time.now - t).should <= expected
102
107
  end
103
108
 
104
- it "can can with given files" do
109
+ it "can run with given files" do
105
110
  write "spec/x1_spec.rb", "puts '111'"
106
111
  write "spec/x2_spec.rb", "puts '222'"
107
112
  write "spec/x3_spec.rb", "puts '333'"
@@ -118,6 +123,15 @@ describe 'CLI' do
118
123
  result.should =~ /\d+\.\d+\.\d+.*\d+\.\d+\.\d+/m # prints version twice
119
124
  end
120
125
 
126
+ it "runs with PARALLEL_TEST_PROCESSORS processes" do
127
+ processes = 5
128
+ processes.times{|i|
129
+ write "spec/x#{i}_spec.rb", "puts %{ENV-\#{ENV['TEST_ENV_NUMBER']}-}"
130
+ }
131
+ result = run_tests(:export => "PARALLEL_TEST_PROCESSORS=#{processes}", :processes => processes)
132
+ result.scan(/ENV-.?-/).should =~ ["ENV--", "ENV-2-", "ENV-3-", "ENV-4-", "ENV-5-"]
133
+ end
134
+
121
135
  context "Test::Unit" do
122
136
  it "runs" do
123
137
  write "test/x1_test.rb", "require 'test/unit'; class XTest < Test::Unit::TestCase; def test_xxx; end; end"
@@ -11,7 +11,7 @@ describe ParallelTests do
11
11
 
12
12
  it "should default to the prefix" do
13
13
  args = {:count => "models"}
14
- ParallelTests.parse_rake_args(args).should == [Parallel.processor_count, "models", ""]
14
+ ParallelTests.parse_rake_args(args).should == [nil, "models", ""]
15
15
  end
16
16
 
17
17
  it "should return the count and pattern" do
@@ -23,16 +23,38 @@ describe ParallelTests do
23
23
  args = {:count => 2, :pattern => "plain", :options => "-p default" }
24
24
  ParallelTests.parse_rake_args(args).should == [2, "plain", "-p default"]
25
25
  end
26
+ end
26
27
 
27
- it "should use the PARALLEL_TEST_PROCESSORS env var for processor_count if set" do
28
- ENV['PARALLEL_TEST_PROCESSORS'] = '28'
29
- ParallelTests.parse_rake_args({}).should == [28, '', '']
28
+ describe ".determine_number_of_processes" do
29
+ before do
30
+ ENV.delete('PARALLEL_TEST_PROCESSORS')
31
+ Parallel.stub(:processor_count).and_return 20
30
32
  end
31
33
 
32
- it "should use count over PARALLEL_TEST_PROCESSORS env var" do
33
- ENV['PARALLEL_TEST_PROCESSORS'] = '28'
34
- args = {:count => 2}
35
- ParallelTests.parse_rake_args(args).should == [2, '', ""]
34
+ def call(count)
35
+ ParallelTests.determine_number_of_processes(count)
36
+ end
37
+
38
+ it "uses the given count if set" do
39
+ call('5').should == 5
40
+ end
41
+
42
+ it "uses the processor count from Parallel" do
43
+ call(nil).should == 20
44
+ end
45
+
46
+ it "uses the processor count from ENV before Parallel" do
47
+ ENV['PARALLEL_TEST_PROCESSORS'] = '22'
48
+ call(nil).should == 22
49
+ end
50
+
51
+ it "does not use blank count" do
52
+ call(' ').should == 20
53
+ end
54
+
55
+ it "does not use blank env" do
56
+ ENV['PARALLEL_TEST_PROCESSORS'] = ' '
57
+ call(nil).should == 20
36
58
  end
37
59
  end
38
60
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.19
4
+ version: 0.6.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-17 00:00:00.000000000 Z
12
+ date: 2012-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parallel
16
- requirement: &84626410 !ruby/object:Gem::Requirement
16
+ requirement: &12086720 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *84626410
24
+ version_requirements: *12086720
25
25
  description:
26
26
  email: grosser.michael@gmail.com
27
27
  executables:
@@ -76,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
76
  version: '0'
77
77
  segments:
78
78
  - 0
79
- hash: -373433901
79
+ hash: -3131334744826676279
80
80
  required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  version: '0'
86
86
  requirements: []
87
87
  rubyforge_project:
88
- rubygems_version: 1.8.10
88
+ rubygems_version: 1.8.15
89
89
  signing_key:
90
90
  specification_version: 3
91
91
  summary: Run tests / specs / features in parallel