[DRE-commits] [ruby-minitest] 01/04: New upstream version 5.10.2
Lucas Nussbaum
lucas at moszumanska.debian.org
Sun Jul 2 15:23:27 UTC 2017
This is an automated email from the git hooks/post-receive script.
lucas pushed a commit to branch master
in repository ruby-minitest.
commit 59cea2d81c7b283166ad814b368d8e2da50ff18f
Author: Lucas Nussbaum <lucas at debian.org>
Date: Sun Jul 2 14:38:40 2017 +0200
New upstream version 5.10.2
---
History.rdoc | 54 +++++++++
README.rdoc | 12 +-
Rakefile | 18 ++-
checksums.yaml.gz.sig | Bin 256 -> 256 bytes
data.tar.gz.sig | Bin 256 -> 256 bytes
lib/hoe/minitest.rb | 14 ++-
lib/minitest.rb | 73 ++++++++---
lib/minitest/assertions.rb | 21 +++-
lib/minitest/benchmark.rb | 2 +-
lib/minitest/hell.rb | 10 +-
lib/minitest/mock.rb | 8 +-
lib/minitest/parallel.rb | 2 +-
lib/minitest/pride_plugin.rb | 2 +-
lib/minitest/spec.rb | 2 +-
lib/minitest/test.rb | 8 +-
lib/minitest/unit.rb | 2 +-
metadata.gz.sig | Bin 256 -> 256 bytes
minitest.gemspec | 12 +-
test/minitest/metametameta.rb | 13 +-
test/minitest/test_minitest_mock.rb | 12 +-
test/minitest/test_minitest_reporter.rb | 6 +
test/minitest/test_minitest_spec.rb | 70 +++++++----
test/minitest/test_minitest_test.rb | 209 +++++++++++++++++++++++++-------
23 files changed, 419 insertions(+), 131 deletions(-)
diff --git a/History.rdoc b/History.rdoc
index 5ac7b1c..3b79251 100644
--- a/History.rdoc
+++ b/History.rdoc
@@ -1,3 +1,50 @@
+=== 5.10.2 / 2017-05-09
+
+* 1 minor enhancement:
+
+ * Added suggestion in minitest/hell to install minitest/proveit.
+
+* 7 bug fixes:
+
+ * Expand MT6 to Minitest 6. (xaviershay)
+ * Fixed location of assert_send deprecation. (rab)
+ * Fixed location of nil assert_equal deprecation to work with expectations. (jeremyevans)
+ * Fixed minitest/hell to use parallelize_me! (azul)
+ * Made deprecation use warn so -W0 will silence it.
+ * Workaround for rdoc nodoc generation bug that totally f'd up minitest doco. (Paxa)
+ * Write aggregated_results directly to the IO object to avoid mixed encoding errors. (tenderlove)
+
+=== 5.10.1 / 2016-12-01
+
+* 1 bug fix:
+
+ * Added a hack/kludge to deal with missing #prerecord on reporters that aren't properly subclassing AbstractReporter (I'm looking at you minitest-reporters)
+
+=== 5.10.0 / 2016-11-30
+
+* 1 major enhancement:
+
+ * Deprecated ruby 1.8, 1.9, possibly 2.0, assert_send, & old MiniTest namespace.
+
+* 3 minor enhancements:
+
+ * Warn if assert_equal expects a nil. This will fail in minitest 6+. (tenderlove)
+ * Added AbstractReporter#prerecord and extended ProgressReporter and CompositeReporter to use it.
+ * Minor optimization: remove runnables with no runnable methods before run.
+
+* 3 bug fixes:
+
+ * Fix assert_throw rescuing any NameError and ArgumentError. (waldyr)
+ * Clean up (most of the) last remaining vestiges of minitest/unit.
+ * 2.4: removed deprecation warnings when referring to Fixnum.
+
+=== 5.9.1 / 2016-09-25
+
+* 2 bug fixes:
+
+ * Re-release to refresh gem certificate signing. ugh.
+ * Fixed hoe/minitest to not augment load path if we're actually testing minitest.
+
=== 5.9.0 / 2016-05-16
* 8 minor enhancements:
@@ -15,6 +62,13 @@
* Removed Interrupt from PASSTHROUGH_EXCEPTIONS (already handled). (waldyr)
+=== 5.8.5 / 2016-09-25
+
+* 2 bug fixes:
+
+ * Re-release to refresh gem certificate signing. ugh.
+ * Fixed hoe/minitest to not augment load path if we're actually testing minitest.
+
=== 5.8.4 / 2016-01-21
* 1 bug fix:
diff --git a/README.rdoc b/README.rdoc
index 6fd83a0..d9cb67b 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -285,9 +285,9 @@ provided via plugins. To see them, simply run with +--help+:
% ruby -Ilib:test test/minitest/test_minitest_test.rb --help
minitest options:
-h, --help Display this help.
- -s, --seed SEED Sets random seed
+ -s, --seed SEED Sets random seed. Also via env. Eg: SEED=n rake
-v, --verbose Verbose. Show progress processing files.
- -n, --name PATTERN Filter run on /pattern/ or string.
+ -n, --name PATTERN Filter run on /regexp/ or string.
-e, --exclude PATTERN Exclude /regexp/ or string from run.
Known extensions: pride, autotest
@@ -325,7 +325,7 @@ bogus example:
Minitest uses composite reporter to output test results using multiple
reporter instances. You can add new reporters to the composite during
-the init_plugins phase. As we saw in +plugin_bonus_init+ above, you
+the init_plugins phase. As we saw in +plugin_bogus_init+ above, you
simply add your reporter instance to the composite via <tt><<</tt>.
+AbstractReporter+ defines the API for reporters. You may subclass it
@@ -466,7 +466,7 @@ minitest-around :: Around block for minitest. An alternative to
setup/teardown dance.
minitest-assert_errors :: Adds Minitest assertions to test for errors raised
or not raised by Minitest itself.
-minitest-autotest :: autotest is a continous testing facility meant to
+minitest-autotest :: autotest is a continuous testing facility meant to
be used during development.
minitest-bacon :: minitest-bacon extends minitest with bacon-like
functionality.
@@ -605,6 +605,10 @@ Authors... Please send me a pull request with a description of your minitest ext
* minitest-sugar
* spork-minitest
+== Minitest related goods
+
+* minitest/pride fabric: http://www.spoonflower.com/fabric/3928730-again-by-katie_allen
+
== REQUIREMENTS:
* Ruby 1.8.7+. No magic is involved. I hope.
diff --git a/Rakefile b/Rakefile
index 0fc5232..fbf706a 100644
--- a/Rakefile
+++ b/Rakefile
@@ -11,13 +11,27 @@ Hoe.spec "minitest" do
license "MIT"
- self.testlib = :minitest
+ ## TODO: uncomment this on the last point release on 5.x
+ #
+ # self.post_install_message = <<-"EOM"
+ # NOTE: minitest 5 will be the last in the minitest family to support
+ # ruby 1.8 and 1.9 (and maybe 2.0?). If you need to keep using 1.8
+ # or 1.9, you need to pin your dependency to minitest with
+ # something like "~> 5.0".
+ #
+ # Further, minitest 6 will be dropping the following:
+ #
+ # + MiniTest (it's been Minitest for *years*)
+ # + MiniTest::Unit
+ # + MiniTest::Unit::TestCase
+ # + assert_send (unless you argue for it well)
+ # EOM
end
desc "Find missing expectations"
task :specs do
$:.unshift "lib"
- require "minitest/unit"
+ require "minitest/test"
require "minitest/spec"
pos_prefix, neg_prefix = "must", "wont"
diff --git a/checksums.yaml.gz.sig b/checksums.yaml.gz.sig
index 4016743..2ad662e 100644
Binary files a/checksums.yaml.gz.sig and b/checksums.yaml.gz.sig differ
diff --git a/data.tar.gz.sig b/data.tar.gz.sig
index 6b88d96..d4d6fa2 100644
Binary files a/data.tar.gz.sig and b/data.tar.gz.sig differ
diff --git a/lib/hoe/minitest.rb b/lib/hoe/minitest.rb
index dc2f029..6c045a5 100644
--- a/lib/hoe/minitest.rb
+++ b/lib/hoe/minitest.rb
@@ -4,16 +4,22 @@ class Hoe
end
module Hoe::Minitest
+ def minitest?
+ self.name == "minitest"
+ end
+
def initialize_minitest
- dir = "../../minitest/dev/lib"
- Hoe.add_include_dirs dir if File.directory? dir
+ unless minitest? then
+ dir = "../../minitest/dev/lib"
+ Hoe.add_include_dirs dir if File.directory? dir
+ end
gem "minitest"
require "minitest"
version = Minitest::VERSION.split(/\./).first(2).join(".")
dependency "minitest", "~> #{version}", :development unless
- self.name == "minitest" or ENV["MT_NO_ISOLATE"]
+ minitest? or ENV["MT_NO_ISOLATE"]
end
def define_minitest_tasks
@@ -21,6 +27,6 @@ module Hoe::Minitest
# make sure we use the gemmed minitest on 1.9
self.test_prelude = 'gem "minitest"' unless
- self.name == "minitest" or ENV["MT_NO_ISOLATE"]
+ minitest? or ENV["MT_NO_ISOLATE"]
end
end
diff --git a/lib/minitest.rb b/lib/minitest.rb
index 3c8e887..5525ade 100644
--- a/lib/minitest.rb
+++ b/lib/minitest.rb
@@ -2,12 +2,13 @@ require "optparse"
require "thread"
require "mutex_m"
require "minitest/parallel"
+require "stringio"
##
# :include: README.rdoc
module Minitest
- VERSION = "5.9.0" # :nodoc:
+ VERSION = "5.10.2" # :nodoc:
ENCS = "".respond_to? :encoding # :nodoc:
@@installed_at_exit ||= false
@@ -147,7 +148,7 @@ module Minitest
# sub-classes to run.
def self.__run reporter, options
- suites = Runnable.runnables.shuffle
+ suites = Runnable.runnables.reject { |s| s.runnable_methods.empty? }.shuffle
parallel, serial = suites.partition { |s| s.test_order == :parallel }
# If we run the parallel tests before the serial tests, the parallel tests
@@ -319,6 +320,7 @@ module Minitest
# test. See Minitest::ParallelTest::ClassMethods for an example.
def self.run_one_method klass, method_name, reporter
+ reporter.prerecord klass, method_name
reporter.record Minitest.run_one_method(klass, method_name)
end
@@ -430,6 +432,13 @@ module Minitest
end
##
+ # About to start running a test. This allows a reporter to show
+ # that it is starting or that we are in the middle of a test run.
+
+ def prerecord klass, name
+ end
+
+ ##
# Record a result and output the Runnable#result_code. Stores the
# result of the run if the run did not pass.
@@ -477,9 +486,15 @@ module Minitest
# own.
class ProgressReporter < Reporter
+ def prerecord klass, name
+ if options[:verbose] then
+ io.print "%s#%s = " % [klass, name]
+ io.flush
+ end
+ end
+
def record result # :nodoc:
- io.print "%s#%s = %.2f s = " % [result.class, result.name, result.time] if
- options[:verbose]
+ io.print "%.2f s = " % [result.time] if options[:verbose]
io.print result.result_code
io.puts if options[:verbose]
end
@@ -579,7 +594,7 @@ module Minitest
io.puts unless options[:verbose] # finish the dots
io.puts
io.puts statistics
- io.puts aggregated_results
+ aggregated_results io
io.puts summary
end
@@ -588,21 +603,20 @@ module Minitest
[total_time, count / total_time, assertions / total_time]
end
- def aggregated_results # :nodoc:
+ def aggregated_results io # :nodoc:
filtered_results = results.dup
filtered_results.reject!(&:skipped?) unless options[:verbose]
- s = filtered_results.each_with_index.map { |result, i|
- "\n%3d) %s" % [i+1, result]
- }.join("\n") + "\n"
-
- s.force_encoding(io.external_encoding) if
- ENCS and io.external_encoding and s.encoding != io.external_encoding
-
- s
+ filtered_results.each_with_index { |result, i|
+ io.puts "\n%3d) %s" % [i+1, result]
+ }
+ io.puts
+ io
end
- alias to_s aggregated_results
+ def to_s
+ aggregated_results(StringIO.new(binary_string)).string
+ end
def summary # :nodoc:
extra = ""
@@ -613,6 +627,14 @@ module Minitest
"%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
[count, assertions, failures, errors, skips, extra]
end
+
+ private
+
+ if '<3'.respond_to? :b
+ def binary_string; ''.b; end
+ else
+ def binary_string; ''.force_encoding(Encoding::ASCII_8BIT); end
+ end
end
##
@@ -648,6 +670,13 @@ module Minitest
self.reporters.each(&:start)
end
+ def prerecord klass, name # :nodoc:
+ self.reporters.each do |reporter|
+ # TODO: remove conditional for minitest 6
+ reporter.prerecord klass, name if reporter.respond_to? :prerecord
+ end
+ end
+
def record result # :nodoc:
self.reporters.each do |reporter|
reporter.record result
@@ -785,9 +814,11 @@ module Minitest
return bt.dup if $DEBUG
- new_bt = bt.take_while { |line| line !~ /lib\/minitest/ }
- new_bt = bt.select { |line| line !~ /lib\/minitest/ } if new_bt.empty?
- new_bt = bt.dup if new_bt.empty?
+ mt_re = %r%lib/minitest%
+
+ new_bt = bt.take_while { |line| line !~ mt_re }
+ new_bt = bt.select { |line| line !~ mt_re } if new_bt.empty?
+ new_bt = bt.dup if new_bt.empty?
new_bt
end
@@ -801,7 +832,9 @@ module Minitest
result
end
- if defined? Process::CLOCK_MONOTONIC
+ # :stopdoc:
+
+ if defined? Process::CLOCK_MONOTONIC # :nodoc:
def self.clock_time
Process.clock_gettime Process::CLOCK_MONOTONIC
end
@@ -810,6 +843,8 @@ module Minitest
Time.now
end
end
+
+ # :startdoc:
end
require "minitest/test"
diff --git a/lib/minitest/assertions.rb b/lib/minitest/assertions.rb
index 230ecdd..b58aae1 100644
--- a/lib/minitest/assertions.rb
+++ b/lib/minitest/assertions.rb
@@ -171,7 +171,20 @@ module Minitest
def assert_equal exp, act, msg = nil
msg = message(msg, E) { diff exp, act }
- assert exp == act, msg
+ result = assert exp == act, msg
+
+ if exp.nil? then
+ if Minitest::VERSION =~ /^6/ then
+ refute_nil exp, "Use assert_nil if expecting nil."
+ else
+ where = Minitest.filter_backtrace(caller).first
+ where = where.split(/:in /, 2).first # clean up noise
+
+ warn "DEPRECATED: Use assert_nil if expecting nil from #{where}. This will fail in Minitest 6."
+ end
+ end
+
+ result
end
##
@@ -357,6 +370,10 @@ module Minitest
# Fails unless the call returns a true value
def assert_send send_ary, m = nil
+ where = Minitest.filter_backtrace(caller).first
+ where = where.split(/:in /, 2).first # clean up noise
+ warn "DEPRECATED: assert_send. From #{where}"
+
recv, msg, *args = send_ary
m = message(m) {
"Expected #{mu_pp(recv)}.#{msg}(*#{mu_pp(args)}) to return true" }
@@ -386,8 +403,10 @@ module Minitest
rescue ThreadError => e # wtf?!? 1.8 + threads == suck
default += ", not \:#{e.message[/uncaught throw \`(\w+?)\'/, 1]}"
rescue ArgumentError => e # 1.9 exception
+ raise e unless e.message.include?("uncaught throw")
default += ", not #{e.message.split(/ /).last}"
rescue NameError => e # 1.8 exception
+ raise e unless e.name == sym
default += ", not #{e.name.inspect}"
end
caught = false
diff --git a/lib/minitest/benchmark.rb b/lib/minitest/benchmark.rb
index fadcc73..fd310e3 100644
--- a/lib/minitest/benchmark.rb
+++ b/lib/minitest/benchmark.rb
@@ -1,4 +1,4 @@
-require "minitest/unit"
+require "minitest/test"
require "minitest/spec"
module Minitest
diff --git a/lib/minitest/hell.rb b/lib/minitest/hell.rb
index 01f0d54..73c88ac 100644
--- a/lib/minitest/hell.rb
+++ b/lib/minitest/hell.rb
@@ -1,17 +1,11 @@
require "minitest/parallel"
class Minitest::Test
- class << self
- alias :old_test_order :test_order # :nodoc:
-
- def test_order # :nodoc:
- :parallel
- end
- end
+ parallelize_me!
end
begin
require "minitest/proveit"
rescue LoadError
- # do nothing
+ warn "NOTE: `gem install minitest-proveit` for even more hellish tests"
end
diff --git a/lib/minitest/mock.rb b/lib/minitest/mock.rb
index eadcc46..a4e9d34 100644
--- a/lib/minitest/mock.rb
+++ b/lib/minitest/mock.rb
@@ -37,7 +37,7 @@ module Minitest # :nodoc:
end
end
- def initialize(delegator = nil) # :nodoc:
+ def initialize delegator = nil # :nodoc:
@delegator = delegator
@expected_calls = Hash.new { |calls, name| calls[name] = [] }
@actual_calls = Hash.new { |calls, name| calls[name] = [] }
@@ -67,7 +67,7 @@ module Minitest # :nodoc:
# @mock.expect(:uses_one_string, true, ["foo"])
# @mock.uses_one_string("bar") # => raises MockExpectationError
- def expect(name, retval, args = [], &blk)
+ def expect name, retval, args = [], &blk
name = name.to_sym
if block_given?
@@ -104,7 +104,7 @@ module Minitest # :nodoc:
true
end
- def method_missing(sym, *args, &block) # :nodoc:
+ def method_missing sym, *args, &block # :nodoc:
unless @expected_calls.key?(sym) then
if @delegator && @delegator.respond_to?(sym)
return @delegator.public_send(sym, *args, &block)
@@ -158,7 +158,7 @@ module Minitest # :nodoc:
retval
end
- def respond_to?(sym, include_private = false) # :nodoc:
+ def respond_to? sym, include_private = false # :nodoc:
return true if @expected_calls.key? sym.to_sym
return true if @delegator && @delegator.respond_to?(sym, include_private)
__respond_to?(sym, include_private)
diff --git a/lib/minitest/parallel.rb b/lib/minitest/parallel.rb
index e90030a..ad2a6d5 100644
--- a/lib/minitest/parallel.rb
+++ b/lib/minitest/parallel.rb
@@ -1,5 +1,5 @@
module Minitest
- module Parallel
+ module Parallel #:nodoc:
##
# The engine used to run multiple tests in parallel.
diff --git a/lib/minitest/pride_plugin.rb b/lib/minitest/pride_plugin.rb
index 335cd5c..aeef2b9 100644
--- a/lib/minitest/pride_plugin.rb
+++ b/lib/minitest/pride_plugin.rb
@@ -70,7 +70,7 @@ module Minitest
end
end
- def puts(*o) # :nodoc:
+ def puts *o # :nodoc:
o.map! { |s|
s.to_s.sub(/Finished/) {
@index = 0
diff --git a/lib/minitest/spec.rb b/lib/minitest/spec.rb
index 9c958db..a1275af 100644
--- a/lib/minitest/spec.rb
+++ b/lib/minitest/spec.rb
@@ -132,7 +132,7 @@ class Minitest::Spec < Minitest::Test
# desc.superclass == ActiveRecord::Base
# end
- def register_spec_type(*args, &block)
+ def register_spec_type *args, &block
if block then
matcher, klass = block, args.first
else
diff --git a/lib/minitest/test.rb b/lib/minitest/test.rb
index d6e5213..12627cd 100644
--- a/lib/minitest/test.rb
+++ b/lib/minitest/test.rb
@@ -13,8 +13,10 @@ module Minitest
PASSTHROUGH_EXCEPTIONS = [NoMemoryError, SignalException, SystemExit] # :nodoc:
- class << self; attr_accessor :io_lock; end # :nodoc:
+ # :stopdoc:
+ class << self; attr_accessor :io_lock; end
self.io_lock = Mutex.new
+ # :startdoc:
##
# Call this at the top of your tests when you absolutely
@@ -37,9 +39,7 @@ module Minitest
def self.make_my_diffs_pretty!
require "pp"
- define_method :mu_pp do |o|
- o.pretty_inspect
- end
+ define_method :mu_pp, &:pretty_inspect
end
##
diff --git a/lib/minitest/unit.rb b/lib/minitest/unit.rb
index a082797..9a4eadf 100644
--- a/lib/minitest/unit.rb
+++ b/lib/minitest/unit.rb
@@ -34,7 +34,7 @@ module Minitest
Minitest.autorun
end
- def self.after_tests(&b) # :nodoc:
+ def self.after_tests &b # :nodoc:
from = caller.first
warn "MiniTest::Unit.after_tests is now Minitest.after_run. From #{from}"
Minitest.after_run(&b)
diff --git a/metadata.gz.sig b/metadata.gz.sig
index 8f4be6e..34d3718 100644
Binary files a/metadata.gz.sig and b/metadata.gz.sig differ
diff --git a/minitest.gemspec b/minitest.gemspec
index 770499a..26c7516 100644
--- a/minitest.gemspec
+++ b/minitest.gemspec
@@ -5,12 +5,12 @@
Gem::Specification.new do |s|
s.name = "minitest"
- s.version = "5.9.0"
+ s.version = "5.10.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Ryan Davis"]
- s.cert_chain = ["-----BEGIN CERTIFICATE-----\nMIIDPjCCAiagAwIBAgIBAzANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu\nZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB\nGRYDY29tMB4XDTE1MDkxOTIwNTEyMloXDTE2MDkxODIwNTEyMlowRTETMBEGA1UE\nAwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS\nJomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda\nb9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx\ntaCPaLmfYIaFcHHCSY4hYDJijRQkLxPeB3xbOfzfLoBDbjvx [...]
- s.date = "2016-05-16"
+ s.cert_chain = ["-----BEGIN CERTIFICATE-----\nMIIDijCCAnKgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu\nZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB\nGRYDY29tMB4XDTE2MDkyNjAxNTczNVoXDTE3MDkyNjAxNTczNVowRTETMBEGA1UE\nAwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS\nJomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda\nb9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx\ntaCPaLmfYIaFcHHCSY4hYDJijRQkLxPeB3xbOfzfLoBDbjvx [...]
+ s.date = "2017-05-09"
s.description = "minitest provides a complete suite of testing facilities supporting\nTDD, BDD, mocking, and benchmarking.\n\n \"I had a class with Jim Weirich on testing last week and we were\n allowed to choose our testing frameworks. Kirk Haines and I were\n paired up and we cracked open the code for a few test\n frameworks...\n\n I MUST say that minitest is *very* readable / understandable\n compared to the 'other two' options we looked at. Nicely done and\n [...]
s.email = ["ryand-ruby at zenspider.com"]
s.extra_rdoc_files = ["History.rdoc", "Manifest.txt", "README.rdoc"]
@@ -26,14 +26,14 @@ Gem::Specification.new do |s|
s.specification_version = 4
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<hoe>, ["~> 3.15"])
+ s.add_development_dependency(%q<hoe>, ["~> 3.16"])
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
else
- s.add_dependency(%q<hoe>, ["~> 3.15"])
+ s.add_dependency(%q<hoe>, ["~> 3.16"])
s.add_dependency(%q<rdoc>, ["~> 4.0"])
end
else
- s.add_dependency(%q<hoe>, ["~> 3.15"])
+ s.add_dependency(%q<hoe>, ["~> 3.16"])
s.add_dependency(%q<rdoc>, ["~> 4.0"])
end
end
diff --git a/test/minitest/metametameta.rb b/test/minitest/metametameta.rb
index e2f87d0..fa3704f 100644
--- a/test/minitest/metametameta.rb
+++ b/test/minitest/metametameta.rb
@@ -8,13 +8,24 @@ class Minitest::Test
end
end
+class FakeNamedTest < Minitest::Test
+ @@count = 0
+
+ def self.name
+ @fake_name ||= begin
+ @@count += 1
+ "FakeNamedTest%02d" % @@count
+ end
+ end
+end
+
class MetaMetaMetaTestCase < Minitest::Test
attr_accessor :reporter, :output, :tu
def run_tu_with_fresh_reporter flags = %w[--seed 42]
options = Minitest.process_args flags
- @output = StringIO.new("")
+ @output = StringIO.new("".encode('UTF-8'))
self.reporter = Minitest::CompositeReporter.new
reporter << Minitest::SummaryReporter.new(@output, options)
diff --git a/test/minitest/test_minitest_mock.rb b/test/minitest/test_minitest_mock.rb
index f5f4f56..d4c4f40 100644
--- a/test/minitest/test_minitest_mock.rb
+++ b/test/minitest/test_minitest_mock.rb
@@ -174,10 +174,10 @@ class TestMinitestMock < Minitest::Test
end
def test_mock_is_a_blank_slate
- @mock.expect :kind_of?, true, [Fixnum]
+ @mock.expect :kind_of?, true, [String]
@mock.expect :==, true, [1]
- assert @mock.kind_of?(Fixnum), "didn't mock :kind_of\?"
+ assert @mock.kind_of?(String), "didn't mock :kind_of\?"
assert @mock == 1, "didn't mock :=="
end
@@ -473,11 +473,11 @@ class TestMinitestStub < Minitest::Test
@assertion_count = 2
dynamic = Class.new do
- def self.respond_to?(meth)
+ def self.respond_to? meth
meth == :found
end
- def self.method_missing(meth, *args, &block)
+ def self.method_missing meth, *args, &block
if meth == :found
false
else
@@ -501,8 +501,8 @@ class TestMinitestStub < Minitest::Test
end
rs = nil
- File.stub(:open, true, mock) do
- File.open("foo.txt", "r") do |f|
+ File.stub :open, true, mock do
+ File.open "foo.txt", "r" do |f|
rs = f.write
end
end
diff --git a/test/minitest/test_minitest_reporter.rb b/test/minitest/test_minitest_reporter.rb
index 18b8a75..2c93c2d 100644
--- a/test/minitest/test_minitest_reporter.rb
+++ b/test/minitest/test_minitest_reporter.rb
@@ -74,6 +74,12 @@ class TestMinitestReporter < MetaMetaMetaTestCase
@st
end
+ def test_to_s
+ r.record passing_test
+ r.record fail_test
+ assert_match "woot", r.first.to_s
+ end
+
def test_passed_eh_empty
assert r.passed?
end
diff --git a/test/minitest/test_minitest_spec.rb b/test/minitest/test_minitest_spec.rb
index 7ae786f..29b6a6e 100644
--- a/test/minitest/test_minitest_spec.rb
+++ b/test/minitest/test_minitest_spec.rb
@@ -12,6 +12,9 @@ class ExampleA; end
class ExampleB < ExampleA; end
describe Minitest::Spec do
+ # helps to deal with 2.4 deprecation of Fixnum for Integer
+ Int = 1.class
+
# do not parallelize this suite... it just can"t handle it.
def assert_triggered expected = "blah", klass = Minitest::Assertion
@@ -115,7 +118,7 @@ describe Minitest::Spec do
@assertion_count -= 1 # no msg
@assertion_count += 2 # assert_output is 2 assertions
- proc { }.must_be_silent.must_equal true
+ proc {}.must_be_silent.must_equal true
assert_triggered "In stdout.\nExpected: \"\"\n Actual: \"xxx\"" do
proc { print "xxx" }.must_be_silent
@@ -213,6 +216,21 @@ describe Minitest::Spec do
end
end
+ it "needs to warn on equality with nil" do
+ @assertion_count += 1 # extra test
+
+ out, err = capture_io do
+ nil.must_equal(nil).must_equal true
+ end
+
+ exp = "DEPRECATED: Use assert_nil if expecting nil from #{__FILE__}:#{__LINE__-3}. " \
+ "This will fail in Minitest 6.\n"
+ exp = "" if $-w.nil?
+
+ assert_empty out
+ assert_equal exp, err
+ end
+
it "needs to verify floats outside a delta" do
@assertion_count += 1 # extra test
@@ -304,7 +322,7 @@ describe Minitest::Spec do
it "needs to verify inequality" do
@assertion_count += 2
42.wont_equal(6 * 9).must_equal false
- proc{}.wont_equal(42).must_equal false
+ proc {}.wont_equal(42).must_equal false
assert_triggered "Expected 1 to not be equal to 1." do
1.wont_equal 1
@@ -318,12 +336,12 @@ describe Minitest::Spec do
it "needs to verify instances of a class" do
42.wont_be_instance_of(String).must_equal false
- assert_triggered "Expected 42 to not be an instance of Fixnum." do
- 42.wont_be_instance_of Fixnum
+ assert_triggered "Expected 42 to not be a kind of #{Int.name}." do
+ 42.wont_be_kind_of Int
end
- assert_triggered "msg.\nExpected 42 to not be an instance of Fixnum." do
- 42.wont_be_instance_of Fixnum, "msg"
+ assert_triggered "msg.\nExpected 42 to not be an instance of #{Int.name}." do
+ 42.wont_be_instance_of Int, "msg"
end
end
@@ -331,34 +349,34 @@ describe Minitest::Spec do
@assertion_count += 2
42.wont_be_kind_of(String).must_equal false
- proc{}.wont_be_kind_of(String).must_equal false
+ proc {}.wont_be_kind_of(String).must_equal false
- assert_triggered "Expected 42 to not be a kind of Integer." do
- 42.wont_be_kind_of Integer
+ assert_triggered "Expected 42 to not be a kind of #{Int.name}." do
+ 42.wont_be_kind_of Int
end
- assert_triggered "msg.\nExpected 42 to not be a kind of Integer." do
- 42.wont_be_kind_of Integer, "msg"
+ assert_triggered "msg.\nExpected 42 to not be a kind of #{Int.name}." do
+ 42.wont_be_kind_of Int, "msg"
end
end
it "needs to verify kinds of objects" do
@assertion_count += 3 # extra test
- (6 * 7).must_be_kind_of(Fixnum).must_equal true
+ (6 * 7).must_be_kind_of(Int).must_equal true
(6 * 7).must_be_kind_of(Numeric).must_equal true
- assert_triggered "Expected 42 to be a kind of String, not Fixnum." do
+ assert_triggered "Expected 42 to be a kind of String, not #{Int.name}." do
(6 * 7).must_be_kind_of String
end
- assert_triggered "msg.\nExpected 42 to be a kind of String, not Fixnum." do
+ assert_triggered "msg.\nExpected 42 to be a kind of String, not #{Int.name}." do
(6 * 7).must_be_kind_of String, "msg"
end
exp = "Expected #<Proc:0xXXXXXX at PATH> to be a kind of String, not Proc."
assert_triggered exp do
- proc{}.must_be_kind_of String
+ proc {}.must_be_kind_of String
end
end
@@ -502,7 +520,7 @@ describe Minitest::Spec do
proc { throw :blah }.must_throw(:blah).must_equal true
assert_triggered "Expected :blah to have been thrown." do
- proc { }.must_throw :blah
+ proc {}.must_throw :blah
end
assert_triggered "Expected :blah to have been thrown, not :xxx." do
@@ -510,7 +528,7 @@ describe Minitest::Spec do
end
assert_triggered "msg.\nExpected :blah to have been thrown." do
- proc { }.must_throw :blah, "msg"
+ proc {}.must_throw :blah, "msg"
end
assert_triggered "msg.\nExpected :blah to have been thrown, not :xxx." do
@@ -519,9 +537,9 @@ describe Minitest::Spec do
end
it "needs to verify types of objects" do
- (6 * 7).must_be_instance_of(Fixnum).must_equal true
+ (6 * 7).must_be_instance_of(Int).must_equal true
- exp = "Expected 42 to be an instance of String, not Fixnum."
+ exp = "Expected 42 to be an instance of String, not #{Int.name}."
assert_triggered exp do
(6 * 7).must_be_instance_of String
@@ -565,11 +583,11 @@ describe Minitest::Spec do
it "needs to verify using respond_to" do
42.must_respond_to(:+).must_equal true
- assert_triggered "Expected 42 (Fixnum) to respond to #clear." do
+ assert_triggered "Expected 42 (#{Int.name}) to respond to #clear." do
42.must_respond_to :clear
end
- assert_triggered "msg.\nExpected 42 (Fixnum) to respond to #clear." do
+ assert_triggered "msg.\nExpected 42 (#{Int.name}) to respond to #clear." do
42.must_respond_to :clear, "msg"
end
end
@@ -626,7 +644,7 @@ describe Minitest::Spec, :let do
end
it "procs come after dont_flip" do
- p = proc { }
+ p = proc {}
assert_respond_to p, :call
p.must_respond_to :call
end
@@ -947,21 +965,21 @@ class ValueMonadTest < Minitest::Test
attr_accessor :struct
def setup
- @struct = { :_ => 'a', :value => 'b', :expect => 'c' }
+ @struct = { :_ => "a", :value => "b", :expect => "c" }
def @struct.method_missing k # think openstruct
self[k]
end
end
def test_value_monad_method
- assert_equal 'a', struct._
+ assert_equal "a", struct._
end
def test_value_monad_value_alias
- assert_equal 'b', struct.value
+ assert_equal "b", struct.value
end
def test_value_monad_expect_alias
- assert_equal 'c', struct.expect
+ assert_equal "c", struct.expect
end
end
diff --git a/test/minitest/test_minitest_test.rb b/test/minitest/test_minitest_test.rb
index dac74fb..a967eb4 100644
--- a/test/minitest/test_minitest_test.rb
+++ b/test/minitest/test_minitest_test.rb
@@ -3,6 +3,18 @@
require "pathname"
require "minitest/metametameta"
+if defined? Encoding then
+ e = Encoding.default_external
+ if e != Encoding::UTF_8 then
+ warn ""
+ warn ""
+ warn "NOTE: External encoding #{e} is not UTF-8. Tests WILL fail."
+ warn " Run tests with `RUBYOPT=-Eutf-8 rake` to avoid errors."
+ warn ""
+ warn ""
+ end
+end
+
module MyModule; end
class AnError < StandardError; include MyModule; end
class ImmutableString < String; def inspect; super.freeze; end; end
@@ -66,8 +78,40 @@ class TestMinitestUnit < MetaMetaMetaTestCase
# assert_instance_of Minitest::Unit, Minitest::Unit.runner
# end
+ def test_infectious_binary_encoding
+ @tu = Class.new Minitest::Test do
+ def test_this_is_not_ascii_assertion
+ assert_equal "ЁЁЁ", "ёёё"
+ end
+
+ def test_this_is_non_ascii_failure_message
+ fail 'ЁЁЁ'.force_encoding('ASCII-8BIT')
+ end
+ end
+
+ expected = clean <<-EOM
+ EF
+
+ Finished in 0.00
+
+ 1) Error:
+ #<Class:0xXXX>#test_this_is_non_ascii_failure_message:
+ RuntimeError: ЁЁЁ
+ FILE:LINE:in `test_this_is_non_ascii_failure_message'
+
+ 2) Failure:
+ #<Class:0xXXX>#test_this_is_not_ascii_assertion [FILE:LINE]:
+ Expected: \"ЁЁЁ\"
+ Actual: \"ёёё\"
+
+ 2 runs, 1 assertions, 1 failures, 1 errors, 0 skips
+ EOM
+
+ assert_report expected
+ end
+
def test_passed_eh_teardown_good
- test_class = Class.new Minitest::Test do
+ test_class = Class.new FakeNamedTest do
def teardown; assert true; end
def test_omg; assert true; end
end
@@ -78,7 +122,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
end
def test_passed_eh_teardown_skipped
- test_class = Class.new Minitest::Test do
+ test_class = Class.new FakeNamedTest do
def teardown; assert true; end
def test_omg; skip "bork"; end
end
@@ -91,7 +135,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
end
def test_passed_eh_teardown_flunked
- test_class = Class.new Minitest::Test do
+ test_class = Class.new FakeNamedTest do
def teardown; flunk; end
def test_omg; assert true; end
end
@@ -138,7 +182,7 @@ class TestMinitestUnitInherited < MetaMetaMetaTestCase
def test_inherited_hook_plays_nice_with_others
with_overridden_include do
assert_throws :inherited_hook do
- Class.new Minitest::Test
+ Class.new FakeNamedTest
end
end
end
@@ -158,7 +202,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
def test_run_test
@tu =
- Class.new Minitest::Test do
+ Class.new FakeNamedTest do
attr_reader :foo
def run
@@ -187,7 +231,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
def test_run_error
@tu =
- Class.new Minitest::Test do
+ Class.new FakeNamedTest do
def test_something
assert true
end
@@ -215,7 +259,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
def test_run_error_teardown
@tu =
- Class.new Minitest::Test do
+ Class.new FakeNamedTest do
def test_something
assert true
end
@@ -261,7 +305,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
def setup_basic_tu
@tu =
- Class.new Minitest::Test do
+ Class.new FakeNamedTest do
def test_something
assert true
end
@@ -289,14 +333,14 @@ class TestMinitestRunner < MetaMetaMetaTestCase
def assert_filtering filter, name, expected, a = false
args = %W[--#{filter} #{name} --seed 42]
- alpha = Class.new Minitest::Test do
+ alpha = Class.new FakeNamedTest do
define_method :test_something do
assert a
end
end
Object.const_set(:Alpha, alpha)
- beta = Class.new Minitest::Test do
+ beta = Class.new FakeNamedTest do
define_method :test_something do
assert true
end
@@ -320,7 +364,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
- assert_filtering 'name', "/Beta#test_something/", expected
+ assert_filtering "name", "/Beta#test_something/", expected
end
def test_run_filtered_including_suite_name_string
@@ -332,7 +376,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
- assert_filtering 'name', "Beta#test_something", expected
+ assert_filtering "name", "Beta#test_something", expected
end
def test_run_filtered_string_method_only
@@ -344,7 +388,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
EOM
- assert_filtering 'name', "test_something", expected, :pass
+ assert_filtering "name", "test_something", expected, :pass
end
def test_run_failing_excluded
@@ -370,7 +414,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
- assert_filtering 'exclude', "/Alpha#test_something/", expected
+ assert_filtering "exclude", "/Alpha#test_something/", expected
end
def test_run_filtered_excluding_suite_name_string
@@ -382,7 +426,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
- assert_filtering 'exclude', "Alpha#test_something", expected
+ assert_filtering "exclude", "Alpha#test_something", expected
end
def test_run_filtered_excluding_string_method_only
@@ -394,12 +438,12 @@ class TestMinitestRunner < MetaMetaMetaTestCase
0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
EOM
- assert_filtering 'exclude', "test_something", expected, :pass
+ assert_filtering "exclude", "test_something", expected, :pass
end
def test_run_passing
@tu =
- Class.new Minitest::Test do
+ Class.new FakeNamedTest do
def test_something
assert true
end
@@ -418,7 +462,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
def test_run_skip
@tu =
- Class.new Minitest::Test do
+ Class.new FakeNamedTest do
def test_something
assert true
end
@@ -445,7 +489,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
def test_run_skip_verbose
@tu =
- Class.new Minitest::Test do
+ Class.new FakeNamedTest do
def test_something
assert true
end
@@ -473,7 +517,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
def test_run_with_other_runner
@tu =
- Class.new Minitest::Test do
+ Class.new FakeNamedTest do
def self.run reporter, options = {}
@reporter = reporter
before_my_suite
@@ -548,7 +592,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
}
@tu =
- Class.new Minitest::Test do
+ Class.new FakeNamedTest do
parallelize_me!
test_count.times do |i|
@@ -596,7 +640,7 @@ class TestMinitestUnitOrder < MetaMetaMetaTestCase
def test_before_setup
call_order = []
@tu =
- Class.new Minitest::Test do
+ Class.new FakeNamedTest do
define_method :setup do
super()
call_order << :setup
@@ -618,7 +662,7 @@ class TestMinitestUnitOrder < MetaMetaMetaTestCase
def test_after_teardown
call_order = []
@tu =
- Class.new Minitest::Test do
+ Class.new FakeNamedTest do
define_method :teardown do
super()
call_order << :teardown
@@ -640,7 +684,7 @@ class TestMinitestUnitOrder < MetaMetaMetaTestCase
def test_all_teardowns_are_guaranteed_to_run
call_order = []
@tu =
- Class.new Minitest::Test do
+ Class.new FakeNamedTest do
define_method :after_teardown do
super()
call_order << :after_teardown
@@ -671,7 +715,7 @@ class TestMinitestUnitOrder < MetaMetaMetaTestCase
def test_setup_and_teardown_survive_inheritance
call_order = []
- @tu = Class.new Minitest::Test do
+ @tu = Class.new FakeNamedTest do
define_method :setup do
call_order << :setup_method
end
@@ -979,6 +1023,30 @@ class TestMinitestUnitTestCase < Minitest::Test
end
end
+ def test_assert_equal_does_not_allow_lhs_nil
+ if Minitest::VERSION =~ /^6/ then
+ warn "Time to strip the MT5 test"
+
+ @assertion_count += 1
+ assert_triggered(/Use assert_nil if expecting nil/) do
+ @tc.assert_equal nil, nil
+ end
+ else
+ err_re = /Use assert_nil if expecting nil from .*test_minitest_test.rb/
+ err_re = "" if $-w.nil?
+
+ assert_output "", err_re do
+ @tc.assert_equal nil, nil
+ end
+ end
+ end
+
+ def test_assert_equal_does_not_allow_lhs_nil_triggered
+ assert_triggered "Expected: nil\n Actual: false" do
+ @tc.assert_equal nil, false
+ end
+ end
+
def test_assert_in_delta
@tc.assert_in_delta 0.0, 1.0 / 1000, 0.1
end
@@ -1088,7 +1156,7 @@ class TestMinitestUnitTestCase < Minitest::Test
@assertion_count = 2
pattern = Object.new
- def pattern.=~(_) true end
+ def pattern.=~ _; true end
@tc.assert_match pattern, 5
end
@@ -1106,7 +1174,7 @@ class TestMinitestUnitTestCase < Minitest::Test
@assertion_count = 2
pattern = Object.new
- def pattern.=~(_) false end
+ def pattern.=~ _; false end
def pattern.inspect; "[Object]" end
assert_triggered "Expected [Object] to match 5." do
@@ -1137,7 +1205,7 @@ class TestMinitestUnitTestCase < Minitest::Test
def test_assert_operator_bad_object
bad = Object.new
- def bad.==(_) true end
+ def bad.== _; true end
@tc.assert_operator bad, :equal?, bad
end
@@ -1424,13 +1492,26 @@ class TestMinitestUnitTestCase < Minitest::Test
end
end
+ def assert_deprecated name
+ dep = /DEPRECATED: #{name}. From #{__FILE__}:\d+(?::.*)?/
+ dep = "" if $-w.nil?
+
+ assert_output nil, dep do
+ yield
+ end
+ end
+
def test_assert_send
- @tc.assert_send [1, :<, 2]
+ assert_deprecated :assert_send do
+ @tc.assert_send [1, :<, 2]
+ end
end
def test_assert_send_bad
- assert_triggered "Expected 1.>(*[2]) to return true." do
- @tc.assert_send [1, :>, 2]
+ assert_deprecated :assert_send do
+ assert_triggered "Expected 1.>(*[2]) to return true." do
+ @tc.assert_send [1, :>, 2]
+ end
end
end
@@ -1466,6 +1547,22 @@ class TestMinitestUnitTestCase < Minitest::Test
end
end
+ def test_assert_throws_name_error
+ @tc.assert_raises NameError do
+ @tc.assert_throws :blah do
+ raise NameError
+ end
+ end
+ end
+
+ def test_assert_throws_argument_exception
+ @tc.assert_raises ArgumentError do
+ @tc.assert_throws :blah do
+ raise ArgumentError
+ end
+ end
+ end
+
def test_assert_throws_different
assert_triggered "Expected :blah to have been thrown, not :not_blah." do
@tc.assert_throws :blah do
@@ -1696,7 +1793,7 @@ class TestMinitestUnitTestCase < Minitest::Test
@assertion_count = 2
pattern = Object.new
- def pattern.=~(_) true end
+ def pattern.=~ _; true end
def pattern.inspect; "[Object]" end
assert_triggered "Expected [Object] to not match 5." do
@@ -1737,7 +1834,7 @@ class TestMinitestUnitTestCase < Minitest::Test
def test_refute_operator_bad_object
bad = Object.new
- def bad.==(_) true end
+ def bad.== _; true end
@tc.refute_operator true, :equal?, bad
end
@@ -1779,7 +1876,7 @@ class TestMinitestUnitTestCase < Minitest::Test
def test_runnable_methods_random
@assertion_count = 0
- sample_test_case = Class.new Minitest::Test do
+ sample_test_case = Class.new FakeNamedTest do
def self.test_order; :random; end
def test_test1; assert "does not matter" end
def test_test2; assert "does not matter" end
@@ -1799,7 +1896,7 @@ class TestMinitestUnitTestCase < Minitest::Test
def test_runnable_methods_sorted
@assertion_count = 0
- sample_test_case = Class.new Minitest::Test do
+ sample_test_case = Class.new FakeNamedTest do
def self.test_order; :sorted end
def test_test3; assert "does not matter" end
def test_test2; assert "does not matter" end
@@ -1813,7 +1910,7 @@ class TestMinitestUnitTestCase < Minitest::Test
def test_i_suck_and_my_tests_are_order_dependent_bang_sets_test_order_alpha
@assertion_count = 0
- shitty_test_case = Class.new Minitest::Test
+ shitty_test_case = Class.new FakeNamedTest
shitty_test_case.i_suck_and_my_tests_are_order_dependent!
@@ -1823,7 +1920,7 @@ class TestMinitestUnitTestCase < Minitest::Test
def test_i_suck_and_my_tests_are_order_dependent_bang_does_not_warn
@assertion_count = 0
- shitty_test_case = Class.new Minitest::Test
+ shitty_test_case = Class.new FakeNamedTest
def shitty_test_case.test_order; :lol end
@@ -1841,7 +1938,8 @@ class TestMinitestUnitTestCase < Minitest::Test
msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
- assert_equal expected, msg
+ assert_msg = Regexp === expected ? :assert_match : :assert_equal
+ self.send assert_msg, expected, msg
end
def util_msg exp, act, msg = nil
@@ -1887,8 +1985,8 @@ end
class TestMinitestUnitRecording < MetaMetaMetaTestCase
# do not parallelize this suite... it just can't handle it.
- def assert_run_record(*expected, &block)
- @tu = Class.new Minitest::Test, &block
+ def assert_run_record *expected, &block
+ @tu = Class.new FakeNamedTest, &block
run_tu_with_fresh_reporter
@@ -1897,6 +1995,35 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
assert_equal expected, recorded
end
+ def test_run_with_bogus_reporter
+ # https://github.com/seattlerb/minitest/issues/659
+ # TODO: remove test for minitest 6
+ @tu = Class.new FakeNamedTest do
+ def test_method
+ assert true
+ end
+ end
+
+ bogus_reporter = Class.new do # doesn't subclass AbstractReporter
+ def start; @success = false; end
+ # def prerecord klass, name; end # doesn't define full API
+ def record result; @success = true; end
+ def report; end
+ def passed?; end
+ def results; end
+ def success?; @success; end
+ end.new
+
+ self.reporter = Minitest::CompositeReporter.new
+ reporter << bogus_reporter
+
+ Minitest::Runnable.runnables.delete @tu
+
+ @tu.run reporter, {}
+
+ assert_predicate bogus_reporter, :success?
+ end
+
def test_record_passing
assert_run_record do
def test_method
@@ -1946,7 +2073,7 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
end
def test_to_s_error_in_test_and_teardown
- @tu = Class.new Minitest::Test do
+ @tu = Class.new FakeNamedTest do
def test_method
raise AnError
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-minitest.git
More information about the Pkg-ruby-extras-commits
mailing list