parallel_split_test 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cd1d692dde899db03bd2f824af156bb38b708fe
4
- data.tar.gz: 7c9d58d739df030889c15203687a72a40a5f848f
3
+ metadata.gz: 45de1287c50f21414ec9cfd8cd44f15063757423
4
+ data.tar.gz: 77b10746bf20d6b9b0bbc334617d3c1648c7ba5f
5
5
  SHA512:
6
- metadata.gz: 06c36c0c0acb25def7f2006472603a80b0849347f9173d68ce28d7c17d348ed7169405c1261016ed8fca50a5b0b528b4f00b61b123365ccd4ff395bd989d4af5
7
- data.tar.gz: ed46c3d631cde68b6e0b15e9d7da79639ba14796823edceb82d2a40f10a4a9e86871ef8de244b5f5a4b2e4d22add15838d67c30bcfb0b2b5268243053e181c98
6
+ metadata.gz: 01bf113de23323bdbb7f64eef5f4aeb885cf40dd915e0d1701dc6bf9995b7773b43f8c1cc06f1ad9b4d086453cec57e45da5dc4b550281917e30ae8bd5d8f7e7
7
+ data.tar.gz: e72f3554bae41f8590eb896d9e8ae69da8ae62ff2f9efb4a844274142f8b0a6a73dc068b1585d0cdfc22df8c19924270d56b2f3a9c6778074a7051776aae4e28
@@ -3,6 +3,7 @@ require 'parallel_split_test/output_recorder'
3
3
  require 'parallel'
4
4
  require 'rspec'
5
5
  require 'parallel_split_test/core_ext/rspec_example'
6
+ require 'parallel_split_test/core_ext/rspec_world'
6
7
 
7
8
  module ParallelSplitTest
8
9
  class CommandLine < RSpec::Core::Runner
@@ -26,11 +27,9 @@ module ParallelSplitTest
26
27
  set_test_env_number(process_number)
27
28
  modify_out_file_in_args(process_number) if out_file
28
29
  out = OutputRecorder.new(out)
29
- setup_copied_from_rspec(err, out)
30
- [run_group_of_tests, out.recorded]
30
+ [super(err, out), out.recorded]
31
31
  end
32
32
 
33
-
34
33
  combine_out_files if out_file unless no_merge
35
34
 
36
35
  reprint_result_lines(out, results.map(&:last)) unless no_summary
@@ -41,7 +40,7 @@ module ParallelSplitTest
41
40
 
42
41
  # modify + reparse args to unify output
43
42
  def modify_out_file_in_args(process_number)
44
- @args[out_file_position] = "#{out_file_basename}.#{process_number}#{File.extname(out_file)}"
43
+ @args[out_file_position] = "#{out_file_parent_dir}/#{out_file_basename}.#{process_number}#{File.extname(out_file)}"
45
44
  @options = RSpec::Core::ConfigurationOptions.new(@args)
46
45
  end
47
46
 
@@ -53,6 +52,10 @@ module ParallelSplitTest
53
52
  @out_file ||= @args[out_file_position] if out_file_position
54
53
  end
55
54
 
55
+ def out_file_parent_dir
56
+ @out_file_parent_dir ||= File.expand_path("#{out_file}/../.")
57
+ end
58
+
56
59
  def out_file_basename
57
60
  @out_file_basename ||= File.basename(out_file, File.extname(out_file))
58
61
  end
@@ -67,7 +70,7 @@ module ParallelSplitTest
67
70
 
68
71
  def combine_out_files
69
72
  File.open(out_file, "w") do |f|
70
- Dir["#{out_file_basename}.*#{File.extname(out_file)}"].each do |file|
73
+ Dir["#{out_file_parent_dir}/#{out_file_basename}.*#{File.extname(out_file)}"].each do |file|
71
74
  f.write File.read(file)
72
75
  File.delete(file)
73
76
  end
@@ -79,24 +82,5 @@ module ParallelSplitTest
79
82
  out.puts "Summary:"
80
83
  out.puts printed_outputs.map{|o| o[/.*\d+ failure.*/] }.join("\n")
81
84
  end
82
-
83
- def run_group_of_tests
84
- example_count = @world.example_count / ParallelSplitTest.processes
85
-
86
- @configuration.reporter.report(example_count) do |reporter|
87
- groups = @world.example_groups
88
- results = groups.map {|g| g.run(reporter)}
89
- results.all? ? 0 : @configuration.failure_exit_code
90
- end
91
- end
92
-
93
- # https://github.com/rspec/rspec-core/blob/6ee92a0d47bcb1f3abcd063dca2cee005356d709/lib/rspec/core/runner.rb#L93
94
- def setup_copied_from_rspec(err, out)
95
- @configuration.error_stream = err
96
- @configuration.output_stream = out if @configuration.output_stream == $stdout
97
- @options.configure(@configuration)
98
- @configuration.load_spec_files
99
- @world.announce_filters
100
- end
101
85
  end
102
86
  end
@@ -0,0 +1,15 @@
1
+ require 'parallel_split_test'
2
+ require 'rspec/core/example'
3
+
4
+ RSpec::Core::World.class_eval do
5
+ alias :example_count_without_parallel_split_test :example_count
6
+ def example_count(*args, &block)
7
+ count = example_count_without_parallel_split_test(*args, &block)
8
+ quotient = count / ParallelSplitTest.processes
9
+ if ParallelSplitTest.process_number < count % ParallelSplitTest.processes
10
+ quotient + 1
11
+ else
12
+ quotient
13
+ end
14
+ end
15
+ end
@@ -7,7 +7,7 @@ module ParallelSplitTest
7
7
  @out = out
8
8
  end
9
9
 
10
- %w[puts write print putc flush].each do |method|
10
+ %w[puts write print putc flush tty? closed?].each do |method|
11
11
  class_eval <<-RUBY, __FILE__, __LINE__
12
12
  def #{method}(*args)
13
13
  @recorded.#{method}(*args)
@@ -1,3 +1,3 @@
1
1
  module ParallelSplitTest
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_split_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-22 00:00:00.000000000 Z
11
+ date: 2017-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -50,6 +50,7 @@ files:
50
50
  - lib/parallel_split_test.rb
51
51
  - lib/parallel_split_test/command_line.rb
52
52
  - lib/parallel_split_test/core_ext/rspec_example.rb
53
+ - lib/parallel_split_test/core_ext/rspec_world.rb
53
54
  - lib/parallel_split_test/output_recorder.rb
54
55
  - lib/parallel_split_test/runner.rb
55
56
  - lib/parallel_split_test/version.rb
@@ -73,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
74
  version: '0'
74
75
  requirements: []
75
76
  rubyforge_project:
76
- rubygems_version: 2.4.5.1
77
+ rubygems_version: 2.5.1
77
78
  signing_key:
78
79
  specification_version: 4
79
80
  summary: Split a big test file into multiple chunks and run them in parallel