minitest 5.26.2 → 6.0.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +90 -0
- data/Manifest.txt +13 -4
- data/README.rdoc +8 -90
- data/Rakefile +7 -1
- data/bin/minitest +5 -0
- data/lib/minitest/assertions.rb +32 -64
- data/lib/minitest/autorun.rb +3 -4
- data/lib/minitest/benchmark.rb +3 -3
- data/lib/minitest/bisect.rb +306 -0
- data/lib/minitest/complete.rb +56 -0
- data/lib/minitest/find_minimal_combination.rb +127 -0
- data/lib/minitest/hell.rb +1 -1
- data/lib/minitest/manual_plugins.rb +4 -16
- data/lib/minitest/parallel.rb +3 -3
- data/lib/minitest/path_expander.rb +425 -0
- data/lib/minitest/pride.rb +2 -2
- data/lib/minitest/pride_plugin.rb +1 -1
- data/lib/minitest/server.rb +45 -0
- data/lib/minitest/server_plugin.rb +84 -0
- data/lib/minitest/spec.rb +4 -33
- data/lib/minitest/sprint.rb +104 -0
- data/lib/minitest/sprint_plugin.rb +39 -0
- data/lib/minitest/test.rb +7 -13
- data/lib/minitest/test_task.rb +18 -16
- data/lib/minitest.rb +70 -94
- data/test/minitest/metametameta.rb +1 -1
- data/test/minitest/test_bisect.rb +235 -0
- data/test/minitest/test_find_minimal_combination.rb +138 -0
- data/test/minitest/test_minitest_assertions.rb +41 -101
- data/test/minitest/test_minitest_benchmark.rb +14 -0
- data/test/minitest/test_minitest_reporter.rb +6 -5
- data/test/minitest/test_minitest_spec.rb +41 -117
- data/test/minitest/test_minitest_test.rb +21 -100
- data/test/minitest/test_path_expander.rb +229 -0
- data/test/minitest/test_server.rb +149 -0
- data.tar.gz.sig +2 -1
- metadata +56 -20
- metadata.gz.sig +0 -0
- data/.autotest +0 -34
- data/lib/minitest/mock.rb +0 -327
- data/lib/minitest/unit.rb +0 -42
- data/test/minitest/test_minitest_mock.rb +0 -1213
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
$LOAD_PATH.unshift "test", "lib"
|
|
2
|
+
|
|
3
|
+
require "simplecov" if ENV["MT_COV"] || ARGV.delete("--simplecov")
|
|
4
|
+
require_relative "autorun"
|
|
5
|
+
require_relative "path_expander"
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Runs (Get it? It's fast!) your tests and makes it easier to rerun individual
|
|
9
|
+
# failures.
|
|
10
|
+
|
|
11
|
+
module Minitest
|
|
12
|
+
class Sprint
|
|
13
|
+
# extracted version = "1.5.0"
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
# Process and run minitest cmdline.
|
|
17
|
+
|
|
18
|
+
def self.run args = ARGV
|
|
19
|
+
if ARGV.delete("--bisect") or ARGV.delete("-b") then
|
|
20
|
+
require_relative "bisect"
|
|
21
|
+
|
|
22
|
+
return Minitest::Bisect.run ARGV
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
Minitest::PathExpander.new(args).process { |f|
|
|
26
|
+
require "./#{f}" if File.file? f
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
##
|
|
31
|
+
# An extra minitest reporter to output how to rerun failures in
|
|
32
|
+
# various styles.
|
|
33
|
+
|
|
34
|
+
class SprintReporter < AbstractReporter
|
|
35
|
+
##
|
|
36
|
+
# The style to report, either lines or regexp. Defaults to lines.
|
|
37
|
+
attr_accessor :style
|
|
38
|
+
attr_accessor :results # :nodoc:
|
|
39
|
+
|
|
40
|
+
def initialize style = :regexp # :nodoc:
|
|
41
|
+
self.results = []
|
|
42
|
+
self.style = style
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def record result # :nodoc:
|
|
46
|
+
results << result unless result.passed? or result.skipped?
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def report # :nodoc:
|
|
50
|
+
return if results.empty?
|
|
51
|
+
|
|
52
|
+
puts
|
|
53
|
+
puts "Happy Happy Sprint List:"
|
|
54
|
+
puts
|
|
55
|
+
print_list
|
|
56
|
+
puts
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def print_list # :nodoc:
|
|
60
|
+
case style
|
|
61
|
+
when :regexp
|
|
62
|
+
results.each do |result|
|
|
63
|
+
puts " minitest -n #{result.class_name}##{result.name}"
|
|
64
|
+
end
|
|
65
|
+
when :lines
|
|
66
|
+
files = Hash.new { |h,k| h[k] = [] }
|
|
67
|
+
results.each do |result|
|
|
68
|
+
path, line = result.source_location
|
|
69
|
+
path = path.delete_prefix "#{Dir.pwd}/"
|
|
70
|
+
files[path] << line
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
files.sort.each do |path, lines|
|
|
74
|
+
puts " minitest %s:%s" % [path, lines.sort.join(",")]
|
|
75
|
+
end
|
|
76
|
+
else
|
|
77
|
+
raise "unsupported style: %p" % [style]
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
##
|
|
83
|
+
# An extra minitest reporter to output how to rerun failures using
|
|
84
|
+
# rake.
|
|
85
|
+
|
|
86
|
+
class RakeReporter < SprintReporter
|
|
87
|
+
##
|
|
88
|
+
# The name of the rake task to rerun. Defaults to nil.
|
|
89
|
+
|
|
90
|
+
attr_accessor :name
|
|
91
|
+
|
|
92
|
+
def initialize name = nil # :nodoc:
|
|
93
|
+
super()
|
|
94
|
+
self.name = name
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def print_list # :nodoc:
|
|
98
|
+
results.each do |result|
|
|
99
|
+
puts [" rake", name, "N=#{result.class_name}##{result.name}"].compact.join(" ")
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require_relative "../minitest"
|
|
2
|
+
|
|
3
|
+
# :stopdoc:
|
|
4
|
+
class OptionParser # unofficial embedded gem "makeoptparseworkwell"
|
|
5
|
+
def hidden(...) = define(...).tap { |sw| def sw.summarize(*) = nil }
|
|
6
|
+
def deprecate(from, to) = hidden(from) { abort "#{from} is deprecated. Use #{to}." }
|
|
7
|
+
def topdict(name) = name.length > 1 ? top.long : top.short
|
|
8
|
+
def alias(from, to) = (dict = topdict(from) and dict[to] = dict[from])
|
|
9
|
+
end unless OptionParser.method_defined? :hidden
|
|
10
|
+
# :startdoc:
|
|
11
|
+
|
|
12
|
+
module Minitest # :nodoc:
|
|
13
|
+
def self.plugin_sprint_options opts, options # :nodoc:
|
|
14
|
+
opts.on "--rake [TASK]", "Report how to re-run failures with rake." do |task|
|
|
15
|
+
options[:sprint] = :rake
|
|
16
|
+
options[:rake_task] = task
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
opts.deprecate "--binstub", "--rerun"
|
|
20
|
+
|
|
21
|
+
sprint_styles = %w[rake lines names binstub]
|
|
22
|
+
|
|
23
|
+
opts.on "-r", "--rerun [STYLE]", sprint_styles, "Report how to re-run failures using STYLE (names, lines)." do |style|
|
|
24
|
+
options[:sprint] = (style || :lines).to_sym
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.plugin_sprint_init options
|
|
29
|
+
require_relative "sprint"
|
|
30
|
+
case options[:sprint]
|
|
31
|
+
when :rake then
|
|
32
|
+
self.reporter << Minitest::Sprint::RakeReporter.new(options[:rake_task])
|
|
33
|
+
when :binstub, :names then
|
|
34
|
+
self.reporter << Minitest::Sprint::SprintReporter.new
|
|
35
|
+
when :lines then
|
|
36
|
+
self.reporter << Minitest::Sprint::SprintReporter.new(:lines)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
data/lib/minitest/test.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "../minitest" unless defined? Minitest::Runnable
|
|
2
2
|
|
|
3
3
|
module Minitest
|
|
4
4
|
##
|
|
@@ -8,14 +8,10 @@ module Minitest
|
|
|
8
8
|
# See Minitest::Assertions
|
|
9
9
|
|
|
10
10
|
class Test < Runnable
|
|
11
|
-
|
|
11
|
+
require_relative "assertions"
|
|
12
12
|
include Minitest::Reportable
|
|
13
13
|
include Minitest::Assertions
|
|
14
14
|
|
|
15
|
-
def class_name # :nodoc:
|
|
16
|
-
self.class.name # for Minitest::Reportable
|
|
17
|
-
end
|
|
18
|
-
|
|
19
15
|
PASSTHROUGH_EXCEPTIONS = [NoMemoryError, SignalException, SystemExit] # :nodoc:
|
|
20
16
|
|
|
21
17
|
SETUP_METHODS = %w[ before_setup setup after_setup ] # :nodoc:
|
|
@@ -34,8 +30,8 @@ module Minitest
|
|
|
34
30
|
|
|
35
31
|
def self.i_suck_and_my_tests_are_order_dependent!
|
|
36
32
|
class << self
|
|
37
|
-
undef_method :
|
|
38
|
-
define_method :
|
|
33
|
+
undef_method :run_order if method_defined? :run_order
|
|
34
|
+
define_method :run_order do :alpha end
|
|
39
35
|
end
|
|
40
36
|
end
|
|
41
37
|
|
|
@@ -65,20 +61,20 @@ module Minitest
|
|
|
65
61
|
|
|
66
62
|
##
|
|
67
63
|
# Returns all instance methods starting with "test_". Based on
|
|
68
|
-
# #
|
|
64
|
+
# #run_order, the methods are either sorted, randomized
|
|
69
65
|
# (default), or run in parallel.
|
|
70
66
|
|
|
71
67
|
def self.runnable_methods
|
|
72
68
|
methods = methods_matching(/^test_/)
|
|
73
69
|
|
|
74
|
-
case self.
|
|
70
|
+
case self.run_order
|
|
75
71
|
when :random, :parallel then
|
|
76
72
|
srand Minitest.seed
|
|
77
73
|
methods.sort.shuffle
|
|
78
74
|
when :alpha, :sorted then
|
|
79
75
|
methods.sort
|
|
80
76
|
else
|
|
81
|
-
raise "
|
|
77
|
+
raise "Unknown_order: %p" % [self.run_order]
|
|
82
78
|
end
|
|
83
79
|
end
|
|
84
80
|
|
|
@@ -234,5 +230,3 @@ module Minitest
|
|
|
234
230
|
extend Guard
|
|
235
231
|
end # Test
|
|
236
232
|
end
|
|
237
|
-
|
|
238
|
-
require "minitest/unit" if ENV["MT_COMPAT"] # compatibility layer only
|
data/lib/minitest/test_task.rb
CHANGED
|
@@ -168,20 +168,18 @@ module Minitest # :nodoc:
|
|
|
168
168
|
ENV["TESTOPTS"]
|
|
169
169
|
warn "FILTER is deprecated in Minitest::TestTask. Use A instead" if
|
|
170
170
|
ENV["FILTER"]
|
|
171
|
-
warn "N is deprecated in Minitest::TestTask. Use MT_CPU instead" if
|
|
172
|
-
ENV["N"] && ENV["N"].to_i > 0
|
|
173
171
|
|
|
174
172
|
lib_extras = (ENV["MT_LIB_EXTRAS"] || "").split File::PATH_SEPARATOR
|
|
175
173
|
self.libs[0, 0] = lib_extras
|
|
176
174
|
|
|
177
|
-
extra_args << "-
|
|
178
|
-
extra_args << "-
|
|
175
|
+
extra_args << "-i" << ENV["N"] if ENV["N"]
|
|
176
|
+
extra_args << "-i" << ENV["I"] if ENV["I"]
|
|
177
|
+
extra_args << "-x" << ENV["X"] if ENV["X"]
|
|
178
|
+
extra_args << "-x" << ENV["E"] if ENV["E"]
|
|
179
179
|
extra_args.concat Shellwords.split(ENV["TESTOPTS"]) if ENV["TESTOPTS"]
|
|
180
180
|
extra_args.concat Shellwords.split(ENV["FILTER"]) if ENV["FILTER"]
|
|
181
181
|
extra_args.concat Shellwords.split(ENV["A"]) if ENV["A"]
|
|
182
182
|
|
|
183
|
-
ENV.delete "N" if ENV["N"]
|
|
184
|
-
|
|
185
183
|
# TODO? RUBY_DEBUG = ENV["RUBY_DEBUG"]
|
|
186
184
|
# TODO? ENV["RUBY_FLAGS"]
|
|
187
185
|
|
|
@@ -189,11 +187,16 @@ module Minitest # :nodoc:
|
|
|
189
187
|
end
|
|
190
188
|
|
|
191
189
|
def define # :nodoc:
|
|
192
|
-
desc "Run the test suite. Use
|
|
190
|
+
desc "Run the test suite. Use I, X, and A to add flags/args."
|
|
193
191
|
task name do
|
|
194
192
|
ruby make_test_cmd, verbose: verbose
|
|
195
193
|
end
|
|
196
194
|
|
|
195
|
+
desc "Run the test suite, filtering for 'FU' in name (focused units?)."
|
|
196
|
+
task "#{name}:fu" do
|
|
197
|
+
ruby make_test_cmd(include:"/FU/"), verbose: verbose
|
|
198
|
+
end
|
|
199
|
+
|
|
197
200
|
desc "Print out the test command. Good for profiling and other tools."
|
|
198
201
|
task "#{name}:cmd" do
|
|
199
202
|
puts "ruby #{make_test_cmd}"
|
|
@@ -212,7 +215,7 @@ module Minitest # :nodoc:
|
|
|
212
215
|
|
|
213
216
|
n.threads_do tests.sort do |path|
|
|
214
217
|
t0 = Time.now
|
|
215
|
-
output = `#{Gem.ruby} #{make_test_cmd path} 2>&1`
|
|
218
|
+
output = `#{Gem.ruby} #{make_test_cmd path:path} 2>&1`
|
|
216
219
|
t1 = Time.now - t0
|
|
217
220
|
|
|
218
221
|
times[path] = t1
|
|
@@ -278,7 +281,9 @@ module Minitest # :nodoc:
|
|
|
278
281
|
##
|
|
279
282
|
# Generate the test command-line.
|
|
280
283
|
|
|
281
|
-
def make_test_cmd
|
|
284
|
+
def make_test_cmd **option
|
|
285
|
+
globs = option[:path] || test_globs
|
|
286
|
+
|
|
282
287
|
tests = []
|
|
283
288
|
tests.concat Dir[*globs].sort.shuffle # TODO: SEED -> srand first?
|
|
284
289
|
tests.map! { |f| %(require "#{f}") }
|
|
@@ -289,6 +294,8 @@ module Minitest # :nodoc:
|
|
|
289
294
|
runner.concat tests
|
|
290
295
|
runner = runner.join "; "
|
|
291
296
|
|
|
297
|
+
extra_args << "-i" << option[:include] if option[:include]
|
|
298
|
+
|
|
292
299
|
args = []
|
|
293
300
|
args << "-I#{libs.join File::PATH_SEPARATOR}" unless libs.empty?
|
|
294
301
|
args << "-w" if warning
|
|
@@ -303,13 +310,8 @@ module Minitest # :nodoc:
|
|
|
303
310
|
end
|
|
304
311
|
|
|
305
312
|
class Work < Queue # :nodoc:
|
|
306
|
-
def initialize jobs
|
|
307
|
-
super
|
|
308
|
-
|
|
309
|
-
jobs.each do |job|
|
|
310
|
-
self << job
|
|
311
|
-
end
|
|
312
|
-
|
|
313
|
+
def initialize jobs # :nodoc:
|
|
314
|
+
super
|
|
313
315
|
close
|
|
314
316
|
end
|
|
315
317
|
end
|
data/lib/minitest.rb
CHANGED
|
@@ -10,7 +10,7 @@ require_relative "minitest/compress"
|
|
|
10
10
|
# runtime. See +Minitest.run+ for more information.
|
|
11
11
|
|
|
12
12
|
module Minitest
|
|
13
|
-
VERSION = "
|
|
13
|
+
VERSION = "6.0.1" # :nodoc:
|
|
14
14
|
|
|
15
15
|
@@installed_at_exit ||= false
|
|
16
16
|
@@after_run = []
|
|
@@ -33,8 +33,7 @@ module Minitest
|
|
|
33
33
|
|
|
34
34
|
cattr_accessor :parallel_executor
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
n_threads = (ENV["MT_CPU"] || ENV["N"] || Etc.nprocessors).to_i
|
|
36
|
+
n_threads = (ENV["MT_CPU"] || Etc.nprocessors).to_i
|
|
38
37
|
|
|
39
38
|
self.parallel_executor = Parallel::Executor.new n_threads if n_threads > 1
|
|
40
39
|
|
|
@@ -68,8 +67,7 @@ module Minitest
|
|
|
68
67
|
# Registers Minitest to run at process exit
|
|
69
68
|
|
|
70
69
|
def self.autorun
|
|
71
|
-
Warning[:deprecated] = true
|
|
72
|
-
Object.const_defined?(:Warning) && Warning.respond_to?(:[]=)
|
|
70
|
+
Warning[:deprecated] = true
|
|
73
71
|
|
|
74
72
|
at_exit {
|
|
75
73
|
next if $! and not ($!.kind_of? SystemExit and $!.success?)
|
|
@@ -98,6 +96,17 @@ module Minitest
|
|
|
98
96
|
@@after_run << block
|
|
99
97
|
end
|
|
100
98
|
|
|
99
|
+
##
|
|
100
|
+
# Manually load plugins by name.
|
|
101
|
+
|
|
102
|
+
def self.load *names
|
|
103
|
+
names.each do |name|
|
|
104
|
+
require "minitest/#{name}_plugin"
|
|
105
|
+
|
|
106
|
+
self.extensions << name.to_s
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
101
110
|
##
|
|
102
111
|
# Register a plugin to be used. Does NOT require / load it.
|
|
103
112
|
|
|
@@ -146,22 +155,27 @@ module Minitest
|
|
|
146
155
|
}
|
|
147
156
|
orig_args = args.dup
|
|
148
157
|
|
|
158
|
+
warn "--no-plugins is a no-op" if args.delete "--no-plugins" # TODO: remove me! when?
|
|
159
|
+
|
|
149
160
|
OptionParser.new do |opts|
|
|
150
161
|
opts.program_name = "minitest"
|
|
151
162
|
opts.version = Minitest::VERSION
|
|
152
163
|
|
|
153
164
|
opts.banner = [
|
|
154
|
-
"Usage:
|
|
155
|
-
"
|
|
156
|
-
"
|
|
165
|
+
"Usage: minitest [paths] [options]",
|
|
166
|
+
"ruby path/to/test.rb [options]",
|
|
167
|
+
"rake test [A=options] (see Minitest::TestTask for more options)\n\n",
|
|
157
168
|
].join "\n or: "
|
|
158
169
|
|
|
159
170
|
opts.on "-h", "--help", "Display this help." do
|
|
160
171
|
puts opts
|
|
161
|
-
exit
|
|
172
|
+
exit! true
|
|
162
173
|
end
|
|
163
174
|
|
|
164
|
-
opts.on "
|
|
175
|
+
opts.on "-V", "--version", "Display the version." do
|
|
176
|
+
puts "#{opts.program_name} #{Minitest::VERSION}"
|
|
177
|
+
exit! true
|
|
178
|
+
end
|
|
165
179
|
|
|
166
180
|
desc = "Sets random seed. Also via env, eg: SEED=42"
|
|
167
181
|
opts.on "-s", "--seed SEED", Integer, desc do |m|
|
|
@@ -180,22 +194,24 @@ module Minitest
|
|
|
180
194
|
options[:show_skips] = true
|
|
181
195
|
end
|
|
182
196
|
|
|
183
|
-
opts.on "-
|
|
184
|
-
|
|
197
|
+
opts.on "-b", "--bisect", "Run minitest in bisect-mode to isolate flaky tests."
|
|
198
|
+
|
|
199
|
+
opts.on "-i", "--include PATTERN", "Include /regexp/ or string for run." do |a|
|
|
200
|
+
options[:include] = a
|
|
185
201
|
end
|
|
186
202
|
|
|
187
203
|
opts.on "-e", "--exclude PATTERN", "Exclude /regexp/ or string from run." do |a|
|
|
188
204
|
options[:exclude] = a
|
|
189
205
|
end
|
|
190
206
|
|
|
191
|
-
#
|
|
192
|
-
def opts.
|
|
193
|
-
def opts.
|
|
207
|
+
# part of my unofficial embedded gem "makeoptparseworkwell"
|
|
208
|
+
def opts.topdict(name) = (name.length > 1 ? top.long : top.short)
|
|
209
|
+
def opts.alias(from, to) = (dict = topdict(from) ; dict[to] = dict[from])
|
|
194
210
|
|
|
195
211
|
# these will work but won't show up in --help output:
|
|
196
|
-
opts.
|
|
197
|
-
opts.
|
|
198
|
-
opts.
|
|
212
|
+
opts.alias "include", "name"
|
|
213
|
+
opts.alias "i", "n"
|
|
214
|
+
opts.alias "e", "x"
|
|
199
215
|
|
|
200
216
|
opts.on "-S", "--skip CODES", String, "Skip reporting of certain types of results (eg E)." do |s|
|
|
201
217
|
options[:skip] = s.chars.to_a
|
|
@@ -205,7 +221,7 @@ module Minitest
|
|
|
205
221
|
options[:Werror] = true
|
|
206
222
|
case s
|
|
207
223
|
when "error", "all", nil then
|
|
208
|
-
|
|
224
|
+
require_relative "minitest/error_on_warning"
|
|
209
225
|
$VERBOSE = true
|
|
210
226
|
::Warning[:deprecated] = true
|
|
211
227
|
else
|
|
@@ -266,23 +282,20 @@ module Minitest
|
|
|
266
282
|
#
|
|
267
283
|
# The overall structure of a run looks like this:
|
|
268
284
|
#
|
|
285
|
+
# [Minitest.load_plugins] optional, called by user, or require what you want
|
|
269
286
|
# Minitest.autorun
|
|
270
287
|
# Minitest.run(args)
|
|
271
|
-
# Minitest.load_plugins
|
|
272
288
|
# Minitest.process_args
|
|
273
289
|
# Minitest.init_plugins
|
|
274
|
-
# Minitest.
|
|
290
|
+
# Minitest.run_all_suites(reporter, options)
|
|
275
291
|
# Runnable.runnables.each |runnable_klass|
|
|
276
|
-
# runnable_klass.
|
|
277
|
-
# filtered_methods =
|
|
292
|
+
# runnable_klass.run_suite(reporter, options)
|
|
293
|
+
# filtered_methods = runnable_klass.filter_runnable_methods options
|
|
278
294
|
# filtered_methods.each |runnable_method|
|
|
279
|
-
# runnable_klass.
|
|
280
|
-
#
|
|
281
|
-
# runnable_klass.new(runnable_method).run
|
|
295
|
+
# runnable_klass.run(self, runnable_method, reporter)
|
|
296
|
+
# runnable_klass.new(runnable_method).run
|
|
282
297
|
|
|
283
298
|
def self.run args = []
|
|
284
|
-
self.load_plugins unless args.delete("--no-plugins") || ENV["MT_NO_PLUGINS"]
|
|
285
|
-
|
|
286
299
|
options = process_args args
|
|
287
300
|
|
|
288
301
|
Minitest.seed = options[:seed]
|
|
@@ -299,7 +312,7 @@ module Minitest
|
|
|
299
312
|
self.parallel_executor.start if parallel_executor.respond_to? :start
|
|
300
313
|
reporter.start
|
|
301
314
|
begin
|
|
302
|
-
|
|
315
|
+
run_all_suites reporter, options
|
|
303
316
|
finished = true
|
|
304
317
|
rescue Interrupt
|
|
305
318
|
warn "Interrupted. Exiting..."
|
|
@@ -316,7 +329,7 @@ module Minitest
|
|
|
316
329
|
end
|
|
317
330
|
|
|
318
331
|
def self.empty_run! options # :nodoc:
|
|
319
|
-
filter = options[:
|
|
332
|
+
filter = options[:include]
|
|
320
333
|
return true unless filter # no filter, but nothing ran == success
|
|
321
334
|
|
|
322
335
|
warn "Nothing ran for filter: %s" % [filter]
|
|
@@ -335,17 +348,17 @@ module Minitest
|
|
|
335
348
|
# Internal run method. Responsible for telling all Runnable
|
|
336
349
|
# sub-classes to run.
|
|
337
350
|
|
|
338
|
-
def self.
|
|
351
|
+
def self.run_all_suites reporter, options
|
|
339
352
|
suites = Runnable.runnables.shuffle
|
|
340
|
-
parallel, serial = suites.partition { |s| s.
|
|
353
|
+
parallel, serial = suites.partition { |s| s.run_order == :parallel }
|
|
341
354
|
|
|
342
355
|
# If we run the parallel tests before the serial tests, the parallel tests
|
|
343
356
|
# could run in parallel with the serial tests. This would be bad because
|
|
344
357
|
# the serial tests won't lock around Reporter#record. Run the serial tests
|
|
345
358
|
# first, so that after they complete, the parallel tests will lock when
|
|
346
359
|
# recording results.
|
|
347
|
-
serial.map { |suite| suite.
|
|
348
|
-
parallel.map { |suite| suite.
|
|
360
|
+
serial.map { |suite| suite.run_suite reporter, options } +
|
|
361
|
+
parallel.map { |suite| suite.run_suite reporter, options }
|
|
349
362
|
end
|
|
350
363
|
|
|
351
364
|
def self.filter_backtrace bt # :nodoc:
|
|
@@ -413,21 +426,30 @@ module Minitest
|
|
|
413
426
|
reset
|
|
414
427
|
|
|
415
428
|
##
|
|
416
|
-
#
|
|
417
|
-
#
|
|
418
|
-
#
|
|
429
|
+
# Returns an array of filtered +runnable_methods+. Uses
|
|
430
|
+
# options[:include] (--include arguments) and options[:exclude]
|
|
431
|
+
# (--exclude arguments) values to filter.
|
|
419
432
|
|
|
420
|
-
def self.
|
|
421
|
-
pos = options[:
|
|
433
|
+
def self.filter_runnable_methods options={}
|
|
434
|
+
pos = options[:include]
|
|
422
435
|
neg = options[:exclude]
|
|
423
436
|
|
|
424
437
|
pos = Regexp.new $1 if pos.kind_of?(String) && pos =~ %r%/(.*)/%
|
|
425
438
|
neg = Regexp.new $1 if neg.kind_of?(String) && neg =~ %r%/(.*)/%
|
|
426
439
|
|
|
427
440
|
# at most 1-2% slower than a 1-pass version, stop optimizing this
|
|
428
|
-
|
|
441
|
+
self.runnable_methods
|
|
429
442
|
.select { |m| !pos || pos === m || pos === "#{self}##{m}" }
|
|
430
443
|
.reject { |m| neg && (neg === m || neg === "#{self}##{m}") }
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
##
|
|
447
|
+
# Responsible for running all runnable methods in a given class,
|
|
448
|
+
# each in its own instance. Each instance is passed to the
|
|
449
|
+
# reporter to record.
|
|
450
|
+
|
|
451
|
+
def Runnable.run_suite reporter, options = {}
|
|
452
|
+
filtered_methods = filter_runnable_methods options
|
|
431
453
|
|
|
432
454
|
return if filtered_methods.empty?
|
|
433
455
|
|
|
@@ -442,12 +464,12 @@ module Minitest
|
|
|
442
464
|
warn "Current: %s#%s %.2fs" % [self, name, Minitest.clock_time - t0]
|
|
443
465
|
end
|
|
444
466
|
|
|
445
|
-
with_info_handler
|
|
467
|
+
with_info_handler do
|
|
446
468
|
filtered_methods.each do |method_name|
|
|
447
469
|
name = method_name
|
|
448
470
|
t0 = Minitest.clock_time
|
|
449
471
|
|
|
450
|
-
|
|
472
|
+
run self, method_name, reporter
|
|
451
473
|
end
|
|
452
474
|
end
|
|
453
475
|
end
|
|
@@ -458,20 +480,20 @@ module Minitest
|
|
|
458
480
|
# that subclasses can specialize the running of an individual
|
|
459
481
|
# test. See Minitest::ParallelTest::ClassMethods for an example.
|
|
460
482
|
|
|
461
|
-
def
|
|
483
|
+
def Runnable.run klass, method_name, reporter
|
|
462
484
|
reporter.prerecord klass, method_name
|
|
463
|
-
reporter.record
|
|
485
|
+
reporter.record klass.new(method_name).run
|
|
464
486
|
end
|
|
465
487
|
|
|
466
488
|
##
|
|
467
489
|
# Defines the order to run tests (:random by default). Override
|
|
468
490
|
# this or use a convenience method to change it for your tests.
|
|
469
491
|
|
|
470
|
-
def self.
|
|
492
|
+
def self.run_order
|
|
471
493
|
:random
|
|
472
494
|
end
|
|
473
495
|
|
|
474
|
-
def self.with_info_handler
|
|
496
|
+
def self.with_info_handler _reporter=nil, &block # :nodoc:
|
|
475
497
|
on_signal ::Minitest.info_signal, @_info_handler, &block
|
|
476
498
|
end
|
|
477
499
|
|
|
@@ -505,22 +527,6 @@ module Minitest
|
|
|
505
527
|
@@runnables
|
|
506
528
|
end
|
|
507
529
|
|
|
508
|
-
@@marshal_dump_warned = false
|
|
509
|
-
|
|
510
|
-
def marshal_dump # :nodoc:
|
|
511
|
-
unless @@marshal_dump_warned then
|
|
512
|
-
warn ["Minitest::Runnable#marshal_dump is deprecated.",
|
|
513
|
-
"You might be violating internals. From", caller(1..1).first].join " "
|
|
514
|
-
@@marshal_dump_warned = true
|
|
515
|
-
end
|
|
516
|
-
|
|
517
|
-
[self.name, self.failures, self.assertions, self.time]
|
|
518
|
-
end
|
|
519
|
-
|
|
520
|
-
def marshal_load ary # :nodoc:
|
|
521
|
-
self.name, self.failures, self.assertions, self.time = ary
|
|
522
|
-
end
|
|
523
|
-
|
|
524
530
|
def failure # :nodoc:
|
|
525
531
|
self.failures.first
|
|
526
532
|
end
|
|
@@ -652,9 +658,6 @@ module Minitest
|
|
|
652
658
|
class Result < Runnable
|
|
653
659
|
include Minitest::Reportable
|
|
654
660
|
|
|
655
|
-
undef_method :marshal_dump
|
|
656
|
-
undef_method :marshal_load
|
|
657
|
-
|
|
658
661
|
##
|
|
659
662
|
# The class name of the test result.
|
|
660
663
|
|
|
@@ -1014,8 +1017,7 @@ module Minitest
|
|
|
1014
1017
|
|
|
1015
1018
|
def prerecord klass, name # :nodoc:
|
|
1016
1019
|
self.reporters.each do |reporter|
|
|
1017
|
-
|
|
1018
|
-
reporter.prerecord klass, name if reporter.respond_to? :prerecord
|
|
1020
|
+
reporter.prerecord klass, name
|
|
1019
1021
|
end
|
|
1020
1022
|
end
|
|
1021
1023
|
|
|
@@ -1141,16 +1143,6 @@ module Minitest
|
|
|
1141
1143
|
"java" == platform
|
|
1142
1144
|
end
|
|
1143
1145
|
|
|
1144
|
-
##
|
|
1145
|
-
# Is this running on maglev?
|
|
1146
|
-
|
|
1147
|
-
def maglev? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
|
|
1148
|
-
where = Minitest.filter_backtrace(caller).first
|
|
1149
|
-
where = where.split(":in ", 2).first # clean up noise
|
|
1150
|
-
warn "DEPRECATED: `maglev?` called from #{where}. This will fail in Minitest 6."
|
|
1151
|
-
"maglev" == platform
|
|
1152
|
-
end
|
|
1153
|
-
|
|
1154
1146
|
##
|
|
1155
1147
|
# Is this running on mri?
|
|
1156
1148
|
|
|
@@ -1165,16 +1157,6 @@ module Minitest
|
|
|
1165
1157
|
platform.include? "darwin"
|
|
1166
1158
|
end
|
|
1167
1159
|
|
|
1168
|
-
##
|
|
1169
|
-
# Is this running on rubinius?
|
|
1170
|
-
|
|
1171
|
-
def rubinius? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
|
|
1172
|
-
where = Minitest.filter_backtrace(caller).first
|
|
1173
|
-
where = where.split(":in ", 2).first # clean up noise
|
|
1174
|
-
warn "DEPRECATED: `rubinius?` called from #{where}. This will fail in Minitest 6."
|
|
1175
|
-
"rbx" == platform
|
|
1176
|
-
end
|
|
1177
|
-
|
|
1178
1160
|
##
|
|
1179
1161
|
# Is this running on windows?
|
|
1180
1162
|
|
|
@@ -1220,12 +1202,6 @@ module Minitest
|
|
|
1220
1202
|
|
|
1221
1203
|
self.backtrace_filter = BacktraceFilter.new
|
|
1222
1204
|
|
|
1223
|
-
def self.run_one_method klass, method_name # :nodoc:
|
|
1224
|
-
result = klass.new(method_name).run
|
|
1225
|
-
raise "#{klass}#run _must_ return a Result" unless Result === result
|
|
1226
|
-
result
|
|
1227
|
-
end
|
|
1228
|
-
|
|
1229
1205
|
# :stopdoc:
|
|
1230
1206
|
|
|
1231
1207
|
if defined? Process::CLOCK_MONOTONIC # :nodoc:
|
|
@@ -1248,4 +1224,4 @@ module Minitest
|
|
|
1248
1224
|
# :startdoc:
|
|
1249
1225
|
end
|
|
1250
1226
|
|
|
1251
|
-
|
|
1227
|
+
require_relative "minitest/test"
|