minitest-fork_executor 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/minitest/fork_executor.rb +23 -16
- data/test/minitest/fork_executor_test.rb +1 -1
- metadata +25 -12
- checksums.yaml +0 -7
@@ -1,23 +1,25 @@
|
|
1
1
|
module Minitest
|
2
2
|
class ForkExecutor
|
3
|
+
# Minitest runs individual test cases via Minitest.run_one_method. When
|
4
|
+
# ForkExecutor is started, we need to override it and implement the fork
|
5
|
+
# algorithm. See the detailed comments below to understand how it's done.
|
6
|
+
#
|
7
|
+
# Please keep in mind we support Ruby 1.9 and hence can't use conveniences
|
8
|
+
# offered by more modern Rubies.
|
3
9
|
def start
|
4
|
-
#
|
5
|
-
|
6
|
-
# fork there. run_one_method is a method on the Minitest module so we need
|
7
|
-
# to *prepend* our version so that it's called first.
|
8
|
-
metaclass = (class << Minitest; self; end)
|
9
|
-
metaclass.prepend ClassMethods
|
10
|
-
end
|
10
|
+
# Store the reference to the original run_one_method singleton method.
|
11
|
+
original_run_one_method = Minitest.method(:run_one_method)
|
11
12
|
|
12
|
-
|
13
|
-
#
|
14
|
-
|
13
|
+
# Remove the original singleton method from Minitest in order to avoid
|
14
|
+
# method redefinition warnings when patching it in the next step.
|
15
|
+
class << Minitest
|
16
|
+
remove_method(:run_one_method)
|
17
|
+
end
|
15
18
|
|
16
|
-
|
17
|
-
#
|
18
|
-
#
|
19
|
-
|
20
|
-
def run_one_method klass, method_name
|
19
|
+
# Define a new version of run_one_method that forks, calls the original
|
20
|
+
# run_one_method in the child process, and sends results back to the
|
21
|
+
# parent.
|
22
|
+
Minitest.define_singleton_method(:run_one_method) do |klass, method_name|
|
21
23
|
read_io, write_io = IO.pipe
|
22
24
|
read_io.binmode
|
23
25
|
write_io.binmode
|
@@ -33,7 +35,7 @@ module Minitest
|
|
33
35
|
else
|
34
36
|
# Child: just run normally, dump the result, and exit the process to
|
35
37
|
# avoid double-reporting.
|
36
|
-
result =
|
38
|
+
result = original_run_one_method.call(klass, method_name)
|
37
39
|
|
38
40
|
read_io.close
|
39
41
|
Marshal.dump(result, write_io)
|
@@ -44,5 +46,10 @@ module Minitest
|
|
44
46
|
result
|
45
47
|
end
|
46
48
|
end
|
49
|
+
|
50
|
+
def shutdown
|
51
|
+
# Nothing to do here but required by Minitest. In a future version, we may
|
52
|
+
# reinstate the original Minitest.run_one_method here.
|
53
|
+
end
|
47
54
|
end
|
48
55
|
end
|
@@ -15,7 +15,7 @@ Minitest.parallel_executor = Minitest::ForkExecutor.new
|
|
15
15
|
# 2. These processes are different from the parent process that spawned the
|
16
16
|
# test suite - hence recording @@parent_pid at the top.
|
17
17
|
class ForkTest < Minitest::Test
|
18
|
-
@@log = Tempfile.new
|
18
|
+
@@log = Tempfile.new('pid')
|
19
19
|
@@parent_pid = Process.pid
|
20
20
|
|
21
21
|
def test_run_in_process_one
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-fork_executor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Greg Navis
|
@@ -13,31 +14,35 @@ dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: minitest
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rake
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - '='
|
32
36
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
37
|
+
version: 12.2.1
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- -
|
43
|
+
- - '='
|
39
44
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
45
|
+
version: 12.2.1
|
41
46
|
description: Run each test_* method in a separate process thus eliminating test case
|
42
47
|
interference.
|
43
48
|
email: contact@gregnavis.com
|
@@ -50,25 +55,33 @@ files:
|
|
50
55
|
homepage: https://github.com/gregnavis/minitest-fork_executor
|
51
56
|
licenses:
|
52
57
|
- MIT
|
53
|
-
metadata: {}
|
54
58
|
post_install_message:
|
55
59
|
rdoc_options: []
|
56
60
|
require_paths:
|
57
61
|
- lib
|
58
62
|
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
59
64
|
requirements:
|
60
|
-
- -
|
65
|
+
- - ! '>='
|
61
66
|
- !ruby/object:Gem::Version
|
62
67
|
version: '0'
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
hash: -1027518140381874469
|
63
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
64
73
|
requirements:
|
65
|
-
- -
|
74
|
+
- - ! '>='
|
66
75
|
- !ruby/object:Gem::Version
|
67
76
|
version: '0'
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
hash: -1027518140381874469
|
68
80
|
requirements: []
|
69
|
-
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.8.23.2
|
70
83
|
signing_key:
|
71
|
-
specification_version:
|
84
|
+
specification_version: 3
|
72
85
|
summary: Near-perfect process-level test case isolation.
|
73
86
|
test_files:
|
74
87
|
- test/minitest/fork_executor_test.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA256:
|
3
|
-
metadata.gz: b399f50e3a52b2505c2125113c05ab712b1db59d26f00dd1075d7be2346c979b
|
4
|
-
data.tar.gz: a3394aab364af126482879b30badfd400ab2168185b1e746305555c42ef84ff2
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: b6014495cb3f12a88165cb983533be9a9b2f4e3188cbb67fa2e355577de3af285fc0ea6bf575e82e194d2526bedfa25ef979482be9377d96e1ca67082994a211
|
7
|
-
data.tar.gz: d887d4b98c08f8c7ba5e5c41687b88875ea431c9dd4ea0fbf5cb546947a524c6326ea5212519c98dcf3c91bceb417cc8feaeb04c1ef6e00cf6face124e8fef62
|