parallel_split_test 0.4.0 → 0.8.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d47db7668cac84b19a06abb0f28fd4f616305c73
4
- data.tar.gz: 8540f31e03bc0c3ef75df0ca1f35ca8fecdb2fb9
2
+ SHA256:
3
+ metadata.gz: d99547f6d43a4f9dd42a7516577df244219947e306e3949f92857fae6223918b
4
+ data.tar.gz: 28168f003ffdd21e7114505282130097177c9613088f00d87de6debc3050da0a
5
5
  SHA512:
6
- metadata.gz: 5549fef2328692d9f6595dde32ef0c15be9f5593b323526d2f020fb06b269a0c99aaed669fab2e880d2280da00a03373799d17620fd97b902fb0cce632e89de9
7
- data.tar.gz: 27e9cf6279d5ca9003f449ebce3ab3e5a8b61be2776161d47af9e61923ba21fe4efa9d510104f8c64456db4126cc3e920e90f992cd45f61f8c4a703b82c87931
6
+ metadata.gz: e28d04385f572a35391a22dac32ee71a4b78a875a183bcab786801689c5053a8cba0eaa7bcd08193f11c2819cbbaa9265f74e22c87c419f07b244b6f46681e4e
7
+ data.tar.gz: e265329ce22c3df8e279498629370942ae2fdff97bcc3004cd840b159aedae67762993b0142ee6a06bdbfb3a87a73244bc32a1267016947467b38ce2c5150f98
data/Readme.md CHANGED
@@ -66,15 +66,20 @@ TIPS
66
66
  ====
67
67
  - use `-o/--out` to get unified/clean output from all processes
68
68
  - set number of processes to use with `PARALLEL_SPLIT_TEST_PROCESSES` environment variable
69
- - [unify JUnit output](http://blog.tech.renttherunway.com/?p=631) for rspec
69
+ - [unify JUnit output](http://dresscode.renttherunway.com/blog/631) for rspec
70
70
 
71
71
  TODO
72
72
  ====
73
73
  - Cucumber support
74
74
  - Test::Unit / Minitest support
75
75
 
76
- Author
77
- ======
76
+ Authors
77
+ =======
78
+
79
+ ### [Contributors](https://github.com/grosser/parallel_split_test/contributors)
80
+ - [bootstraponline](https://github.com/bootstraponline)
81
+ - [ModST](https://github.com/ModST)
82
+
78
83
  [Michael Grosser](http://grosser.it)<br/>
79
84
  michael@grosser.it<br/>
80
85
  License: MIT<br/>
@@ -15,6 +15,8 @@ Usage:
15
15
  Options are:
16
16
  -v, --version Display the program version.
17
17
  -h, --help Display this help message.
18
+ --no-summary Does not display test summary.
19
+ --no-merge Does not merge --out results.
18
20
  TEXT
19
21
  exit
20
22
  end
@@ -2,7 +2,7 @@ require 'parallel_split_test'
2
2
  require 'parallel_split_test/output_recorder'
3
3
  require 'parallel'
4
4
  require 'rspec'
5
- require 'parallel_split_test/core_ext/rspec_example'
5
+ require 'parallel_split_test/core_ext/rspec_world'
6
6
 
7
7
  module ParallelSplitTest
8
8
  class CommandLine < RSpec::Core::Runner
@@ -12,6 +12,9 @@ module ParallelSplitTest
12
12
  end
13
13
 
14
14
  def run(err, out)
15
+ no_summary = @args.delete('--no-summary')
16
+ no_merge = @args.delete('--no-merge')
17
+
15
18
  @options = RSpec::Core::ConfigurationOptions.new(@args)
16
19
 
17
20
  processes = ParallelSplitTest.choose_number_of_processes
@@ -22,15 +25,13 @@ module ParallelSplitTest
22
25
  ParallelSplitTest.process_number = process_number
23
26
  set_test_env_number(process_number)
24
27
  modify_out_file_in_args(process_number) if out_file
25
-
26
28
  out = OutputRecorder.new(out)
27
- setup_copied_from_rspec(err, out)
28
- [run_group_of_tests, out.recorded]
29
+ [super(err, out), out.recorded]
29
30
  end
30
31
 
31
- combine_out_files if out_file
32
+ combine_out_files if out_file unless no_merge
32
33
 
33
- reprint_result_lines(out, results.map(&:last))
34
+ reprint_result_lines(out, results.map(&:last)) unless no_summary
34
35
  results.map(&:first).max # combine exit status
35
36
  end
36
37
 
@@ -38,7 +39,7 @@ module ParallelSplitTest
38
39
 
39
40
  # modify + reparse args to unify output
40
41
  def modify_out_file_in_args(process_number)
41
- @args[out_file_position] = "#{out_file}.#{process_number}"
42
+ @args[out_file_position] = "#{out_file_parent_dir}/#{out_file_basename}.#{process_number}#{File.extname(out_file)}"
42
43
  @options = RSpec::Core::ConfigurationOptions.new(@args)
43
44
  end
44
45
 
@@ -50,6 +51,14 @@ module ParallelSplitTest
50
51
  @out_file ||= @args[out_file_position] if out_file_position
51
52
  end
52
53
 
54
+ def out_file_parent_dir
55
+ @out_file_parent_dir ||= File.expand_path("#{out_file}/../.")
56
+ end
57
+
58
+ def out_file_basename
59
+ @out_file_basename ||= File.basename(out_file, File.extname(out_file))
60
+ end
61
+
53
62
  def out_file_position
54
63
  @out_file_position ||= begin
55
64
  if out_position = @args.index { |i| ["-o", "--out"].include?(i) }
@@ -60,7 +69,7 @@ module ParallelSplitTest
60
69
 
61
70
  def combine_out_files
62
71
  File.open(out_file, "w") do |f|
63
- Dir["#{out_file}.*"].each do |file|
72
+ Dir["#{out_file_parent_dir}/#{out_file_basename}.*#{File.extname(out_file)}"].each do |file|
64
73
  f.write File.read(file)
65
74
  File.delete(file)
66
75
  end
@@ -72,24 +81,5 @@ module ParallelSplitTest
72
81
  out.puts "Summary:"
73
82
  out.puts printed_outputs.map{|o| o[/.*\d+ failure.*/] }.join("\n")
74
83
  end
75
-
76
- def run_group_of_tests
77
- example_count = @world.example_count / ParallelSplitTest.processes
78
-
79
- @configuration.reporter.report(example_count) do |reporter|
80
- groups = @world.example_groups
81
- results = groups.map {|g| g.run(reporter)}
82
- results.all? ? 0 : @configuration.failure_exit_code
83
- end
84
- end
85
-
86
- # https://github.com/rspec/rspec-core/blob/6ee92a0d47bcb1f3abcd063dca2cee005356d709/lib/rspec/core/runner.rb#L93
87
- def setup_copied_from_rspec(err, out)
88
- @configuration.error_stream = err
89
- @configuration.output_stream = out if @configuration.output_stream == $stdout
90
- @options.configure(@configuration)
91
- @configuration.load_spec_files
92
- @world.announce_filters
93
- end
94
84
  end
95
85
  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 :original_prepare_example_filtereing :prepare_example_filtering
6
+
7
+ def prepare_example_filtering
8
+ @original_filtered_examples = original_prepare_example_filtereing
9
+ @filtered_examples = Hash.new do |hash, group|
10
+ hash[group] = @original_filtered_examples[group].select do |x|
11
+ ParallelSplitTest.run_example?
12
+ end
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.4.0'
2
+ VERSION = '0.8.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.4.0
4
+ version: 0.8.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: 2015-01-12 00:00:00.000000000 Z
11
+ date: 2020-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -49,7 +49,7 @@ files:
49
49
  - bin/parallel_split_test
50
50
  - lib/parallel_split_test.rb
51
51
  - lib/parallel_split_test/command_line.rb
52
- - lib/parallel_split_test/core_ext/rspec_example.rb
52
+ - lib/parallel_split_test/core_ext/rspec_world.rb
53
53
  - lib/parallel_split_test/output_recorder.rb
54
54
  - lib/parallel_split_test/runner.rb
55
55
  - lib/parallel_split_test/version.rb
@@ -65,15 +65,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 2.2.0
69
69
  required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
- rubyforge_project:
76
- rubygems_version: 2.2.2
75
+ rubygems_version: 3.1.3
77
76
  signing_key:
78
77
  specification_version: 4
79
78
  summary: Split a big test file into multiple chunks and run them in parallel
@@ -1,13 +0,0 @@
1
- require 'parallel_split_test'
2
- require 'rspec/core/example'
3
-
4
- RSpec::Core::Example.class_eval do
5
- alias :run_without_parallel_split_test :run
6
- def run(*args, &block)
7
- if ParallelSplitTest.run_example?
8
- run_without_parallel_split_test(*args, &block)
9
- else
10
- true # example 'passed'
11
- end
12
- end
13
- end