forking_test_runner 1.13.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/forking-test-runner +2 -1
- data/lib/forking_test_runner/cli.rb +7 -6
- data/lib/forking_test_runner/coverage_capture.rb +3 -3
- data/lib/forking_test_runner/version.rb +2 -1
- data/lib/forking_test_runner.rb +24 -17
- metadata +48 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e38d2bbf3dd185f3f8c912537be54a0068c98db3c45b17edda9a53a01ccd63d8
|
4
|
+
data.tar.gz: 63393812f02d8841d6ee56c000d9400e0062f405d7eb95eccbd766a93877e7d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cf9450f7cf1fc7259bf5ec9a51f88141ce7e937aca94152577919117ff1fbec3311591f045b01864cd644b6ada45e71265656c91c067242da7c4195e987df27
|
7
|
+
data.tar.gz: ac79e34dab39a08445773c394b1912f7119605187cf2a09af670e94f54b2c2d786dc43a09968e50443881220d7d62f7bfcebf167521569b497d96603714962d5
|
data/bin/forking-test-runner
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
# enable local usage from cloned repo
|
4
|
-
root = File.expand_path(
|
5
|
+
root = File.expand_path('..', __dir__)
|
5
6
|
$LOAD_PATH << "#{root}/lib" if File.exist?("#{root}/Gemfile")
|
6
7
|
|
7
8
|
require 'forking_test_runner'
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module ForkingTestRunner
|
2
3
|
# read and delete options we support and pass the rest through to the underlying test runner (-v / --seed etc)
|
3
4
|
module CLI
|
@@ -11,9 +12,9 @@ module ForkingTestRunner
|
|
11
12
|
[
|
12
13
|
:record_runtime,
|
13
14
|
"--record-runtime=MODE",
|
14
|
-
"\n Record test runtime:\n"
|
15
|
-
|
16
|
-
|
15
|
+
"\n Record test runtime:\n " \
|
16
|
+
"simple = write to disk at --runtime-log)\n " \
|
17
|
+
"amend = write from multiple remote workers via http://github.com/grosser/amend, needs TRAVIS_REPO_SLUG & TRAVIS_BUILD_NUMBER",
|
17
18
|
String
|
18
19
|
],
|
19
20
|
[:runtime_log, "--runtime-log=FILE", "File to store runtime log in or runtime.log", String],
|
@@ -22,7 +23,7 @@ module ForkingTestRunner
|
|
22
23
|
[:groups, "--groups=NUM", "How many groups there are in total (use with --group)", Integer],
|
23
24
|
[:version, "--version", "Show version"],
|
24
25
|
[:help, "--help", "Show help"]
|
25
|
-
]
|
26
|
+
].freeze
|
26
27
|
|
27
28
|
class << self
|
28
29
|
def parse_options(argv)
|
@@ -43,8 +44,8 @@ module ForkingTestRunner
|
|
43
44
|
end
|
44
45
|
|
45
46
|
# check if we can use merge_coverage
|
46
|
-
if options.fetch(:merge_coverage)
|
47
|
-
abort "merge_coverage does not work on ruby prior to 2.3"
|
47
|
+
if options.fetch(:merge_coverage) && "2.3.0" > RUBY_VERSION
|
48
|
+
abort "merge_coverage does not work on ruby prior to 2.3"
|
48
49
|
end
|
49
50
|
|
50
51
|
if !!options.fetch(:group) ^ !!options.fetch(:groups)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module ForkingTestRunner
|
2
3
|
module CoverageCapture
|
3
4
|
# override Coverage.result to add pre-fork captured coverage
|
@@ -7,8 +8,7 @@ module ForkingTestRunner
|
|
7
8
|
end
|
8
9
|
|
9
10
|
# deprecated, single_cov checks for this, so leave it here
|
10
|
-
def capture_coverage
|
11
|
-
end
|
11
|
+
def capture_coverage!; end
|
12
12
|
|
13
13
|
class << self
|
14
14
|
attr_accessor :coverage
|
@@ -49,7 +49,7 @@ module ForkingTestRunner
|
|
49
49
|
def merge_lines_coverage(a, b)
|
50
50
|
b.each_with_index.map do |b_count, i|
|
51
51
|
a_count = a[i]
|
52
|
-
|
52
|
+
a_count.nil? && b_count.nil? ? nil : a_count.to_i + b_count.to_i
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
data/lib/forking_test_runner.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'benchmark'
|
2
3
|
require 'optparse'
|
3
4
|
require 'forking_test_runner/version'
|
@@ -11,7 +12,6 @@ module ForkingTestRunner
|
|
11
12
|
CONVERAGE_REPORT_PREFIX = "coverage/fork-"
|
12
13
|
|
13
14
|
class << self
|
14
|
-
|
15
15
|
attr_accessor :before_fork_callbacks, :after_fork_callbacks
|
16
16
|
|
17
17
|
def cli(argv)
|
@@ -42,19 +42,19 @@ module ForkingTestRunner
|
|
42
42
|
|
43
43
|
# run all the tests
|
44
44
|
results = with_lock do |lock|
|
45
|
-
Parallel.map_with_index(test_groups, in_processes: parallel || 0) do |
|
45
|
+
Parallel.map_with_index(test_groups, in_processes: parallel || 0) do |tests_group, env_index|
|
46
46
|
if parallel
|
47
47
|
ENV["TEST_ENV_NUMBER"] = (env_index == 0 ? '' : (env_index + 1).to_s) # NOTE: does not support first_is_1 option
|
48
48
|
end
|
49
49
|
|
50
50
|
reraise_clean_ar_error { load_test_env }
|
51
51
|
|
52
|
-
|
52
|
+
tests_group.map do |file, expected|
|
53
53
|
print_started file unless parallel
|
54
54
|
result = [file, expected, *benchmark { run_test(file) }]
|
55
55
|
sync_stdout lock do
|
56
56
|
print_started file if parallel
|
57
|
-
print_finished
|
57
|
+
print_finished(*result)
|
58
58
|
end
|
59
59
|
result
|
60
60
|
end
|
@@ -64,9 +64,11 @@ module ForkingTestRunner
|
|
64
64
|
unless @options.fetch(:quiet)
|
65
65
|
# pretty print the results
|
66
66
|
puts "\nResults:"
|
67
|
-
puts
|
68
|
-
|
69
|
-
|
67
|
+
puts(
|
68
|
+
results
|
69
|
+
.sort_by { |_, _, _, r, _| r ? 0 : 1 } # failures should be last so they are easy to find
|
70
|
+
.map { |f, _, _, r, _| "#{f}: #{r ? "OK" : "Fail"}" }
|
71
|
+
)
|
70
72
|
puts
|
71
73
|
end
|
72
74
|
|
@@ -96,7 +98,7 @@ module ForkingTestRunner
|
|
96
98
|
|
97
99
|
def with_lock(&block)
|
98
100
|
return yield unless @options.fetch(:parallel)
|
99
|
-
Tempfile.open"forking-test-runner-lock", &block
|
101
|
+
Tempfile.open "forking-test-runner-lock", &block
|
100
102
|
end
|
101
103
|
|
102
104
|
def sync_stdout(lock)
|
@@ -161,7 +163,7 @@ module ForkingTestRunner
|
|
161
163
|
File.write(log, data)
|
162
164
|
when 'amend'
|
163
165
|
if id = ENV["BUILDKITE_JOB_ID"]
|
164
|
-
slug = ENV.fetch("BUILDKITE_ORG_SLUG")
|
166
|
+
slug = "#{ENV.fetch("BUILDKITE_ORG_SLUG")}-#{ENV.fetch("BUILDKITE_PIPELINE_SLUG")}"
|
165
167
|
else
|
166
168
|
slug = ENV.fetch("TRAVIS_REPO_SLUG").sub("/", "-")
|
167
169
|
id = ENV.fetch("TRAVIS_BUILD_NUMBER")
|
@@ -212,7 +214,7 @@ module ForkingTestRunner
|
|
212
214
|
e = begin
|
213
215
|
yield
|
214
216
|
nil
|
215
|
-
rescue
|
217
|
+
rescue StandardError
|
216
218
|
$!
|
217
219
|
end
|
218
220
|
|
@@ -223,7 +225,7 @@ module ForkingTestRunner
|
|
223
225
|
def load_test_helper
|
224
226
|
disable_test_autorun
|
225
227
|
require 'rspec/core' if @options.fetch(:rspec)
|
226
|
-
helper =
|
228
|
+
helper = @options.fetch(:helper) || (@options.fetch(:rspec) ? "spec/spec_helper" : "test/test_helper")
|
227
229
|
require "./#{helper}"
|
228
230
|
end
|
229
231
|
|
@@ -268,7 +270,7 @@ module ForkingTestRunner
|
|
268
270
|
|
269
271
|
wpipe.close
|
270
272
|
|
271
|
-
buffer = ""
|
273
|
+
buffer = +""
|
272
274
|
|
273
275
|
while ch = rpipe.read(1)
|
274
276
|
buffer << ch
|
@@ -283,7 +285,11 @@ module ForkingTestRunner
|
|
283
285
|
def preserve_tty
|
284
286
|
was_tty = $stdout.tty?
|
285
287
|
yield
|
286
|
-
|
288
|
+
if was_tty
|
289
|
+
def $stdout.tty?;
|
290
|
+
true;
|
291
|
+
end
|
292
|
+
end
|
287
293
|
end
|
288
294
|
|
289
295
|
def run_test(file)
|
@@ -317,7 +323,8 @@ module ForkingTestRunner
|
|
317
323
|
def change_program_name_to(name)
|
318
324
|
return yield if @options.fetch(:parallel)
|
319
325
|
begin
|
320
|
-
old
|
326
|
+
old = $0
|
327
|
+
$0 = name
|
321
328
|
yield
|
322
329
|
ensure
|
323
330
|
$0 = old
|
@@ -338,7 +345,7 @@ module ForkingTestRunner
|
|
338
345
|
group = groups[group - 1] || raise("Group #{group} not found")
|
339
346
|
|
340
347
|
# return tests with runtime
|
341
|
-
tests =
|
348
|
+
tests = tests.to_h
|
342
349
|
group.map { |test| [test, (tests[test] if group_by == :runtime)] }
|
343
350
|
end
|
344
351
|
|
@@ -354,7 +361,7 @@ module ForkingTestRunner
|
|
354
361
|
end
|
355
362
|
end
|
356
363
|
|
357
|
-
def toggle_test_autorun(value, file=nil)
|
364
|
+
def toggle_test_autorun(value, file = nil)
|
358
365
|
if @options.fetch(:rspec)
|
359
366
|
if value
|
360
367
|
exit(RSpec::Core::Runner.run([file] + ARGV))
|
@@ -391,7 +398,7 @@ module ForkingTestRunner
|
|
391
398
|
File.unlink(report) # do not leave junk behind
|
392
399
|
end
|
393
400
|
|
394
|
-
data = JSON.pretty_generate(key => {"coverage" => coverage, "timestamp" => Time.now.to_i })
|
401
|
+
data = JSON.pretty_generate(key => { "coverage" => coverage, "timestamp" => Time.now.to_i })
|
395
402
|
File.write(SingleCov.coverage_report, data)
|
396
403
|
|
397
404
|
# make it not override our report when it finishes for main process
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forking_test_runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel_tests
|
@@ -39,21 +39,27 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.3'
|
45
48
|
- - ">="
|
46
49
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
50
|
+
version: 2.3.27
|
48
51
|
type: :development
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '2.3'
|
52
58
|
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
60
|
+
version: 2.3.27
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
62
|
+
name: minitest
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - ">="
|
@@ -67,7 +73,7 @@ dependencies:
|
|
67
73
|
- !ruby/object:Gem::Version
|
68
74
|
version: '0'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
76
|
+
name: rake
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
79
|
- - ">="
|
@@ -81,7 +87,7 @@ dependencies:
|
|
81
87
|
- !ruby/object:Gem::Version
|
82
88
|
version: '0'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
90
|
+
name: rspec
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
93
|
- - ">="
|
@@ -94,7 +100,35 @@ dependencies:
|
|
94
100
|
- - ">="
|
95
101
|
- !ruby/object:Gem::Version
|
96
102
|
version: '0'
|
97
|
-
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rubocop
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.65.1
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 1.65.1
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: sqlite3
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 1.6.0
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 1.6.0
|
131
|
+
description:
|
98
132
|
email: michael@grosser.it
|
99
133
|
executables:
|
100
134
|
- forking-test-runner
|
@@ -111,7 +145,7 @@ homepage: https://github.com/grosser/forking_test_runner
|
|
111
145
|
licenses:
|
112
146
|
- MIT
|
113
147
|
metadata: {}
|
114
|
-
post_install_message:
|
148
|
+
post_install_message:
|
115
149
|
rdoc_options: []
|
116
150
|
require_paths:
|
117
151
|
- lib
|
@@ -119,15 +153,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
153
|
requirements:
|
120
154
|
- - ">="
|
121
155
|
- !ruby/object:Gem::Version
|
122
|
-
version: 2.
|
156
|
+
version: 2.7.0
|
123
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
158
|
requirements:
|
125
159
|
- - ">="
|
126
160
|
- !ruby/object:Gem::Version
|
127
161
|
version: '0'
|
128
162
|
requirements: []
|
129
|
-
rubygems_version: 3.
|
130
|
-
signing_key:
|
163
|
+
rubygems_version: 3.4.10
|
164
|
+
signing_key:
|
131
165
|
specification_version: 4
|
132
166
|
summary: Run every test in a fork to avoid pollution and get clean output per test
|
133
167
|
test_files: []
|