minitest-parallel_fork 1.1.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +16 -0
- data/README.rdoc +9 -0
- data/lib/minitest/parallel_fork.rb +23 -12
- metadata +38 -10
- data/Rakefile +0 -46
- data/spec/minitest_parallel_fork_example.rb +0 -41
- data/spec/minitest_parallel_fork_spec.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7def66702fe6ea3e7cf52578a812f0ecdbb4b3545c2bd4d04ee5ff73a417af5
|
4
|
+
data.tar.gz: 138a5104f9f344284e806a6b90deb20d61fdf2b16562488b8afc3917f9d8738d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbc75286347260d6a6cd54e3c8bb1c21f1cd3c9c24c2e843a3942ab7056fc53e4ee092a4a65cb66e52816433a96dfbdfd338b871e334acc1e973fa80ad184d6c
|
7
|
+
data.tar.gz: f882ac98930a53fa6ec7d02b3edf50bf9a34b3bb7ce17f72b834879313df0f251c9aa23ea45b5cb1f4d02e969933728dca5ec7f1e8898c3c4cc9b2e7d95fe487
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
=== 1.3.0 (2022-07-05)
|
2
|
+
|
3
|
+
* Bump minimum minitest version to 5.15.0 (jeremyevans)
|
4
|
+
|
5
|
+
* Detect reporter to use by looking for specific methods, instead of specifically for a Minitest::StatisticsReporter (jeremyevans) (#8)
|
6
|
+
|
7
|
+
=== 1.2.0 (2021-08-16)
|
8
|
+
|
9
|
+
* Work correctly with Minitest 5.14+ (jeremyevans)
|
10
|
+
|
11
|
+
* Add on_parallel_fork_marshal_failure hook for handling marshal failures (child process exiting) (jeremyevans)
|
12
|
+
|
13
|
+
=== 1.1.2 (2018-07-05)
|
14
|
+
|
15
|
+
* Handle raised exceptions containing unmarshallable data (jeremyevans)
|
16
|
+
|
1
17
|
=== 1.1.1 (2018-05-07)
|
2
18
|
|
3
19
|
* Work around marshalling issue when there are failures in *_all hooks when using minitest-hooks (jeremyevans)
|
data/README.rdoc
CHANGED
@@ -59,6 +59,15 @@ disconnected, and after forking, the database name is changed in each child to r
|
|
59
59
|
a child-specific database, so that the child processes do not share a database and are
|
60
60
|
thus independent.
|
61
61
|
|
62
|
+
There is also a hook for debugging. +on_parallel_fork_marshal_failure+ is called if
|
63
|
+
there is an error unmarshalling data sent from the child process to the parent process.
|
64
|
+
This can happen if one of the child processes exits unexpected during the test, before
|
65
|
+
it reports results.
|
66
|
+
|
67
|
+
Minitest.on_parallel_fork_marshal_failure do
|
68
|
+
# Gather relevant logs for more debugging
|
69
|
+
end
|
70
|
+
|
62
71
|
== ActiveRecord
|
63
72
|
|
64
73
|
To use this with Rails/ActiveRecord, you probably want to use hooks similar to:
|
@@ -6,18 +6,28 @@ module Minitest
|
|
6
6
|
def self.before_parallel_fork(&block)
|
7
7
|
@before_parallel_fork = block
|
8
8
|
end
|
9
|
+
@before_parallel_fork = nil
|
9
10
|
|
10
11
|
# Set the after_parallel_fork block to the given block
|
11
12
|
def self.after_parallel_fork(i=nil, &block)
|
12
13
|
@after_parallel_fork = block
|
13
14
|
end
|
15
|
+
@after_parallel_fork = nil
|
16
|
+
|
17
|
+
# Set the on_parallel_fork_marshal_failure block to the given block
|
18
|
+
def self.on_parallel_fork_marshal_failure(&block)
|
19
|
+
@on_parallel_fork_marshal_failure = block
|
20
|
+
end
|
21
|
+
@on_parallel_fork_marshal_failure = nil
|
14
22
|
|
15
23
|
module Unparallelize
|
16
24
|
define_method(:run_one_method, &Minitest::Test.method(:run_one_method))
|
17
25
|
end
|
18
26
|
|
19
27
|
def self.parallel_fork_stat_reporter(reporter)
|
20
|
-
reporter.reporters.detect
|
28
|
+
reporter.reporters.detect do |rep|
|
29
|
+
%w'count assertions results count= assertions='.all?{|meth| rep.respond_to?(meth)}
|
30
|
+
end
|
21
31
|
end
|
22
32
|
|
23
33
|
# Override __run to use a child forks to run the speeds, which
|
@@ -28,15 +38,15 @@ module Minitest
|
|
28
38
|
|
29
39
|
n = (ENV['NCPU'] || 4).to_i
|
30
40
|
reads = []
|
31
|
-
if
|
41
|
+
if @before_parallel_fork
|
32
42
|
@before_parallel_fork.call
|
33
43
|
end
|
34
44
|
n.times do |i|
|
35
45
|
read, write = IO.pipe.each{|io| io.binmode}
|
36
46
|
reads << read
|
37
|
-
fork do
|
47
|
+
Process.fork do
|
38
48
|
read.close
|
39
|
-
if
|
49
|
+
if @after_parallel_fork
|
40
50
|
@after_parallel_fork.call(i)
|
41
51
|
end
|
42
52
|
|
@@ -44,19 +54,13 @@ module Minitest
|
|
44
54
|
suites.each_with_index{|s, j| p_suites << s if j % n == i}
|
45
55
|
p_suites.each do |s|
|
46
56
|
if s.is_a?(Minitest::Parallel::Test::ClassMethods)
|
47
|
-
|
57
|
+
s.extend(Unparallelize)
|
48
58
|
end
|
49
59
|
|
50
60
|
s.run(reporter, options)
|
51
61
|
end
|
52
62
|
|
53
63
|
data = %w'count assertions results'.map{|meth| stat_reporter.send(meth)}
|
54
|
-
if data[-1].any?{|result| !result.is_a?(Minitest::Result)}
|
55
|
-
data[-1] = data[-1].map do |result|
|
56
|
-
Minitest::Result.from(result)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
64
|
write.write(Marshal.dump(data))
|
61
65
|
write.close
|
62
66
|
end
|
@@ -64,7 +68,14 @@ module Minitest
|
|
64
68
|
end
|
65
69
|
|
66
70
|
reads.map{|read| Thread.new(read, &:read)}.map(&:value).each do |data|
|
67
|
-
|
71
|
+
begin
|
72
|
+
count, assertions, results = Marshal.load(data)
|
73
|
+
rescue ArgumentError
|
74
|
+
if @on_parallel_fork_marshal_failure
|
75
|
+
@on_parallel_fork_marshal_failure.call
|
76
|
+
end
|
77
|
+
raise
|
78
|
+
end
|
68
79
|
stat_reporter.count += count
|
69
80
|
stat_reporter.assertions += assertions
|
70
81
|
stat_reporter.results.concat(results)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-parallel_fork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -16,14 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.
|
19
|
+
version: 5.15.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.15.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest-hooks
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest-global_expectations
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
20
48
|
type: :development
|
21
49
|
prerelease: false
|
22
50
|
version_requirements: !ruby/object:Gem::Requirement
|
23
51
|
requirements:
|
24
52
|
- - ">="
|
25
53
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
54
|
+
version: '0'
|
27
55
|
description: |
|
28
56
|
minitest-parallel_fork adds fork-based parallelization to Minitest. Each test/spec
|
29
57
|
suite is run in one of the forks, allowing this to work correctly when using
|
@@ -42,14 +70,15 @@ files:
|
|
42
70
|
- CHANGELOG
|
43
71
|
- MIT-LICENSE
|
44
72
|
- README.rdoc
|
45
|
-
- Rakefile
|
46
73
|
- lib/minitest/parallel_fork.rb
|
47
|
-
- spec/minitest_parallel_fork_example.rb
|
48
|
-
- spec/minitest_parallel_fork_spec.rb
|
49
74
|
homepage: http://github.com/jeremyevans/minitest-parallel_fork
|
50
75
|
licenses:
|
51
76
|
- MIT
|
52
|
-
metadata:
|
77
|
+
metadata:
|
78
|
+
bug_tracker_uri: https://github.com/jeremyevans/minitest-parallel_fork/issues
|
79
|
+
changelog_uri: https://github.com/jeremyevans/minitest-parallel_fork/blob/master/CHANGELOG
|
80
|
+
mailing_list_uri: https://github.com/jeremyevans/minitest-parallel_fork/discussions
|
81
|
+
source_code_uri: https://github.com/jeremyevans/minitest-parallel_fork
|
53
82
|
post_install_message:
|
54
83
|
rdoc_options:
|
55
84
|
- "--quiet"
|
@@ -72,8 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
101
|
- !ruby/object:Gem::Version
|
73
102
|
version: '0'
|
74
103
|
requirements: []
|
75
|
-
|
76
|
-
rubygems_version: 2.7.6
|
104
|
+
rubygems_version: 3.3.7
|
77
105
|
signing_key:
|
78
106
|
specification_version: 4
|
79
107
|
summary: Fork-based parallelization for minitest
|
data/Rakefile
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require "rake"
|
2
|
-
require "rake/clean"
|
3
|
-
|
4
|
-
CLEAN.include ["minitest-parallel_fork-*.gem", "rdoc", "coverage"]
|
5
|
-
|
6
|
-
desc "Build minitest-parallel_fork gem"
|
7
|
-
task :package=>[:clean] do |p|
|
8
|
-
sh %{#{FileUtils::RUBY} -S gem build minitest-parallel_fork.gemspec}
|
9
|
-
end
|
10
|
-
|
11
|
-
### Specs
|
12
|
-
|
13
|
-
desc "Run specs"
|
14
|
-
task :spec do
|
15
|
-
ENV['RUBY'] = FileUtils::RUBY
|
16
|
-
sh %{#{FileUtils::RUBY} spec/minitest_parallel_fork_spec.rb}
|
17
|
-
end
|
18
|
-
|
19
|
-
task :default=>:spec
|
20
|
-
|
21
|
-
### RDoc
|
22
|
-
|
23
|
-
RDOC_DEFAULT_OPTS = ["--quiet", "--line-numbers", "--inline-source", '--title', 'minitest-parallel_fork: fork-based parallelization for minitest']
|
24
|
-
|
25
|
-
begin
|
26
|
-
gem 'hanna-nouveau'
|
27
|
-
RDOC_DEFAULT_OPTS.concat(['-f', 'hanna'])
|
28
|
-
rescue Gem::LoadError
|
29
|
-
end
|
30
|
-
|
31
|
-
rdoc_task_class = begin
|
32
|
-
require "rdoc/task"
|
33
|
-
RDoc::Task
|
34
|
-
rescue LoadError
|
35
|
-
require "rake/rdoctask"
|
36
|
-
Rake::RDocTask
|
37
|
-
end
|
38
|
-
|
39
|
-
RDOC_OPTS = RDOC_DEFAULT_OPTS + ['--main', 'README.rdoc']
|
40
|
-
|
41
|
-
rdoc_task_class.new do |rdoc|
|
42
|
-
rdoc.rdoc_dir = "rdoc"
|
43
|
-
rdoc.options += RDOC_OPTS
|
44
|
-
rdoc.rdoc_files.add %w"README.rdoc CHANGELOG MIT-LICENSE lib/**/*.rb"
|
45
|
-
end
|
46
|
-
|
@@ -1,41 +0,0 @@
|
|
1
|
-
gem 'minitest'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require 'minitest/parallel_fork'
|
4
|
-
|
5
|
-
a = nil
|
6
|
-
Minitest.before_parallel_fork do
|
7
|
-
a = 'a'
|
8
|
-
print ":parent"
|
9
|
-
end
|
10
|
-
|
11
|
-
Minitest.after_parallel_fork do |i|
|
12
|
-
print ":child#{i}#{a}"
|
13
|
-
end
|
14
|
-
|
15
|
-
4.times do |i|
|
16
|
-
describe 'minitest/parallel_fork' do
|
17
|
-
parallelize_me! if ENV['MPF_PARALLELIZE_ME']
|
18
|
-
|
19
|
-
if ENV['MPF_TEST_ORDER_PARALLEL']
|
20
|
-
def self.test_order
|
21
|
-
:parallel
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should work" do
|
26
|
-
sleep(1).must_equal 1
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should fail" do
|
30
|
-
1.must_equal 2
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should raise" do
|
34
|
-
raise
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should skip" do
|
38
|
-
skip
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
gem 'minitest'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
|
4
|
-
describe 'minitest/parallel_fork' do
|
5
|
-
[[nil, ''],
|
6
|
-
['MPF_PARALLELIZE_ME', ' when parallelize_me! is used'],
|
7
|
-
['MPF_TEST_ORDER_PARALLEL', ' when test_order parallel is used']
|
8
|
-
].each do |env_key, msg|
|
9
|
-
it "should execute in parallel#{msg}" do
|
10
|
-
t = Time.now
|
11
|
-
ENV['NCPU'] = '4'
|
12
|
-
ENV[env_key] = '1' if env_key
|
13
|
-
output = `#{ENV['RUBY']} -I lib spec/minitest_parallel_fork_example.rb`
|
14
|
-
ENV.delete(env_key) if env_key
|
15
|
-
|
16
|
-
time = (Time.now - t)
|
17
|
-
time.must_be :<, 4
|
18
|
-
time.must_be :>, 1
|
19
|
-
output.must_match /:parent/
|
20
|
-
output.must_match /16 runs, 8 assertions, 4 failures, 4 errors, 4 skips/
|
21
|
-
4.times do |i|
|
22
|
-
output.must_match /:child#{i}a/
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|