parallel_split_test 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- parallel_split_test (0.1.3)
5
- parallel (>= 0.5.12)
4
+ parallel_split_test (0.1.4)
5
+ parallel (>= 0.5.13)
6
6
  rspec (>= 2)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
11
  diff-lcs (1.1.3)
12
- parallel (0.5.12)
12
+ parallel (0.5.13)
13
13
  rake (0.9.2)
14
14
  rspec (2.8.0)
15
15
  rspec-core (~> 2.8.0)
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "optparse"
3
3
  $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
4
- require "parallel_split_test"
5
4
 
6
5
  parser = OptionParser.new do |opts|
7
6
  opts.banner = <<BANNER
@@ -23,8 +22,5 @@ if ARGV.empty?
23
22
  exit
24
23
  end
25
24
 
26
- require "rspec"
27
- require "parallel"
28
-
29
25
  require 'parallel_split_test/runner'
30
26
  ParallelSplitTest::Runner.run(ARGV)
@@ -1,10 +1,24 @@
1
+ require 'parallel'
2
+
1
3
  module ParallelSplitTest
2
4
  class << self
3
- attr_accessor :example_counter, :process_count, :process_number
5
+ attr_accessor :example_counter, :processes, :process_number
4
6
  end
5
7
 
6
8
  def self.run_example?
7
9
  self.example_counter += 1
8
- (example_counter - 1) % process_count == process_number
10
+ (example_counter - 1) % processes == process_number
11
+ end
12
+
13
+ def self.choose_number_of_processes
14
+ self.processes = best_number_of_processes
15
+ end
16
+
17
+ def self.best_number_of_processes
18
+ [
19
+ ENV['PARALLEL_SPLIT_TEST_PROCESSES'],
20
+ Parallel.physical_processor_count,
21
+ Parallel.processor_count
22
+ ].map(&:to_i).find{|number| number > 0 }
9
23
  end
10
24
  end
@@ -1,29 +1,28 @@
1
1
  require 'parallel_split_test'
2
2
  require 'parallel'
3
- require 'rspec/core/command_line'
3
+ require 'rspec'
4
4
  require 'parallel_split_test/core_ext/rspec_example'
5
5
 
6
6
  module ParallelSplitTest
7
7
  class CommandLine < RSpec::Core::CommandLine
8
8
  def run(err, out)
9
- processes = (ENV['PARALLEL_SPLIT_TEST_PROCESSES'] || Parallel.processor_count).to_i
9
+ ParallelSplitTest.choose_number_of_processes
10
10
 
11
- Parallel.in_processes(processes) do |process_number|
11
+ Parallel.in_processes(ParallelSplitTest.processes) do |process_number|
12
12
  ENV['TEST_ENV_NUMBER'] = (process_number == 0 ? '' : (process_number + 1).to_s)
13
13
  setup_copied_from_rspec(err, out)
14
14
 
15
15
  ParallelSplitTest.example_counter = 0
16
- ParallelSplitTest.process_count = processes
17
16
  ParallelSplitTest.process_number = process_number
18
17
 
19
- run_group_of_tests(processes)
18
+ run_group_of_tests
20
19
  end
21
20
  end
22
21
 
23
22
  private
24
23
 
25
- def run_group_of_tests(processes)
26
- example_count = @world.example_count / processes
24
+ def run_group_of_tests
25
+ example_count = @world.example_count / ParallelSplitTest.processes
27
26
 
28
27
  @configuration.reporter.report(example_count, seed) do |reporter|
29
28
  begin
@@ -1,5 +1,3 @@
1
- require 'rspec/core/runner'
2
- require 'rspec/core/configuration_options'
3
1
  require 'parallel_split_test/command_line'
4
2
 
5
3
  # a cleaned up version of the RSpec runner, e.g. no drb support
@@ -1,3 +1,3 @@
1
1
  module ParallelSplitTest
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
@@ -10,6 +10,6 @@ Gem::Specification.new name, ParallelSplitTest::VERSION do |s|
10
10
  s.files = `git ls-files`.split("\n")
11
11
  s.executables = ["parallel_split_test"]
12
12
  s.add_dependency "rspec", ">=2"
13
- s.add_dependency "parallel", ">=0.5.12"
13
+ s.add_dependency "parallel", ">=0.5.13"
14
14
  s.license = "MIT"
15
15
  end
@@ -5,6 +5,30 @@ describe ParallelSplitTest do
5
5
  ParallelSplitTest::VERSION.should =~ /^[\.\da-z]+$/
6
6
  end
7
7
 
8
+ describe ".best_number_of_processes" do
9
+ before do
10
+ ENV['PARALLEL_SPLIT_TEST_PROCESSES'] = nil
11
+ end
12
+
13
+ let(:count) { ParallelSplitTest.send(:best_number_of_processes) }
14
+
15
+ it "uses ENV" do
16
+ ENV['PARALLEL_SPLIT_TEST_PROCESSES'] = "5"
17
+ count.should == 5
18
+ end
19
+
20
+ it "uses physical_processor_count" do
21
+ Parallel.stub(:physical_processor_count).and_return 6
22
+ count.should == 6
23
+ end
24
+
25
+ it "uses processor_count if everything else fails" do
26
+ Parallel.stub(:physical_processor_count).and_return 0
27
+ Parallel.stub(:processor_count).and_return 7
28
+ count.should == 7
29
+ end
30
+ end
31
+
8
32
  describe "cli" do
9
33
  def run(command, options={})
10
34
  result = `#{command} 2>&1`
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_split_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &71624760 !ruby/object:Gem::Requirement
16
+ requirement: &78874300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,18 +21,18 @@ dependencies:
21
21
  version: '2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *71624760
24
+ version_requirements: *78874300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: parallel
27
- requirement: &71624510 !ruby/object:Gem::Requirement
27
+ requirement: &78874050 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 0.5.12
32
+ version: 0.5.13
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *71624510
35
+ version_requirements: *78874050
36
36
  description:
37
37
  email: michael@grosser.it
38
38
  executables:
@@ -69,7 +69,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
69
  version: '0'
70
70
  segments:
71
71
  - 0
72
- hash: -426615473
72
+ hash: -660068355
73
73
  required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  version: '0'
79
79
  segments:
80
80
  - 0
81
- hash: -426615473
81
+ hash: -660068355
82
82
  requirements: []
83
83
  rubyforge_project:
84
84
  rubygems_version: 1.8.10