selective-ruby-minitest 0.1.3 → 0.1.5
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 +4 -4
- data/.rspec +2 -0
- data/.rwx/ci.yml +43 -0
- data/.rwx/test.yml +25 -0
- data/LICENSE +0 -0
- data/Rakefile +0 -0
- data/lib/selective/ruby/minitest/monkeypatches.rb +5 -3
- data/lib/selective/ruby/minitest/runner_wrapper.rb +94 -5
- data/lib/selective/ruby/minitest/version.rb +1 -1
- data/lib/selective-ruby-minitest.rb +0 -0
- metadata +41 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9cdd3bc1432a5d4ed5550f3a1cc8bd3034e4e96d6e24772e3b12c4170a0ff528
|
|
4
|
+
data.tar.gz: 3acd8d973aa50c2c2292181bb59c8e57bfe3236ca00ad0bcd713e77580bd74ca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7907431f1aa57483b1523156bce6c7d3a45546f8b4ddd10a49e69bb1f94c20d526bf3f045cb8a51a69f4835dfffbf94c9d861e0fc7fd54c57f6cf78fa8bd47ba
|
|
7
|
+
data.tar.gz: 2007ac6dd36e472874b51349bdea1b1096a939d12cd86d8e4cce94701bbd454ada0cfa50ba48754d37a5bbabd9be7ad4ae28f72fbe2da2f70f92f9859fb08dee
|
data/.rspec
ADDED
data/.rwx/ci.yml
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
on:
|
|
2
|
+
cli:
|
|
3
|
+
init:
|
|
4
|
+
commit-sha: ${{ event.git.sha }}
|
|
5
|
+
github:
|
|
6
|
+
push:
|
|
7
|
+
if: ${{ event.git.branch == 'main' }}
|
|
8
|
+
init:
|
|
9
|
+
commit-sha: ${{ event.git.sha }}
|
|
10
|
+
pull_request:
|
|
11
|
+
init:
|
|
12
|
+
commit-sha: ${{ event.git.sha }}
|
|
13
|
+
|
|
14
|
+
tasks:
|
|
15
|
+
- key: tests
|
|
16
|
+
parallel:
|
|
17
|
+
matrix:
|
|
18
|
+
ruby-version: ["2.7.8", "3.0.7", "3.1.7", "3.2.9", "3.3.10", "3.4.9", "4.0.7"]
|
|
19
|
+
call: ${{ run.dir }}/test.yml
|
|
20
|
+
init:
|
|
21
|
+
commit-sha: ${{ init.commit-sha }}
|
|
22
|
+
ruby-version: ${{ parallel.ruby-version }}
|
|
23
|
+
minitest-version: "~> 5.0"
|
|
24
|
+
|
|
25
|
+
- key: tests-minitest-6
|
|
26
|
+
parallel:
|
|
27
|
+
matrix:
|
|
28
|
+
ruby-version: ["3.2.9", "3.3.10", "3.4.9", "4.0.7"]
|
|
29
|
+
call: ${{ run.dir }}/test.yml
|
|
30
|
+
init:
|
|
31
|
+
commit-sha: ${{ init.commit-sha }}
|
|
32
|
+
ruby-version: ${{ parallel.ruby-version }}
|
|
33
|
+
minitest-version: "~> 6.0"
|
|
34
|
+
|
|
35
|
+
- key: tests-minitest-floor
|
|
36
|
+
parallel:
|
|
37
|
+
matrix:
|
|
38
|
+
ruby-version: ["2.7.8", "3.0.7", "3.1.7", "3.2.9", "3.3.10", "3.4.9"]
|
|
39
|
+
call: ${{ run.dir }}/test.yml
|
|
40
|
+
init:
|
|
41
|
+
commit-sha: ${{ init.commit-sha }}
|
|
42
|
+
ruby-version: ${{ parallel.ruby-version }}
|
|
43
|
+
minitest-version: "= 5.16.0"
|
data/.rwx/test.yml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
base:
|
|
2
|
+
image: ruby:${{ init.ruby-version }}
|
|
3
|
+
config: none
|
|
4
|
+
|
|
5
|
+
tasks:
|
|
6
|
+
- key: code
|
|
7
|
+
run: |
|
|
8
|
+
git init -q .
|
|
9
|
+
git fetch -q --depth 1 https://github.com/selectiveci/selective-ruby-minitest.git ${{ init.commit-sha }}
|
|
10
|
+
git checkout -q FETCH_HEAD
|
|
11
|
+
|
|
12
|
+
- key: bundle-install
|
|
13
|
+
use: code
|
|
14
|
+
run: |
|
|
15
|
+
ruby -v
|
|
16
|
+
bundle install
|
|
17
|
+
grep "^ minitest " Gemfile.lock
|
|
18
|
+
env:
|
|
19
|
+
MINITEST_VERSION: ${{ init.minitest-version }}
|
|
20
|
+
|
|
21
|
+
- key: rspec
|
|
22
|
+
use: bundle-install
|
|
23
|
+
run: bundle exec rspec
|
|
24
|
+
env:
|
|
25
|
+
MINITEST_VERSION: ${{ init.minitest-version }}
|
data/LICENSE
CHANGED
|
File without changes
|
data/Rakefile
CHANGED
|
File without changes
|
|
@@ -10,7 +10,9 @@ module Selective
|
|
|
10
10
|
|
|
11
11
|
# This is the first half of Minitest.run
|
|
12
12
|
def selective_prerun(args = [])
|
|
13
|
-
|
|
13
|
+
if ::Minitest::VERSION.to_i < 6
|
|
14
|
+
load_plugins unless args.delete("--no-plugins") || ENV["MT_NO_PLUGINS"]
|
|
15
|
+
end
|
|
14
16
|
|
|
15
17
|
options = process_args args
|
|
16
18
|
|
|
@@ -34,14 +36,14 @@ module Selective
|
|
|
34
36
|
def selective_postrun(reporter, args = [])
|
|
35
37
|
options = process_args args
|
|
36
38
|
|
|
37
|
-
parallel_executor.shutdown
|
|
39
|
+
parallel_executor.shutdown if parallel_executor.respond_to?(:shutdown)
|
|
38
40
|
|
|
39
41
|
# might have been removed/replaced during init_plugins:
|
|
40
42
|
summary = reporter.reporters.grep(::Minitest::SummaryReporter).first
|
|
41
43
|
|
|
42
44
|
reporter.report
|
|
43
45
|
|
|
44
|
-
return empty_run! options if summary && summary.count == 0
|
|
46
|
+
return empty_run! options if summary && summary.count == 0 && respond_to?(:empty_run!)
|
|
45
47
|
reporter.passed?
|
|
46
48
|
end
|
|
47
49
|
end
|
|
@@ -42,7 +42,10 @@ module Selective
|
|
|
42
42
|
def run_test_cases(test_case_ids)
|
|
43
43
|
test_case_ids.map do |test_id|
|
|
44
44
|
klass, method_name = get_test_from_map(test_id)
|
|
45
|
-
|
|
45
|
+
discard_previous_results(klass, method_name)
|
|
46
|
+
real_time = time do
|
|
47
|
+
with_test_map(test_id) { run_test(klass, method_name) }
|
|
48
|
+
end
|
|
46
49
|
foo = format_test_case(test_id, klass, method_name, real_time)
|
|
47
50
|
test_case_callback.call(foo)
|
|
48
51
|
end
|
|
@@ -52,10 +55,7 @@ module Selective
|
|
|
52
55
|
test = test_map[test_case_id]
|
|
53
56
|
return unless test
|
|
54
57
|
|
|
55
|
-
result = summary_reporter.results.detect
|
|
56
|
-
r.source_location.first.gsub(root_path, "") == test[:file_path] &&
|
|
57
|
-
r.name == test[:method_name]
|
|
58
|
-
end
|
|
58
|
+
result = summary_reporter.results.detect { |r| same_test?(r, test[:klass], test[:method_name]) }
|
|
59
59
|
|
|
60
60
|
return unless result
|
|
61
61
|
|
|
@@ -92,10 +92,99 @@ module Selective
|
|
|
92
92
|
|
|
93
93
|
private
|
|
94
94
|
|
|
95
|
+
def run_test(klass, method_name)
|
|
96
|
+
if klass.respond_to?(:run_one_method)
|
|
97
|
+
klass.run_one_method(klass, method_name, reporter)
|
|
98
|
+
else
|
|
99
|
+
klass.run(klass, method_name, reporter)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
95
103
|
def time(&block)
|
|
96
104
|
Benchmark.measure(&block).real
|
|
97
105
|
end
|
|
98
106
|
|
|
107
|
+
# Records the files a test executes (setup and teardown included) when
|
|
108
|
+
# the server has asked for a test map; a plain pass-through otherwise
|
|
109
|
+
# and on older cores that predate test maps.
|
|
110
|
+
def with_test_map(test_id, &block)
|
|
111
|
+
if ::Selective::Ruby::Core.const_defined?(:TestMap)
|
|
112
|
+
::Selective::Ruby::Core::TestMap.around(test_id, &block)
|
|
113
|
+
else
|
|
114
|
+
yield
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Auto-retry (and a manual rerun) can hand a test case back to the very
|
|
119
|
+
# process that already ran it. Every reporter recorded that first attempt,
|
|
120
|
+
# so running it again without forgetting the first makes reporters that
|
|
121
|
+
# keep per-test records -- minitest-reporters' JUnitReporter, for example --
|
|
122
|
+
# emit the test twice with identical identity. Tools that key on test
|
|
123
|
+
# identity (Captain, for one) then hold a duplicate they can never
|
|
124
|
+
# reconcile: their own retries update one copy while the other stays
|
|
125
|
+
# failed, and the task can never go green. Drop the stale records first so
|
|
126
|
+
# only the latest attempt is reported, and keep the statistics counters
|
|
127
|
+
# honest about how many distinct tests ran.
|
|
128
|
+
def discard_previous_results(klass, method_name)
|
|
129
|
+
key = [klass.name, method_name]
|
|
130
|
+
previously_run = previous_runs.key?(key)
|
|
131
|
+
previous_runs[key] = true
|
|
132
|
+
|
|
133
|
+
all_reporters.each do |r|
|
|
134
|
+
stale = []
|
|
135
|
+
|
|
136
|
+
if r.respond_to?(:tests) && r.tests.is_a?(Array)
|
|
137
|
+
stale.concat(r.tests.select { |result| same_test?(result, klass, method_name) })
|
|
138
|
+
r.tests.reject! { |result| same_test?(result, klass, method_name) }
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
if r.respond_to?(:results) && r.results.is_a?(Array)
|
|
142
|
+
stale.concat(r.results.select { |result| same_test?(result, klass, method_name) })
|
|
143
|
+
r.results.reject! { |result| same_test?(result, klass, method_name) }
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
forget_statistics(r, stale.uniq, previously_run)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def previous_runs
|
|
151
|
+
@previous_runs ||= {}
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# Every reporter in the composite, including the ones minitest-reporters
|
|
155
|
+
# hides behind its DelegateReporter (which can itself be nested).
|
|
156
|
+
def all_reporters(reporters = reporter.reporters, seen = {})
|
|
157
|
+
reporters.flat_map do |r|
|
|
158
|
+
next [] if seen[r.object_id]
|
|
159
|
+
|
|
160
|
+
seen[r.object_id] = true
|
|
161
|
+
nested = []
|
|
162
|
+
nested.concat(Array(r.send(:all_reporters))) if r.respond_to?(:all_reporters, true)
|
|
163
|
+
nested.concat(Array(r.reporters)) if r.respond_to?(:reporters)
|
|
164
|
+
[r, *all_reporters(nested, seen)]
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def same_test?(result, klass, method_name)
|
|
169
|
+
result.respond_to?(:klass) && result.respond_to?(:name) &&
|
|
170
|
+
result.klass.to_s == klass.name && result.name == method_name
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# Minitest::StatisticsReporter counts every recorded run, whether or not it
|
|
174
|
+
# kept the result object (it only keeps failures and skips). A previously
|
|
175
|
+
# passing test leaves nothing to find in `tests`/`results`, so the rerun
|
|
176
|
+
# itself is the signal that one count has to come off.
|
|
177
|
+
def forget_statistics(r, stale, previously_run)
|
|
178
|
+
if previously_run && r.respond_to?(:count) && r.respond_to?(:count=) && r.count.to_i.positive?
|
|
179
|
+
r.count -= 1
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
assertions = stale.sum { |result| result.respond_to?(:assertions) ? result.assertions.to_i : 0 }
|
|
183
|
+
if assertions.positive? && r.respond_to?(:assertions) && r.respond_to?(:assertions=)
|
|
184
|
+
r.assertions = [r.assertions.to_i - assertions, 0].max
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
99
188
|
def get_test_from_map(test_id)
|
|
100
189
|
t = test_map[test_id]
|
|
101
190
|
|
|
File without changes
|
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: selective-ruby-minitest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Benjamin Wood
|
|
8
8
|
- Nate Vick
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: exe
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: zeitwerk
|
|
@@ -39,6 +38,20 @@ dependencies:
|
|
|
39
38
|
- - ">="
|
|
40
39
|
- !ruby/object:Gem::Version
|
|
41
40
|
version: 0.2.5
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: benchmark
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
42
55
|
- !ruby/object:Gem::Dependency
|
|
43
56
|
name: rake
|
|
44
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -53,6 +66,26 @@ dependencies:
|
|
|
53
66
|
- - ">="
|
|
54
67
|
- !ruby/object:Gem::Version
|
|
55
68
|
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: minitest
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '5.16'
|
|
76
|
+
- - "<"
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
version: '7'
|
|
79
|
+
type: :runtime
|
|
80
|
+
prerelease: false
|
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
82
|
+
requirements:
|
|
83
|
+
- - ">="
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '5.16'
|
|
86
|
+
- - "<"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '7'
|
|
56
89
|
description: Selective is an intelligent test runner for your current CI provider.
|
|
57
90
|
Get real-time test results, intelligent ordering based on code changes, shorter
|
|
58
91
|
run times, automatic flake detection, the ability to re-enqueue failed tests, and
|
|
@@ -64,6 +97,9 @@ executables: []
|
|
|
64
97
|
extensions: []
|
|
65
98
|
extra_rdoc_files: []
|
|
66
99
|
files:
|
|
100
|
+
- ".rspec"
|
|
101
|
+
- ".rwx/ci.yml"
|
|
102
|
+
- ".rwx/test.yml"
|
|
67
103
|
- LICENSE
|
|
68
104
|
- Rakefile
|
|
69
105
|
- lib/selective-ruby-minitest.rb
|
|
@@ -77,7 +113,6 @@ metadata:
|
|
|
77
113
|
homepage_uri: https://www.selective.ci
|
|
78
114
|
source_code_uri: http://github.com/selectiveci/selective-ruby-minitest
|
|
79
115
|
changelog_uri: https://github.com/selectiveci/selective-ruby-minitest/blob/main/CHANGELOG.md
|
|
80
|
-
post_install_message:
|
|
81
116
|
rdoc_options: []
|
|
82
117
|
require_paths:
|
|
83
118
|
- lib
|
|
@@ -85,15 +120,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
85
120
|
requirements:
|
|
86
121
|
- - ">="
|
|
87
122
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: 2.
|
|
123
|
+
version: 2.7.0
|
|
89
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
125
|
requirements:
|
|
91
126
|
- - ">="
|
|
92
127
|
- !ruby/object:Gem::Version
|
|
93
128
|
version: '0'
|
|
94
129
|
requirements: []
|
|
95
|
-
rubygems_version:
|
|
96
|
-
signing_key:
|
|
130
|
+
rubygems_version: 4.0.20
|
|
97
131
|
specification_version: 4
|
|
98
132
|
summary: Selective Ruby Minitest Client
|
|
99
133
|
test_files: []
|