parallel_split_test 0.5.0 → 0.9.1

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: 2e90a44b561fab085aee56146c75c9e233a053f2
4
- data.tar.gz: fee213704dc9f492d09ba8c443620dce366a2626
2
+ SHA256:
3
+ metadata.gz: 63649587db8f5ef9ea136995167e1c88e67d7a37272c6f49ceb1d7a41e6e3e5d
4
+ data.tar.gz: '09c65524b921bcc0e9c93965b6d7317812bc4344b21c55c4ac7a1378e6031956'
5
5
  SHA512:
6
- metadata.gz: ed9ced1cb0a6450edf873c170a33df479defdf043e9e1b05a105551674208e990b8d5fa6a2cd799f7d7f26bf13dd23947dfa4e59e0254cf43bcd5443525769b9
7
- data.tar.gz: 4a86e76334fee6419befa5a688aafd2c2a1687f520f119cabbc18c0869fdd79e66191d5f4864c6e66215f10dde1d2a1037826685186f9aecfeb1c1f58756bd73
6
+ metadata.gz: fd8036881633b94933c0c27e5b69f1ffdd995c6d4398f13c14bfd6a46efcc98e1fc144fee0fa3304c695f4a2c425a578166dfea12658779c822dd4004c7c50ab
7
+ data.tar.gz: 53963087abed65236c9cc349e4eedc5a6fafdcc856f0093327b921b5a3780dfdde6afeae08a8ca40e7d97ea9b2e820413136a768cbe2ea1dc95ee6ed0bb16286
data/Readme.md CHANGED
@@ -68,6 +68,38 @@ TIPS
68
68
  - set number of processes to use with `PARALLEL_SPLIT_TEST_PROCESSES` environment variable
69
69
  - [unify JUnit output](http://dresscode.renttherunway.com/blog/631) for rspec
70
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
+ ```
102
+
71
103
  TODO
72
104
  ====
73
105
  - Cucumber support
@@ -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/rspec_example'
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
@@ -26,11 +26,9 @@ module ParallelSplitTest
26
26
  set_test_env_number(process_number)
27
27
  modify_out_file_in_args(process_number) if out_file
28
28
  out = OutputRecorder.new(out)
29
- setup_copied_from_rspec(err, out)
30
- [run_group_of_tests, out.recorded]
29
+ [super(err, out), out.recorded]
31
30
  end
32
31
 
33
-
34
32
  combine_out_files if out_file unless no_merge
35
33
 
36
34
  reprint_result_lines(out, results.map(&:last)) unless no_summary
@@ -41,7 +39,7 @@ module ParallelSplitTest
41
39
 
42
40
  # modify + reparse args to unify output
43
41
  def modify_out_file_in_args(process_number)
44
- @args[out_file_position] = process_number.to_s << "-" << out_file
42
+ @args[out_file_position] = "#{out_file_parent_dir}/#{out_file_basename}.#{process_number}#{File.extname(out_file)}"
45
43
  @options = RSpec::Core::ConfigurationOptions.new(@args)
46
44
  end
47
45
 
@@ -53,6 +51,14 @@ module ParallelSplitTest
53
51
  @out_file ||= @args[out_file_position] if out_file_position
54
52
  end
55
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
+
56
62
  def out_file_position
57
63
  @out_file_position ||= begin
58
64
  if out_position = @args.index { |i| ["-o", "--out"].include?(i) }
@@ -63,7 +69,7 @@ module ParallelSplitTest
63
69
 
64
70
  def combine_out_files
65
71
  File.open(out_file, "w") do |f|
66
- Dir["*-#{out_file}"].each do |file|
72
+ Dir["#{out_file_parent_dir}/#{out_file_basename}.*#{File.extname(out_file)}"].each do |file|
67
73
  f.write File.read(file)
68
74
  File.delete(file)
69
75
  end
@@ -75,24 +81,5 @@ module ParallelSplitTest
75
81
  out.puts "Summary:"
76
82
  out.puts printed_outputs.map{|o| o[/.*\d+ failure.*/] }.join("\n")
77
83
  end
78
-
79
- def run_group_of_tests
80
- example_count = @world.example_count / ParallelSplitTest.processes
81
-
82
- @configuration.reporter.report(example_count) do |reporter|
83
- groups = @world.example_groups
84
- results = groups.map {|g| g.run(reporter)}
85
- results.all? ? 0 : @configuration.failure_exit_code
86
- end
87
- end
88
-
89
- # https://github.com/rspec/rspec-core/blob/6ee92a0d47bcb1f3abcd063dca2cee005356d709/lib/rspec/core/runner.rb#L93
90
- def setup_copied_from_rspec(err, out)
91
- @configuration.error_stream = err
92
- @configuration.output_stream = out if @configuration.output_stream == $stdout
93
- @options.configure(@configuration)
94
- @configuration.load_spec_files
95
- @world.announce_filters
96
- end
97
84
  end
98
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.5.0'
2
+ VERSION = '0.9.1'
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_split_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.9.1
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: 2021-02-25 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
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.1.0
19
+ version: 3.9.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 3.1.0
26
+ version: 3.9.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: parallel
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -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: 2.1.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.4.5.1
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