parallel_split_test 0.4.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Readme.md +34 -1
- data/bin/parallel_split_test +1 -0
- data/lib/parallel_split_test/command_line.rb +15 -27
- data/lib/parallel_split_test/core_ext/rspec_world.rb +15 -0
- data/lib/parallel_split_test/output_recorder.rb +1 -1
- data/lib/parallel_split_test/version.rb +1 -1
- metadata +6 -7
- data/lib/parallel_split_test/core_ext/rspec_example.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 65917250cd2361e8c7739b8696258d00454935a0a5762aabc7a1101b0748b6a4
|
4
|
+
data.tar.gz: ceba1c8756edf06e496dd51791dc50c1390b0eeafd4c9bc08c45036721525f75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b123a5db0ed451dd9964901098f3db0cd5103a84e6e0aac3b72da6127b54e53ebee9e66705bc7dfaa91958142d9d3126c907646fbd7fbbca8409be1e188a340
|
7
|
+
data.tar.gz: aec4a96ac4e5a99acc62aaccfb8358e5421adedf8e72647d25e2d63c896581a952dfe6f81eb38a896bcfb08a334ce9df0ab2fab4a3a2631e866968b8739a4e8e
|
data/Readme.md
CHANGED
@@ -66,7 +66,39 @@ 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://
|
69
|
+
- [unify JUnit output](http://dresscode.renttherunway.com/blog/631) for rspec
|
70
|
+
|
71
|
+
|
72
|
+
before(:all) rspec hooks
|
73
|
+
========================
|
74
|
+
|
75
|
+
The `before(:all)` hooks in rspec will be executed once for every process that runs a test in an example group. This means if you have more processes than tests in a group, the `before(:all)` block for that group will be fired N times. For example, this spec has 3 tests and a `before(:all)` block:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
describe "before all behavior"
|
79
|
+
before(:all) do
|
80
|
+
puts "Process: #{Process.pid} Before ALL"
|
81
|
+
end
|
82
|
+
|
83
|
+
it "a" do
|
84
|
+
end
|
85
|
+
|
86
|
+
it "b" do
|
87
|
+
end
|
88
|
+
|
89
|
+
it "c" do
|
90
|
+
end
|
91
|
+
end
|
92
|
+
```
|
93
|
+
|
94
|
+
When you run this with 3 or more processes you'll see the `before(:all)` call is invoked 3 times, once per each process (since "a", "b", and "c" tests are each run on a different process).
|
95
|
+
|
96
|
+
```
|
97
|
+
$ PARALLEL_SPLIT_TEST_PROCESSES=3 bundle exec parallel_split_test spec/ | grep "Before ALL"
|
98
|
+
Process: 31539 Before ALL
|
99
|
+
Process: 31538 Before ALL
|
100
|
+
Process: 31540 Before ALL
|
101
|
+
```
|
70
102
|
|
71
103
|
TODO
|
72
104
|
====
|
@@ -78,6 +110,7 @@ Authors
|
|
78
110
|
|
79
111
|
### [Contributors](https://github.com/grosser/parallel_split_test/contributors)
|
80
112
|
- [bootstraponline](https://github.com/bootstraponline)
|
113
|
+
- [ModST](https://github.com/ModST)
|
81
114
|
|
82
115
|
[Michael Grosser](http://grosser.it)<br/>
|
83
116
|
michael@grosser.it<br/>
|
data/bin/parallel_split_test
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'parallel_split_test'
|
2
2
|
require 'parallel_split_test/output_recorder'
|
3
3
|
require 'parallel'
|
4
|
-
require 'rspec'
|
5
|
-
require 'parallel_split_test/core_ext/
|
4
|
+
require 'rspec/core'
|
5
|
+
require 'parallel_split_test/core_ext/rspec_world'
|
6
6
|
|
7
7
|
module ParallelSplitTest
|
8
8
|
class CommandLine < RSpec::Core::Runner
|
@@ -13,6 +13,7 @@ module ParallelSplitTest
|
|
13
13
|
|
14
14
|
def run(err, out)
|
15
15
|
no_summary = @args.delete('--no-summary')
|
16
|
+
no_merge = @args.delete('--no-merge')
|
16
17
|
|
17
18
|
@options = RSpec::Core::ConfigurationOptions.new(@args)
|
18
19
|
|
@@ -24,13 +25,11 @@ module ParallelSplitTest
|
|
24
25
|
ParallelSplitTest.process_number = process_number
|
25
26
|
set_test_env_number(process_number)
|
26
27
|
modify_out_file_in_args(process_number) if out_file
|
27
|
-
|
28
28
|
out = OutputRecorder.new(out)
|
29
|
-
|
30
|
-
[run_group_of_tests, out.recorded]
|
29
|
+
[super(err, out), out.recorded]
|
31
30
|
end
|
32
31
|
|
33
|
-
combine_out_files if out_file
|
32
|
+
combine_out_files if out_file unless no_merge
|
34
33
|
|
35
34
|
reprint_result_lines(out, results.map(&:last)) unless no_summary
|
36
35
|
results.map(&:first).max # combine exit status
|
@@ -40,7 +39,7 @@ module ParallelSplitTest
|
|
40
39
|
|
41
40
|
# modify + reparse args to unify output
|
42
41
|
def modify_out_file_in_args(process_number)
|
43
|
-
@args[out_file_position] = "#{
|
42
|
+
@args[out_file_position] = "#{out_file_parent_dir}/#{out_file_basename}.#{process_number}#{File.extname(out_file)}"
|
44
43
|
@options = RSpec::Core::ConfigurationOptions.new(@args)
|
45
44
|
end
|
46
45
|
|
@@ -52,6 +51,14 @@ module ParallelSplitTest
|
|
52
51
|
@out_file ||= @args[out_file_position] if out_file_position
|
53
52
|
end
|
54
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
|
+
|
55
62
|
def out_file_position
|
56
63
|
@out_file_position ||= begin
|
57
64
|
if out_position = @args.index { |i| ["-o", "--out"].include?(i) }
|
@@ -62,7 +69,7 @@ module ParallelSplitTest
|
|
62
69
|
|
63
70
|
def combine_out_files
|
64
71
|
File.open(out_file, "w") do |f|
|
65
|
-
Dir["#{out_file}
|
72
|
+
Dir["#{out_file_parent_dir}/#{out_file_basename}.*#{File.extname(out_file)}"].each do |file|
|
66
73
|
f.write File.read(file)
|
67
74
|
File.delete(file)
|
68
75
|
end
|
@@ -74,24 +81,5 @@ module ParallelSplitTest
|
|
74
81
|
out.puts "Summary:"
|
75
82
|
out.puts printed_outputs.map{|o| o[/.*\d+ failure.*/] }.join("\n")
|
76
83
|
end
|
77
|
-
|
78
|
-
def run_group_of_tests
|
79
|
-
example_count = @world.example_count / ParallelSplitTest.processes
|
80
|
-
|
81
|
-
@configuration.reporter.report(example_count) do |reporter|
|
82
|
-
groups = @world.example_groups
|
83
|
-
results = groups.map {|g| g.run(reporter)}
|
84
|
-
results.all? ? 0 : @configuration.failure_exit_code
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
# https://github.com/rspec/rspec-core/blob/6ee92a0d47bcb1f3abcd063dca2cee005356d709/lib/rspec/core/runner.rb#L93
|
89
|
-
def setup_copied_from_rspec(err, out)
|
90
|
-
@configuration.error_stream = err
|
91
|
-
@configuration.output_stream = out if @configuration.output_stream == $stdout
|
92
|
-
@options.configure(@configuration)
|
93
|
-
@configuration.load_spec_files
|
94
|
-
@world.announce_filters
|
95
|
-
end
|
96
84
|
end
|
97
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
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel_split_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.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:
|
11
|
+
date: 2021-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: rspec
|
14
|
+
name: rspec-core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -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/
|
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:
|
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
|
-
|
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
|