minitest 5.27.0 → 6.0.3
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 +108 -0
- data/Manifest.txt +13 -4
- data/README.rdoc +8 -90
- data/Rakefile +7 -15
- data/bin/minitest +5 -0
- data/lib/minitest/assertions.rb +26 -55
- data/lib/minitest/autorun.rb +0 -1
- data/lib/minitest/benchmark.rb +1 -1
- data/lib/minitest/bisect.rb +304 -0
- data/lib/minitest/complete.rb +56 -0
- data/lib/minitest/find_minimal_combination.rb +127 -0
- data/lib/minitest/manual_plugins.rb +4 -16
- data/lib/minitest/parallel.rb +3 -3
- data/lib/minitest/path_expander.rb +432 -0
- data/lib/minitest/pride.rb +1 -1
- data/lib/minitest/server.rb +49 -0
- data/lib/minitest/server_plugin.rb +88 -0
- data/lib/minitest/spec.rb +2 -31
- data/lib/minitest/sprint.rb +105 -0
- data/lib/minitest/sprint_plugin.rb +39 -0
- data/lib/minitest/test.rb +5 -11
- data/lib/minitest/test_task.rb +16 -9
- data/lib/minitest.rb +69 -87
- data/test/minitest/metametameta.rb +1 -1
- data/test/minitest/test_bisect.rb +249 -0
- data/test/minitest/test_find_minimal_combination.rb +138 -0
- data/test/minitest/test_minitest_assertions.rb +36 -44
- data/test/minitest/test_minitest_benchmark.rb +14 -0
- data/test/minitest/test_minitest_spec.rb +38 -102
- data/test/minitest/test_minitest_test.rb +20 -99
- data/test/minitest/test_path_expander.rb +229 -0
- data/test/minitest/test_server.rb +146 -0
- data.tar.gz.sig +0 -0
- metadata +87 -41
- metadata.gz.sig +2 -3
- 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,105 @@
|
|
|
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
|
+
module Minitest
|
|
8
|
+
|
|
9
|
+
##
|
|
10
|
+
# Runs (Get it? It's fast!) your tests and makes it easier to rerun
|
|
11
|
+
# individual failures.
|
|
12
|
+
|
|
13
|
+
class Sprint
|
|
14
|
+
# extracted version = "1.5.0"
|
|
15
|
+
|
|
16
|
+
##
|
|
17
|
+
# Process and run minitest cmdline.
|
|
18
|
+
|
|
19
|
+
def self.run args = ARGV
|
|
20
|
+
if args.delete("--bisect") or args.delete("-b") then
|
|
21
|
+
require_relative "bisect"
|
|
22
|
+
|
|
23
|
+
return Minitest::Bisect.run ARGV
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
Minitest::PathExpander.new(args).process { |f|
|
|
27
|
+
require "./#{f}" if File.file? f
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
##
|
|
32
|
+
# An extra minitest reporter to output how to rerun failures in
|
|
33
|
+
# various styles.
|
|
34
|
+
|
|
35
|
+
class SprintReporter < AbstractReporter
|
|
36
|
+
##
|
|
37
|
+
# The style to report, either lines or regexp. Defaults to lines.
|
|
38
|
+
attr_accessor :style
|
|
39
|
+
attr_accessor :results # :nodoc:
|
|
40
|
+
|
|
41
|
+
def initialize style = :regexp # :nodoc:
|
|
42
|
+
self.results = []
|
|
43
|
+
self.style = style
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def record result # :nodoc:
|
|
47
|
+
results << result unless result.passed? or result.skipped?
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def report # :nodoc:
|
|
51
|
+
return if results.empty?
|
|
52
|
+
|
|
53
|
+
puts
|
|
54
|
+
puts "Happy Happy Sprint List:"
|
|
55
|
+
puts
|
|
56
|
+
print_list
|
|
57
|
+
puts
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def print_list # :nodoc:
|
|
61
|
+
case style
|
|
62
|
+
when :regexp
|
|
63
|
+
results.each do |result|
|
|
64
|
+
puts " minitest -n #{result.class_name}##{result.name}"
|
|
65
|
+
end
|
|
66
|
+
when :lines
|
|
67
|
+
files = Hash.new { |h,k| h[k] = [] }
|
|
68
|
+
results.each do |result|
|
|
69
|
+
path, line = result.source_location
|
|
70
|
+
path = path.delete_prefix "#{Dir.pwd}/"
|
|
71
|
+
files[path] << line
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
files.sort.each do |path, lines|
|
|
75
|
+
puts " minitest %s:%s" % [path, lines.sort.join(",")]
|
|
76
|
+
end
|
|
77
|
+
else
|
|
78
|
+
raise "unsupported style: %p" % [style]
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
##
|
|
84
|
+
# An extra minitest reporter to output how to rerun failures using
|
|
85
|
+
# rake.
|
|
86
|
+
|
|
87
|
+
class RakeReporter < SprintReporter
|
|
88
|
+
##
|
|
89
|
+
# The name of the rake task to rerun. Defaults to nil.
|
|
90
|
+
|
|
91
|
+
attr_accessor :name
|
|
92
|
+
|
|
93
|
+
def initialize name = nil # :nodoc:
|
|
94
|
+
super()
|
|
95
|
+
self.name = name
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def print_list # :nodoc:
|
|
99
|
+
results.each do |result|
|
|
100
|
+
puts [" rake", name, "N=#{result.class_name}##{result.name}"].compact.join(" ")
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
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
|
@@ -12,10 +12,6 @@ module Minitest
|
|
|
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_relative "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
|
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.3" # :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
|
|
|
@@ -97,6 +96,17 @@ module Minitest
|
|
|
97
96
|
@@after_run << block
|
|
98
97
|
end
|
|
99
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
|
+
|
|
100
110
|
##
|
|
101
111
|
# Register a plugin to be used. Does NOT require / load it.
|
|
102
112
|
|
|
@@ -145,22 +155,27 @@ module Minitest
|
|
|
145
155
|
}
|
|
146
156
|
orig_args = args.dup
|
|
147
157
|
|
|
158
|
+
warn "--no-plugins is a no-op" if args.delete "--no-plugins" # TODO: remove me! when?
|
|
159
|
+
|
|
148
160
|
OptionParser.new do |opts|
|
|
149
161
|
opts.program_name = "minitest"
|
|
150
162
|
opts.version = Minitest::VERSION
|
|
151
163
|
|
|
152
164
|
opts.banner = [
|
|
153
|
-
"Usage:
|
|
154
|
-
"
|
|
155
|
-
"
|
|
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",
|
|
156
168
|
].join "\n or: "
|
|
157
169
|
|
|
158
170
|
opts.on "-h", "--help", "Display this help." do
|
|
159
171
|
puts opts
|
|
160
|
-
exit
|
|
172
|
+
exit! true
|
|
161
173
|
end
|
|
162
174
|
|
|
163
|
-
opts.on "
|
|
175
|
+
opts.on "-V", "--version", "Display the version." do
|
|
176
|
+
puts "#{opts.program_name} #{Minitest::VERSION}"
|
|
177
|
+
exit! true
|
|
178
|
+
end
|
|
164
179
|
|
|
165
180
|
desc = "Sets random seed. Also via env, eg: SEED=42"
|
|
166
181
|
opts.on "-s", "--seed SEED", Integer, desc do |m|
|
|
@@ -179,8 +194,11 @@ module Minitest
|
|
|
179
194
|
options[:show_skips] = true
|
|
180
195
|
end
|
|
181
196
|
|
|
182
|
-
opts.on "-
|
|
183
|
-
|
|
197
|
+
opts.on "-b", "--bisect", "Run minitest in bisect-mode to isolate flaky tests." if
|
|
198
|
+
File.basename($0).match?(/minitest/)
|
|
199
|
+
|
|
200
|
+
opts.on "-i", "--include PATTERN", "Include /regexp/ or string for run." do |a|
|
|
201
|
+
options[:include] = a
|
|
184
202
|
end
|
|
185
203
|
|
|
186
204
|
opts.on "-e", "--exclude PATTERN", "Exclude /regexp/ or string from run." do |a|
|
|
@@ -192,9 +210,9 @@ module Minitest
|
|
|
192
210
|
def opts.alias(from, to) = (dict = topdict(from) ; dict[to] = dict[from])
|
|
193
211
|
|
|
194
212
|
# these will work but won't show up in --help output:
|
|
195
|
-
opts.alias "
|
|
196
|
-
opts.alias "
|
|
197
|
-
opts.alias "e",
|
|
213
|
+
opts.alias "include", "name"
|
|
214
|
+
opts.alias "i", "n"
|
|
215
|
+
opts.alias "e", "x"
|
|
198
216
|
|
|
199
217
|
opts.on "-S", "--skip CODES", String, "Skip reporting of certain types of results (eg E)." do |s|
|
|
200
218
|
options[:skip] = s.chars.to_a
|
|
@@ -265,23 +283,20 @@ module Minitest
|
|
|
265
283
|
#
|
|
266
284
|
# The overall structure of a run looks like this:
|
|
267
285
|
#
|
|
286
|
+
# [Minitest.load_plugins] optional, called by user, or require what you want
|
|
268
287
|
# Minitest.autorun
|
|
269
288
|
# Minitest.run(args)
|
|
270
|
-
# Minitest.load_plugins
|
|
271
289
|
# Minitest.process_args
|
|
272
290
|
# Minitest.init_plugins
|
|
273
|
-
# Minitest.
|
|
291
|
+
# Minitest.run_all_suites(reporter, options)
|
|
274
292
|
# Runnable.runnables.each |runnable_klass|
|
|
275
|
-
# runnable_klass.
|
|
276
|
-
# filtered_methods =
|
|
293
|
+
# runnable_klass.run_suite(reporter, options)
|
|
294
|
+
# filtered_methods = runnable_klass.filter_runnable_methods options
|
|
277
295
|
# filtered_methods.each |runnable_method|
|
|
278
|
-
# runnable_klass.
|
|
279
|
-
#
|
|
280
|
-
# runnable_klass.new(runnable_method).run
|
|
296
|
+
# runnable_klass.run(self, runnable_method, reporter)
|
|
297
|
+
# runnable_klass.new(runnable_method).run
|
|
281
298
|
|
|
282
299
|
def self.run args = []
|
|
283
|
-
self.load_plugins unless args.delete("--no-plugins") || ENV["MT_NO_PLUGINS"]
|
|
284
|
-
|
|
285
300
|
options = process_args args
|
|
286
301
|
|
|
287
302
|
Minitest.seed = options[:seed]
|
|
@@ -298,7 +313,7 @@ module Minitest
|
|
|
298
313
|
self.parallel_executor.start if parallel_executor.respond_to? :start
|
|
299
314
|
reporter.start
|
|
300
315
|
begin
|
|
301
|
-
|
|
316
|
+
run_all_suites reporter, options
|
|
302
317
|
finished = true
|
|
303
318
|
rescue Interrupt
|
|
304
319
|
warn "Interrupted. Exiting..."
|
|
@@ -315,7 +330,7 @@ module Minitest
|
|
|
315
330
|
end
|
|
316
331
|
|
|
317
332
|
def self.empty_run! options # :nodoc:
|
|
318
|
-
filter = options[:
|
|
333
|
+
filter = options[:include]
|
|
319
334
|
return true unless filter # no filter, but nothing ran == success
|
|
320
335
|
|
|
321
336
|
warn "Nothing ran for filter: %s" % [filter]
|
|
@@ -334,17 +349,17 @@ module Minitest
|
|
|
334
349
|
# Internal run method. Responsible for telling all Runnable
|
|
335
350
|
# sub-classes to run.
|
|
336
351
|
|
|
337
|
-
def self.
|
|
352
|
+
def self.run_all_suites reporter, options
|
|
338
353
|
suites = Runnable.runnables.shuffle
|
|
339
|
-
parallel, serial = suites.partition { |s| s.
|
|
354
|
+
parallel, serial = suites.partition { |s| s.run_order == :parallel }
|
|
340
355
|
|
|
341
356
|
# If we run the parallel tests before the serial tests, the parallel tests
|
|
342
357
|
# could run in parallel with the serial tests. This would be bad because
|
|
343
358
|
# the serial tests won't lock around Reporter#record. Run the serial tests
|
|
344
359
|
# first, so that after they complete, the parallel tests will lock when
|
|
345
360
|
# recording results.
|
|
346
|
-
serial.map { |suite| suite.
|
|
347
|
-
parallel.map { |suite| suite.
|
|
361
|
+
serial.map { |suite| suite.run_suite reporter, options } +
|
|
362
|
+
parallel.map { |suite| suite.run_suite reporter, options }
|
|
348
363
|
end
|
|
349
364
|
|
|
350
365
|
def self.filter_backtrace bt # :nodoc:
|
|
@@ -412,21 +427,30 @@ module Minitest
|
|
|
412
427
|
reset
|
|
413
428
|
|
|
414
429
|
##
|
|
415
|
-
#
|
|
416
|
-
#
|
|
417
|
-
#
|
|
430
|
+
# Returns an array of filtered +runnable_methods+. Uses
|
|
431
|
+
# options[:include] (--include arguments) and options[:exclude]
|
|
432
|
+
# (--exclude arguments) values to filter.
|
|
418
433
|
|
|
419
|
-
def self.
|
|
420
|
-
pos = options[:
|
|
434
|
+
def self.filter_runnable_methods options={}
|
|
435
|
+
pos = options[:include]
|
|
421
436
|
neg = options[:exclude]
|
|
422
437
|
|
|
423
438
|
pos = Regexp.new $1 if pos.kind_of?(String) && pos =~ %r%/(.*)/%
|
|
424
439
|
neg = Regexp.new $1 if neg.kind_of?(String) && neg =~ %r%/(.*)/%
|
|
425
440
|
|
|
426
441
|
# at most 1-2% slower than a 1-pass version, stop optimizing this
|
|
427
|
-
|
|
442
|
+
self.runnable_methods
|
|
428
443
|
.select { |m| !pos || pos === m || pos === "#{self}##{m}" }
|
|
429
444
|
.reject { |m| neg && (neg === m || neg === "#{self}##{m}") }
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
##
|
|
448
|
+
# Responsible for running all runnable methods in a given class,
|
|
449
|
+
# each in its own instance. Each instance is passed to the
|
|
450
|
+
# reporter to record.
|
|
451
|
+
|
|
452
|
+
def Runnable.run_suite reporter, options = {}
|
|
453
|
+
filtered_methods = filter_runnable_methods options
|
|
430
454
|
|
|
431
455
|
return if filtered_methods.empty?
|
|
432
456
|
|
|
@@ -441,12 +465,12 @@ module Minitest
|
|
|
441
465
|
warn "Current: %s#%s %.2fs" % [self, name, Minitest.clock_time - t0]
|
|
442
466
|
end
|
|
443
467
|
|
|
444
|
-
with_info_handler
|
|
468
|
+
with_info_handler do
|
|
445
469
|
filtered_methods.each do |method_name|
|
|
446
470
|
name = method_name
|
|
447
471
|
t0 = Minitest.clock_time
|
|
448
472
|
|
|
449
|
-
|
|
473
|
+
run self, method_name, reporter
|
|
450
474
|
end
|
|
451
475
|
end
|
|
452
476
|
end
|
|
@@ -457,20 +481,20 @@ module Minitest
|
|
|
457
481
|
# that subclasses can specialize the running of an individual
|
|
458
482
|
# test. See Minitest::ParallelTest::ClassMethods for an example.
|
|
459
483
|
|
|
460
|
-
def
|
|
484
|
+
def Runnable.run klass, method_name, reporter
|
|
461
485
|
reporter.prerecord klass, method_name
|
|
462
|
-
reporter.record
|
|
486
|
+
reporter.record klass.new(method_name).run
|
|
463
487
|
end
|
|
464
488
|
|
|
465
489
|
##
|
|
466
490
|
# Defines the order to run tests (:random by default). Override
|
|
467
491
|
# this or use a convenience method to change it for your tests.
|
|
468
492
|
|
|
469
|
-
def self.
|
|
493
|
+
def self.run_order
|
|
470
494
|
:random
|
|
471
495
|
end
|
|
472
496
|
|
|
473
|
-
def self.with_info_handler
|
|
497
|
+
def self.with_info_handler _reporter=nil, &block # :nodoc:
|
|
474
498
|
on_signal ::Minitest.info_signal, @_info_handler, &block
|
|
475
499
|
end
|
|
476
500
|
|
|
@@ -504,22 +528,6 @@ module Minitest
|
|
|
504
528
|
@@runnables
|
|
505
529
|
end
|
|
506
530
|
|
|
507
|
-
@@marshal_dump_warned = false
|
|
508
|
-
|
|
509
|
-
def marshal_dump # :nodoc:
|
|
510
|
-
unless @@marshal_dump_warned then
|
|
511
|
-
warn ["Minitest::Runnable#marshal_dump is deprecated.",
|
|
512
|
-
"You might be violating internals. From", caller(1..1).first].join " "
|
|
513
|
-
@@marshal_dump_warned = true
|
|
514
|
-
end
|
|
515
|
-
|
|
516
|
-
[self.name, self.failures, self.assertions, self.time]
|
|
517
|
-
end
|
|
518
|
-
|
|
519
|
-
def marshal_load ary # :nodoc:
|
|
520
|
-
self.name, self.failures, self.assertions, self.time = ary
|
|
521
|
-
end
|
|
522
|
-
|
|
523
531
|
def failure # :nodoc:
|
|
524
532
|
self.failures.first
|
|
525
533
|
end
|
|
@@ -651,9 +659,6 @@ module Minitest
|
|
|
651
659
|
class Result < Runnable
|
|
652
660
|
include Minitest::Reportable
|
|
653
661
|
|
|
654
|
-
undef_method :marshal_dump
|
|
655
|
-
undef_method :marshal_load
|
|
656
|
-
|
|
657
662
|
##
|
|
658
663
|
# The class name of the test result.
|
|
659
664
|
|
|
@@ -1013,8 +1018,7 @@ module Minitest
|
|
|
1013
1018
|
|
|
1014
1019
|
def prerecord klass, name # :nodoc:
|
|
1015
1020
|
self.reporters.each do |reporter|
|
|
1016
|
-
|
|
1017
|
-
reporter.prerecord klass, name if reporter.respond_to? :prerecord
|
|
1021
|
+
reporter.prerecord klass, name
|
|
1018
1022
|
end
|
|
1019
1023
|
end
|
|
1020
1024
|
|
|
@@ -1140,16 +1144,6 @@ module Minitest
|
|
|
1140
1144
|
"java" == platform
|
|
1141
1145
|
end
|
|
1142
1146
|
|
|
1143
|
-
##
|
|
1144
|
-
# Is this running on maglev?
|
|
1145
|
-
|
|
1146
|
-
def maglev? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
|
|
1147
|
-
where = Minitest.filter_backtrace(caller).first
|
|
1148
|
-
where = where.split(":in ", 2).first # clean up noise
|
|
1149
|
-
warn "DEPRECATED: `maglev?` called from #{where}. This will fail in Minitest 6."
|
|
1150
|
-
"maglev" == platform
|
|
1151
|
-
end
|
|
1152
|
-
|
|
1153
1147
|
##
|
|
1154
1148
|
# Is this running on mri?
|
|
1155
1149
|
|
|
@@ -1164,16 +1158,6 @@ module Minitest
|
|
|
1164
1158
|
platform.include? "darwin"
|
|
1165
1159
|
end
|
|
1166
1160
|
|
|
1167
|
-
##
|
|
1168
|
-
# Is this running on rubinius?
|
|
1169
|
-
|
|
1170
|
-
def rubinius? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
|
|
1171
|
-
where = Minitest.filter_backtrace(caller).first
|
|
1172
|
-
where = where.split(":in ", 2).first # clean up noise
|
|
1173
|
-
warn "DEPRECATED: `rubinius?` called from #{where}. This will fail in Minitest 6."
|
|
1174
|
-
"rbx" == platform
|
|
1175
|
-
end
|
|
1176
|
-
|
|
1177
1161
|
##
|
|
1178
1162
|
# Is this running on windows?
|
|
1179
1163
|
|
|
@@ -1219,12 +1203,6 @@ module Minitest
|
|
|
1219
1203
|
|
|
1220
1204
|
self.backtrace_filter = BacktraceFilter.new
|
|
1221
1205
|
|
|
1222
|
-
def self.run_one_method klass, method_name # :nodoc:
|
|
1223
|
-
result = klass.new(method_name).run
|
|
1224
|
-
raise "#{klass}#run _must_ return a Result" unless Result === result
|
|
1225
|
-
result
|
|
1226
|
-
end
|
|
1227
|
-
|
|
1228
1206
|
# :stopdoc:
|
|
1229
1207
|
|
|
1230
1208
|
if defined? Process::CLOCK_MONOTONIC # :nodoc:
|
|
@@ -1248,3 +1226,7 @@ module Minitest
|
|
|
1248
1226
|
end
|
|
1249
1227
|
|
|
1250
1228
|
require_relative "minitest/test"
|
|
1229
|
+
if ENV["MINITEST_SERVER"] then
|
|
1230
|
+
require_relative "minitest/server_plugin"
|
|
1231
|
+
Minitest.register_plugin :server
|
|
1232
|
+
end
|