minitest 5.14.4 → 5.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1edfa85bfac65503ab66f88d6ca07571a6e788bfd9eb513399cc60ffeae32e1f
4
- data.tar.gz: 68a4cc4fcf8b54f8ba97dbda48e7ee4a8f818c67a3c4021920d5c6e4dfe9866c
3
+ metadata.gz: 0d7d16c7decb91ba01a888704bd527d1e5569454b444fe1b4e41a8a3a7db7406
4
+ data.tar.gz: 1ee0d2823a94b63b8cd019198fe2ca20a5c3d9d7bf4918148bdfa543fb65945d
5
5
  SHA512:
6
- metadata.gz: 7f808ea45c7d6755da784bc6d70356f6beb7b794bd4df3cf509ce08d762f125c1bcafd92c406c73ea6a13809d836c75812fed83605f18b1d82e6f16b98e97004
7
- data.tar.gz: d75f3b41034e4a70b8f372a79af5971eb2a589f87a4a80bfc20f23ebf1e5ac50235bfa5c300a25bba99f55746a8148cddde804cc9181d941ad62c71626482e06
6
+ metadata.gz: 933a300969aa30dc8f254952dd17f9975cb1f3aad9c10c96260394d088b76900273773374b5ed72731356f2b7f1cfeb131583ae943322250a60401e554e11f45
7
+ data.tar.gz: 24a356e1d3c06e28d03860b4dca92d17b88979ebad6316fe97298207c58b29b0ae207657d0044a43ede1bf9a27ac43ca8c779e24fc9ca5ed4c920beca2eaf143
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,24 @@
1
+ === 5.15.0 / 2021-12-14
2
+
3
+ * 1 major enhancement:
4
+
5
+ * assert_throws returns the value returned, if any. (volmer)
6
+
7
+ * 3 minor enhancements:
8
+
9
+ * Added -S <CODES> option to skip reporting of certain types of output
10
+ * Enable Ruby deprecation warnings by default. (casperisfine)
11
+ * Use Etc.nprocessors by default in order to maximize cpu usage. (tonytonyjan)
12
+
13
+ * 6 bug fixes:
14
+
15
+ * Close then unlink tempfiles on Windows. (nobu)
16
+ * Fixed #skip_until for windows paths. (MSP-Greg)
17
+ * Fixed a bunch of tests for jruby and windows. (MSP-Greg)
18
+ * Fixed marshalling of specs if they error. (tenderlove, jeremyevans, et al)
19
+ * Updated deprecation message for block expectations. (blowmage)
20
+ * Use Kernel.warn directly in expectations in case CUT defines their own warn. (firien)
21
+
1
22
  === 5.14.4 / 2021-02-23
2
23
 
3
24
  * 1 bug fix:
@@ -561,7 +582,7 @@ Minitest 5:
561
582
  * Added Minitest::Benchmark.
562
583
  * Your benchmarks need to move to their own subclass.
563
584
  * Benchmarks using the spec DSL have to have "Bench" somewhere in their describe.
564
- * MiniTest::Unit.after_tests moved to Minitest.after_tests
585
+ * MiniTest::Unit.after_tests moved to Minitest.after_run
565
586
  * MiniTest::Unit.autorun is now Minitest.autorun. Just require minitest/autorun pls.
566
587
  * Removed ParallelEach#grep since it isn't used anywhere.
567
588
  * Renamed Runnable#__name__ to Runnable#name (but uses @NAME internally).
data/README.rdoc CHANGED
@@ -401,8 +401,8 @@ Current versions of ruby: (https://endoflife.date/ruby)
401
401
  |------+---------+------------|
402
402
  | 3.0 | Current | 2024-03-31 |
403
403
  | 2.7 | Maint | 2023-03-31 |
404
- | 2.6 | Maint | 2022-03-31 |
405
- | 2.5 | Maint* | 2021-03-31 |
404
+ | 2.6 | Maint* | 2022-03-31 |
405
+ | 2.5 | EOL | 2021-03-31 |
406
406
  | 2.4 | EOL | 2020-03-31 |
407
407
  | 2.3 | EOL | 2019-03-31 |
408
408
  | 2.2 | EOL | 2018-03-31 |
@@ -647,6 +647,7 @@ minitest-growl :: Test notifier for minitest via growl.
647
647
  minitest-happy :: GLOBALLY ACTIVATE MINITEST PRIDE! RAWR!
648
648
  minitest-have_tag :: Adds Minitest assertions to test for the existence of
649
649
  HTML tags, including contents, within a provided string.
650
+ minitest-heat :: Reporting that builds a heat map of failure locations
650
651
  minitest-hooks :: Around and before_all/after_all/around_all hooks
651
652
  minitest-hyper :: Pretty, single-page HTML reports for your Minitest runs
652
653
  minitest-implicit-subject :: Implicit declaration of the test subject.
@@ -721,6 +722,8 @@ mongoid-minitest :: Minitest matchers for Mongoid.
721
722
  mutant-minitest :: Minitest integration for mutant.
722
723
  pry-rescue :: A pry plugin w/ minitest support. See
723
724
  pry-rescue/minitest.rb.
725
+ rematch :: Declutter your test files from large hardcoded data
726
+ and update them automatically when your code changes.
724
727
  rspec2minitest :: Easily translate any RSpec matchers to Minitest
725
728
  assertions and expectations.
726
729
 
data/lib/hoe/minitest.rb CHANGED
@@ -24,9 +24,5 @@ module Hoe::Minitest
24
24
 
25
25
  def define_minitest_tasks
26
26
  self.testlib = :minitest
27
-
28
- # make sure we use the gemmed minitest on 1.9
29
- self.test_prelude = 'gem "minitest"' unless
30
- minitest? or ENV["MT_NO_ISOLATE"]
31
27
  end
32
28
  end
@@ -473,7 +473,7 @@ module Minitest
473
473
  def assert_throws sym, msg = nil
474
474
  default = "Expected #{mu_pp(sym)} to have been thrown"
475
475
  caught = true
476
- catch(sym) do
476
+ value = catch(sym) do
477
477
  begin
478
478
  yield
479
479
  rescue ThreadError => e # wtf?!? 1.8 + threads == suck
@@ -489,6 +489,7 @@ module Minitest
489
489
  end
490
490
 
491
491
  assert caught, message(msg) { default }
492
+ value
492
493
  rescue Assertion
493
494
  raise
494
495
  rescue => e
@@ -561,15 +562,13 @@ module Minitest
561
562
 
562
563
  return captured_stdout.read, captured_stderr.read
563
564
  ensure
564
- captured_stdout.unlink
565
- captured_stderr.unlink
566
565
  $stdout.reopen orig_stdout
567
566
  $stderr.reopen orig_stderr
568
567
 
569
568
  orig_stdout.close
570
569
  orig_stderr.close
571
- captured_stdout.close
572
- captured_stderr.close
570
+ captured_stdout.close!
571
+ captured_stderr.close!
573
572
  end
574
573
  end
575
574
  end
@@ -793,7 +792,7 @@ module Minitest
793
792
 
794
793
  def skip_until y,m,d,msg
795
794
  skip msg if Time.now < Time.local(y, m, d)
796
- where = caller.first.split(/:/, 3).first(2).join ":"
795
+ where = caller.first.rpartition(':in').reject(&:empty?).first
797
796
  warn "Stale skip_until %p at %s" % [msg, where]
798
797
  end
799
798
 
data/lib/minitest/spec.rb CHANGED
@@ -4,13 +4,14 @@ class Module # :nodoc:
4
4
  def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
5
5
  block = dont_flip == :block
6
6
  dont_flip = false if block
7
+ target_obj = block ? '_{obj.method}' : '_(obj)'
7
8
 
8
9
  # warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
9
10
  self.class_eval <<-EOM, __FILE__, __LINE__ + 1
10
11
  def #{new_name} *args
11
12
  where = Minitest.filter_backtrace(caller).first
12
13
  where = where.split(/:in /, 2).first # clean up noise
13
- warn "DEPRECATED: global use of #{new_name} from #\{where}. Use _(obj).#{new_name} instead. This will fail in Minitest 6."
14
+ Kernel.warn "DEPRECATED: global use of #{new_name} from #\{where}. Use #{target_obj}.#{new_name} instead. This will fail in Minitest 6."
14
15
  Minitest::Expectation.new(self, Minitest::Spec.current).#{new_name}(*args)
15
16
  end
16
17
  EOM
data/lib/minitest/test.rb CHANGED
@@ -198,7 +198,17 @@ module Minitest
198
198
  rescue Assertion => e
199
199
  self.failures << e
200
200
  rescue Exception => e
201
- self.failures << UnexpectedError.new(e)
201
+ self.failures << UnexpectedError.new(sanitize_exception e)
202
+ end
203
+
204
+ def sanitize_exception e # :nodoc:
205
+ Marshal.dump e
206
+ e
207
+ rescue TypeError
208
+ bt = e.backtrace
209
+ e = RuntimeError.new "Wrapped undumpable exception for: #{e.class}: #{e.message}"
210
+ e.set_backtrace bt
211
+ e
202
212
  end
203
213
 
204
214
  def with_info_handler &block # :nodoc:
data/lib/minitest.rb CHANGED
@@ -3,12 +3,13 @@ require "thread"
3
3
  require "mutex_m"
4
4
  require "minitest/parallel"
5
5
  require "stringio"
6
+ require "etc"
6
7
 
7
8
  ##
8
9
  # :include: README.rdoc
9
10
 
10
11
  module Minitest
11
- VERSION = "5.14.4" # :nodoc:
12
+ VERSION = "5.15.0" # :nodoc:
12
13
  ENCS = "".respond_to? :encoding # :nodoc:
13
14
 
14
15
  @@installed_at_exit ||= false
@@ -23,7 +24,7 @@ module Minitest
23
24
  mc.send :attr_accessor, :parallel_executor
24
25
 
25
26
  warn "DEPRECATED: use MT_CPU instead of N for parallel test runs" if ENV["N"]
26
- n_threads = (ENV["MT_CPU"] || ENV["N"] || 2).to_i
27
+ n_threads = (ENV["MT_CPU"] || ENV["N"] || Etc.nprocessors).to_i
27
28
  self.parallel_executor = Parallel::Executor.new n_threads
28
29
 
29
30
  ##
@@ -53,6 +54,10 @@ module Minitest
53
54
  # Registers Minitest to run at process exit
54
55
 
55
56
  def self.autorun
57
+ if Object.const_defined?(:Warning) && Warning.respond_to?(:[]=)
58
+ Warning[:deprecated] = true
59
+ end
60
+
56
61
  at_exit {
57
62
  next if $! and not ($!.kind_of? SystemExit and $!.success?)
58
63
 
@@ -199,6 +204,10 @@ module Minitest
199
204
  options[:exclude] = a
200
205
  end
201
206
 
207
+ opts.on "-S", "--skip CODES", String, "Skip reporting of certain types of results (eg E)." do |s|
208
+ options[:skip] = s.chars.to_a
209
+ end
210
+
202
211
  unless extensions.empty?
203
212
  opts.separator ""
204
213
  opts.separator "Known extensions: #{extensions.join(", ")}"
@@ -786,7 +795,11 @@ module Minitest
786
795
  filtered_results = results.dup
787
796
  filtered_results.reject!(&:skipped?) unless options[:verbose]
788
797
 
798
+ skip = options[:skip] || []
799
+
789
800
  filtered_results.each_with_index { |result, i|
801
+ next if skip.include? result.result_code
802
+
790
803
  io.puts "\n%3d) %s" % [i+1, result]
791
804
  }
792
805
  io.puts
@@ -28,6 +28,9 @@ class TestMinitestAssertions < Minitest::Test
28
28
 
29
29
  RUBY18 = !defined? Encoding
30
30
 
31
+ # not included in JRuby
32
+ RE_LEVELS = /\(\d+ levels\) /
33
+
31
34
  class DummyTest
32
35
  include Minitest::Assertions
33
36
  # include Minitest::Reportable # TODO: why do I really need this?
@@ -756,12 +759,12 @@ class TestMinitestAssertions < Minitest::Test
756
759
  Class: <SomeError>
757
760
  Message: <\"blah\">
758
761
  ---Backtrace---
759
- FILE:LINE:in \`test_assert_raises_default_triggered\'
762
+ FILE:LINE:in \`block in test_assert_raises_default_triggered\'
760
763
  ---------------
761
764
  EOM
762
765
 
763
766
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
764
- actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
767
+ actual.gsub!(RE_LEVELS, "") unless jruby?
765
768
 
766
769
  assert_equal expected, actual
767
770
  end
@@ -835,12 +838,12 @@ class TestMinitestAssertions < Minitest::Test
835
838
  Class: <AnError>
836
839
  Message: <\"some message\">
837
840
  ---Backtrace---
838
- FILE:LINE:in \`test_assert_raises_subclass_triggered\'
841
+ FILE:LINE:in \`block in test_assert_raises_subclass_triggered\'
839
842
  ---------------
840
843
  EOM
841
844
 
842
845
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
843
- actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
846
+ actual.gsub!(RE_LEVELS, "") unless jruby?
844
847
 
845
848
  assert_equal expected.chomp, actual
846
849
  end
@@ -857,12 +860,12 @@ class TestMinitestAssertions < Minitest::Test
857
860
  Class: <SyntaxError>
858
861
  Message: <\"icky\">
859
862
  ---Backtrace---
860
- FILE:LINE:in \`test_assert_raises_triggered_different\'
863
+ FILE:LINE:in \`block in test_assert_raises_triggered_different\'
861
864
  ---------------
862
865
  EOM
863
866
 
864
867
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
865
- actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
868
+ actual.gsub!(RE_LEVELS, "") unless jruby?
866
869
 
867
870
  assert_equal expected, actual
868
871
  end
@@ -880,12 +883,12 @@ class TestMinitestAssertions < Minitest::Test
880
883
  Class: <SyntaxError>
881
884
  Message: <\"icky\">
882
885
  ---Backtrace---
883
- FILE:LINE:in \`test_assert_raises_triggered_different_msg\'
886
+ FILE:LINE:in \`block in test_assert_raises_triggered_different_msg\'
884
887
  ---------------
885
888
  EOM
886
889
 
887
890
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
888
- actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
891
+ actual.gsub!(RE_LEVELS, "") unless jruby?
889
892
 
890
893
  assert_equal expected.chomp, actual
891
894
  end
@@ -995,9 +998,19 @@ class TestMinitestAssertions < Minitest::Test
995
998
  end
996
999
 
997
1000
  def test_assert_throws
998
- @tc.assert_throws :blah do
1001
+ v = @tc.assert_throws :blah do
999
1002
  throw :blah
1000
1003
  end
1004
+
1005
+ assert_nil v
1006
+ end
1007
+
1008
+ def test_assert_throws_value
1009
+ v = @tc.assert_throws :blah do
1010
+ throw :blah, 42
1011
+ end
1012
+
1013
+ assert_equal 42, v
1001
1014
  end
1002
1015
 
1003
1016
  def test_assert_throws_argument_exception
@@ -133,7 +133,7 @@ class TestMinitestMock < Minitest::Test
133
133
  @mock.expect :blah, 3, false
134
134
  end
135
135
 
136
- assert_equal "args must be an array", e.message
136
+ assert_match "args must be an array", e.message
137
137
  end
138
138
 
139
139
  def test_respond_appropriately
@@ -150,7 +150,7 @@ class TestMinitestMock < Minitest::Test
150
150
 
151
151
  expected = "unmocked method :bar, expected one of [:foo, :meaning_of_life]"
152
152
 
153
- assert_equal expected, e.message
153
+ assert_match expected, e.message
154
154
  end
155
155
 
156
156
  def test_assign_per_mock_return_values
@@ -309,7 +309,7 @@ class TestMinitestMock < Minitest::Test
309
309
 
310
310
  exp = "args ignored when block given"
311
311
 
312
- assert_equal exp, e.message
312
+ assert_match exp, e.message
313
313
  end
314
314
 
315
315
  def test_mock_returns_retval_when_called_with_block
@@ -499,7 +499,8 @@ class TestMinitestStub < Minitest::Test
499
499
  end
500
500
  end
501
501
 
502
- exp = /undefined method `nope_nope_nope' for( class)? `#{self.class}::Time'/
502
+ exp = jruby? ? /Undefined method nope_nope_nope for '#{self.class}::Time'/ :
503
+ /undefined method `nope_nope_nope' for( class)? `#{self.class}::Time'/
503
504
  assert_match exp, e.message
504
505
  end
505
506
 
@@ -822,7 +823,7 @@ class TestMinitestStub < Minitest::Test
822
823
  end
823
824
  end
824
825
  exp = "undefined method `write' for nil:NilClass"
825
- assert_equal exp, e.message
826
+ assert_match exp, e.message
826
827
  end
827
828
 
828
829
  def test_stub_value_block_args_6
@@ -1,5 +1,6 @@
1
1
  require "minitest/autorun"
2
2
  require "minitest/metametameta"
3
+ require "forwardable"
3
4
 
4
5
  class Runnable
5
6
  def woot
@@ -12,25 +13,18 @@ class TestMinitestReporter < MetaMetaMetaTestCase
12
13
  attr_accessor :r, :io
13
14
 
14
15
  def new_composite_reporter
16
+ # Ruby bug in older versions of 2.2 & 2.3 on all platforms
17
+ # Latest Windows builds were 2.2.6 and 2.3.3. Latest Ruby releases were
18
+ # 2.2.10 and 2.3.8.
19
+ skip if windows? && RUBY_VERSION < '2.4'
15
20
  reporter = Minitest::CompositeReporter.new
16
21
  reporter << Minitest::SummaryReporter.new(self.io)
17
22
  reporter << Minitest::ProgressReporter.new(self.io)
18
23
 
19
- def reporter.first
20
- reporters.first
21
- end
22
-
23
- def reporter.results
24
- first.results
25
- end
26
-
27
- def reporter.count
28
- first.count
29
- end
30
-
31
- def reporter.assertions
32
- first.assertions
33
- end
24
+ # eg reporter.results -> reporters.first.results
25
+ reporter.extend Forwardable
26
+ reporter.delegate :first => :reporters
27
+ reporter.delegate %i[results count assertions options to_s] => :first
34
28
 
35
29
  reporter
36
30
  end
@@ -86,7 +80,25 @@ class TestMinitestReporter < MetaMetaMetaTestCase
86
80
  def test_to_s
87
81
  r.record passing_test
88
82
  r.record fail_test
89
- assert_match "woot", r.first.to_s
83
+ assert_match "woot", r.to_s
84
+ end
85
+
86
+ def test_options_skip_F
87
+ r.options[:skip] = "F"
88
+
89
+ r.record passing_test
90
+ r.record fail_test
91
+
92
+ refute_match "woot", r.to_s
93
+ end
94
+
95
+ def test_options_skip_E
96
+ r.options[:skip] = "E"
97
+
98
+ r.record passing_test
99
+ r.record error_test
100
+
101
+ refute_match "RuntimeError: no", r.to_s
90
102
  end
91
103
 
92
104
  def test_passed_eh_empty
@@ -126,7 +138,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
126
138
  end
127
139
 
128
140
  def test_passed_eh_skipped_verbose
129
- r.first.options[:verbose] = true
141
+ r.options[:verbose] = true
130
142
 
131
143
  r.start
132
144
  r.results << skip_test
@@ -590,9 +590,10 @@ describe Minitest::Spec do
590
590
  end
591
591
 
592
592
  it "needs to verify throw" do
593
- @assertion_count += 2 # 2 extra tests
593
+ @assertion_count += 4 # 2 extra tests
594
594
 
595
- assert_success expect { throw :blah }.must_throw(:blah)
595
+ assert_nil expect { throw :blah }.must_throw(:blah)
596
+ assert_equal 42, expect { throw :blah, 42 }.must_throw(:blah)
596
597
 
597
598
  assert_triggered "Expected :blah to have been thrown." do
598
599
  expect {}.must_throw :blah
@@ -803,6 +803,25 @@ class TestMinitestRunnable < Minitest::Test
803
803
  assert_equal @tc.failures, over_the_wire.failures
804
804
  assert_equal @tc.klass, over_the_wire.klass
805
805
  end
806
+
807
+ def test_spec_marshal_with_exception
808
+ klass = describe("whatever") { it("passes") { raise Class.new(StandardError)} }
809
+ rm = klass.runnable_methods.first
810
+
811
+ # Run the test
812
+ @tc = klass.new(rm).run
813
+
814
+ assert_kind_of Minitest::Result, @tc
815
+
816
+ # Pass it over the wire
817
+ over_the_wire = Marshal.load Marshal.dump @tc
818
+
819
+ assert_equal @tc.time, over_the_wire.time
820
+ assert_equal @tc.name, over_the_wire.name
821
+ assert_equal @tc.assertions, over_the_wire.assertions
822
+ assert_equal @tc.failures, over_the_wire.failures
823
+ assert_equal @tc.klass, over_the_wire.klass
824
+ end
806
825
  end
807
826
 
808
827
  class TestMinitestTest < TestMinitestRunnable
@@ -848,19 +867,25 @@ class TestMinitestUnitTestCase < Minitest::Test
848
867
  $VERBOSE = orig_verbose
849
868
  end
850
869
 
870
+ def sample_test_case(rand)
871
+ srand rand
872
+ Class.new FakeNamedTest do
873
+ 100.times do |i|
874
+ define_method("test_#{i}") { assert true }
875
+ end
876
+ end.runnable_methods
877
+ end
878
+
879
+ # srand varies with OS
851
880
  def test_runnable_methods_random
852
881
  @assertion_count = 0
853
882
 
854
- sample_test_case = Class.new FakeNamedTest do
855
- def self.test_order; :random; end
856
- def test_test1; assert "does not matter" end
857
- def test_test2; assert "does not matter" end
858
- def test_test3; assert "does not matter" end
859
- end
883
+ random_tests_1 = sample_test_case 42
884
+ random_tests_2 = sample_test_case 42
885
+ random_tests_3 = sample_test_case 1_000
860
886
 
861
- srand 42
862
- expected = %w[test_test2 test_test1 test_test3]
863
- assert_equal expected, sample_test_case.runnable_methods
887
+ assert_equal random_tests_1, random_tests_2
888
+ refute_equal random_tests_1, random_tests_3
864
889
  end
865
890
 
866
891
  def test_runnable_methods_sorted
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.14.4
4
+ version: 5.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -29,7 +29,7 @@ cert_chain:
29
29
  d/AHw/kcnU6iuMUoJEcGiJd4gVCTn1l3cDcIvxakGslCA88Jubw0Sqatan0TnC9g
30
30
  KToW560QIey7SPfHWduzFJnV
31
31
  -----END CERTIFICATE-----
32
- date: 2021-02-24 00:00:00.000000000 Z
32
+ date: 2021-12-15 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rdoc
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  - !ruby/object:Gem::Version
182
182
  version: '0'
183
183
  requirements: []
184
- rubygems_version: 3.1.4
184
+ rubygems_version: 3.2.16
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: minitest provides a complete suite of testing facilities supporting TDD,
metadata.gz.sig CHANGED
Binary file