minitest 4.4.0 → 4.5.0

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.
data.tar.gz.sig CHANGED
Binary file
data/.autotest CHANGED
@@ -10,6 +10,7 @@ Autotest.add_hook :initialize do |at|
10
10
  at.extra_class_map["TestMeta"] = "test/test_minitest_spec.rb"
11
11
  at.extra_class_map["TestMiniTestUnitTestCase"] = "test/test_minitest_unit.rb"
12
12
  at.extra_class_map["TestMiniTestUnit"] = "test/test_minitest_unit.rb"
13
+ at.extra_class_map["TestMiniTestUnitRecording"]= "test/test_minitest_unit.rb"
13
14
  at.extra_class_map["TestMiniTestStub"] = "test/test_minitest_mock.rb"
14
15
  at.add_exception 'coverage.info'
15
16
  at.add_exception 'coverage'
data/History.txt CHANGED
@@ -1,3 +1,22 @@
1
+ === 4.5.0 / 2013-01-22
2
+
3
+ * 1 major enhancement:
4
+
5
+ * Rearranged minitest/unit.rb so NO parallelization code is loaded/used until you opt-in.
6
+
7
+ * 4 minor enhancements:
8
+
9
+ * Added TestCase#skipped? for teardown guards
10
+ * Added maglev? guard
11
+ * Document that record can be sent twice if teardown fails or errors (randycoulman)
12
+ * Errors in teardown are now recorded. (randycoulman)
13
+
14
+ * 3 bug fixes:
15
+
16
+ * Added hacks and skips to get clean test runs on maglev
17
+ * Modified float tests for maglev float output differences. Not sure this is right. Not sure I care.
18
+ * Test for existance of diff.exe instead of assuming they have devkit. (blowmage/Cumbayah)
19
+
1
20
  === 4.4.0 / 2013-01-07
2
21
 
3
22
  * 3 minor enhancements:
data/README.txt CHANGED
@@ -286,6 +286,7 @@ fixture loading:
286
286
  capybara_minitest_spec :: Bridge between Capybara RSpec matchers and MiniTest::Spec expectations (e.g. page.must_have_content('Title')).
287
287
  minispec-metadata :: Metadata for describe/it blocks
288
288
  (e.g. `it 'requires JS driver', js: true do`)
289
+ minitest-ansi :: Colorize minitest output with ANSI colors.
289
290
  minitest-around :: Around block for minitest. An alternative to setup/teardown dance.
290
291
  minitest-capistrano :: Assertions and expectations for testing Capistrano recipes
291
292
  minitest-capybara :: Capybara matchers support for minitest unit and spec
@@ -301,6 +302,7 @@ minitest-emoji :: Print out emoji for your test passes, fails, and skip
301
302
  minitest-excludes :: Clean API for excluding certain tests you
302
303
  don't want to run under certain conditions.
303
304
  minitest-firemock :: Makes your MiniTest mocks more resilient.
305
+ minitest-great_expectations :: Generally useful additions to minitest's assertions and expectations
304
306
  minitest-growl :: Test notifier for minitest via growl.
305
307
  minitest-instrument :: Instrument ActiveSupport::Notifications when
306
308
  test method is executed
@@ -312,11 +314,13 @@ minitest-matchers :: Adds support for RSpec-style matchers to minitest.
312
314
  minitest-metadata :: Annotate tests with metadata (key-value).
313
315
  minitest-mongoid :: Mongoid assertion matchers for MiniTest
314
316
  minitest-must_not :: Provides must_not as an alias for wont in MiniTest
317
+ minitest-nc :: Test notifier for minitest via Mountain Lion's Notification Center
315
318
  minitest-predicates :: Adds support for .predicate? methods
316
319
  minitest-rails :: MiniTest integration for Rails 3.x
317
320
  minitest-rails-capybara :: Capybara integration for MiniTest::Rails
318
321
  minitest-reporters :: Create customizable MiniTest output formats
319
322
  minitest-rg :: redgreen minitest
323
+ minitest-should_syntax :: RSpec-style +x.should == y+ assertions for MiniTest
320
324
  minitest-shouldify :: Adding all manner of shoulds to MiniTest (bad idea)
321
325
  minitest-spec-magic :: Minitest::Spec extensions for Rails and beyond
322
326
  minitest-spec-rails :: Drop in MiniTest::Spec superclass for ActiveSupport::TestCase.
@@ -344,7 +348,6 @@ Authors... Please send me a pull request with a description of your minitest ext
344
348
  * minitest-colorer
345
349
  * minitest-deluxe
346
350
  * minitest-extra-assertions
347
- * minitest-nc
348
351
  * minitest-rails-shoulda
349
352
  * minitest-spec
350
353
  * minitest-spec-context
data/lib/minitest/hell.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require "minitest/parallel_each"
2
+
1
3
  class Minitest::Unit::TestCase # :nodoc:
2
4
  class << self
3
5
  alias :old_test_order :test_order
@@ -43,3 +43,19 @@ class ParallelEach
43
43
  threads.map(&:join)
44
44
  end
45
45
  end
46
+
47
+ class MiniTest::Unit
48
+ alias _old_run_suites _run_suites
49
+
50
+ ##
51
+ # Runs all the +suites+ for a given +type+. Runs suites declaring
52
+ # a test_order of +:parallel+ in parallel, and everything else
53
+ # serial.
54
+
55
+ def _run_suites suites, type
56
+ parallel, serial = suites.partition { |s| s.test_order == :parallel }
57
+
58
+ ParallelEach.new(parallel).map { |suite| _run_suite suite, type } +
59
+ serial.map { |suite| _run_suite suite, type }
60
+ end
61
+ end
data/lib/minitest/unit.rb CHANGED
@@ -1,7 +1,5 @@
1
- require 'optparse'
2
- require 'rbconfig'
3
- require 'thread' # required for 1.8
4
- require 'minitest/parallel_each'
1
+ require "optparse"
2
+ require "rbconfig"
5
3
 
6
4
  ##
7
5
  # Minimal (mostly drop-in) replacement for test-unit.
@@ -83,16 +81,17 @@ module MiniTest
83
81
  # figure out what diff to use.
84
82
 
85
83
  def self.diff
86
- @diff = if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ then
84
+ @diff = if (RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ &&
85
+ system("diff.exe", __FILE__, __FILE__)) then
87
86
  "diff.exe -u"
87
+ elsif Minitest::Unit::Guard.maglev? then # HACK
88
+ "diff -u"
89
+ elsif system("gdiff", __FILE__, __FILE__)
90
+ "gdiff -u" # solaris and kin suck
91
+ elsif system("diff", __FILE__, __FILE__)
92
+ "diff -u"
88
93
  else
89
- if system("gdiff", __FILE__, __FILE__)
90
- "gdiff -u" # solaris and kin suck
91
- elsif system("diff", __FILE__, __FILE__)
92
- "diff -u"
93
- else
94
- nil
95
- end
94
+ nil
96
95
  end unless defined? @diff
97
96
 
98
97
  @diff
@@ -720,9 +719,14 @@ module MiniTest
720
719
 
721
720
  def skip msg = nil, bt = caller
722
721
  msg ||= "Skipped, no message given"
722
+ @skip = true
723
723
  raise MiniTest::Skip, msg, bt
724
724
  end
725
725
 
726
+ def skipped?
727
+ defined?(@skip) and @skip
728
+ end
729
+
726
730
  ##
727
731
  # Takes a block and wraps it with the runner's shared mutex.
728
732
 
@@ -734,7 +738,7 @@ module MiniTest
734
738
  end
735
739
 
736
740
  class Unit # :nodoc:
737
- VERSION = "4.4.0" # :nodoc:
741
+ VERSION = "4.5.0" # :nodoc:
738
742
 
739
743
  attr_accessor :report, :failures, :errors, :skips # :nodoc:
740
744
  attr_accessor :test_count, :assertion_count # :nodoc:
@@ -885,15 +889,13 @@ module MiniTest
885
889
  end
886
890
 
887
891
  ##
888
- # Runs all the +suites+ for a given +type+. Runs suites declaring
889
- # a test_order of +:parallel+ in parallel, and everything else
890
- # serial.
892
+ # Runs all the +suites+ for a given +type+.
893
+ #
894
+ # NOTE: this method is redefined in parallel_each.rb, which is
895
+ # loaded if a test-suite calls parallelize_me!.
891
896
 
892
897
  def _run_suites suites, type
893
- parallel, serial = suites.partition { |s| s.test_order == :parallel }
894
-
895
- ParallelEach.new(parallel).map { |suite| _run_suite suite, type } +
896
- serial.map { |suite| _run_suite suite, type }
898
+ suites.map { |suite| _run_suite suite, type }
897
899
  end
898
900
 
899
901
  ##
@@ -926,7 +928,7 @@ module MiniTest
926
928
  end
927
929
 
928
930
  ##
929
- # Record the result of a single run. Makes it very easy to gather
931
+ # Record the result of a single test. Makes it very easy to gather
930
932
  # information. Eg:
931
933
  #
932
934
  # class StatisticsRecorder < MiniTest::Unit
@@ -936,6 +938,11 @@ module MiniTest
936
938
  # end
937
939
  #
938
940
  # MiniTest::Unit.runner = StatisticsRecorder.new
941
+ #
942
+ # NOTE: record might be sent more than once per test. It will be
943
+ # sent once with the results from the test itself. If there is a
944
+ # failure or error in teardown, it will be sent again with the
945
+ # error or failure.
939
946
 
940
947
  def record suite, method, assertions, time, error
941
948
  end
@@ -975,11 +982,15 @@ module MiniTest
975
982
  @report = []
976
983
  @errors = @failures = @skips = 0
977
984
  @verbose = false
978
- @mutex = Mutex.new
985
+ @mutex = Mutex.new if defined?(Mutex)
979
986
  end
980
987
 
981
988
  def synchronize # :nodoc:
982
- @mutex.synchronize { yield }
989
+ if @mutex then
990
+ @mutex.synchronize { yield }
991
+ else
992
+ yield
993
+ end
983
994
  end
984
995
 
985
996
  def process_args args = [] # :nodoc:
@@ -1092,6 +1103,15 @@ module MiniTest
1092
1103
  ##
1093
1104
  # Is this running on mri?
1094
1105
 
1106
+ def maglev? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
1107
+ "maglev" == platform
1108
+ end
1109
+
1110
+ module_function :maglev?
1111
+
1112
+ ##
1113
+ # Is this running on mri?
1114
+
1095
1115
  def mri? platform = RUBY_DESCRIPTION
1096
1116
  /^ruby/ =~ platform
1097
1117
  end
@@ -1315,6 +1335,7 @@ module MiniTest
1315
1335
  raise
1316
1336
  rescue Exception => e
1317
1337
  @passed = false
1338
+ runner.record self.class, self.__name__, self._assertions, time, e
1318
1339
  result = runner.puke self.class, self.__name__, e
1319
1340
  end
1320
1341
  end
@@ -1389,6 +1410,8 @@ module MiniTest
1389
1410
  # and your tests are awesome.
1390
1411
 
1391
1412
  def self.parallelize_me!
1413
+ require "minitest/parallel_each"
1414
+
1392
1415
  class << self
1393
1416
  undef_method :test_order if method_defined? :test_order
1394
1417
  define_method :test_order do :parallel end
@@ -1,7 +1,4 @@
1
- require 'minitest/mock'
2
- require 'minitest/unit'
3
-
4
- MiniTest::Unit.autorun
1
+ require 'minitest/autorun'
5
2
 
6
3
  class TestMiniTestMock < MiniTest::Unit::TestCase
7
4
  parallelize_me!
@@ -67,6 +64,8 @@ class TestMiniTestMock < MiniTest::Unit::TestCase
67
64
  end
68
65
 
69
66
  def test_mock_args_does_not_raise
67
+ skip "non-opaque use of ==" if maglev?
68
+
70
69
  arg = MiniTest::Mock.new
71
70
  mock = MiniTest::Mock.new
72
71
  mock.expect(:foo, nil, [arg])
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
- require 'minitest/autorun'
3
- require 'stringio'
2
+ require "minitest/autorun"
3
+ require "stringio"
4
4
 
5
5
  class MiniSpecA < MiniTest::Spec; end
6
6
  class MiniSpecB < MiniTest::Spec; end
@@ -8,7 +8,7 @@ class ExampleA; end
8
8
  class ExampleB < ExampleA; end
9
9
 
10
10
  describe MiniTest::Spec do
11
- # do not parallelize this suite... it just can't handle it.
11
+ # do not parallelize this suite... it just can"t handle it.
12
12
 
13
13
  def assert_triggered expected = "blah", klass = MiniTest::Assertion
14
14
  @assertion_count += 2
@@ -18,7 +18,7 @@ describe MiniTest::Spec do
18
18
  end
19
19
 
20
20
  msg = e.message.sub(/(---Backtrace---).*/m, '\1')
21
- msg.gsub!(/\(oid=[-0-9]+\)/, '(oid=N)')
21
+ msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
22
22
 
23
23
  assert_equal expected, msg
24
24
  end
@@ -28,7 +28,7 @@ describe MiniTest::Spec do
28
28
  end
29
29
 
30
30
  after do
31
- self._assertions.must_equal @assertion_count
31
+ self._assertions.must_equal @assertion_count if passed? and not skipped?
32
32
  end
33
33
 
34
34
  it "needs to be able to catch a MiniTest::Assertion exception" do
@@ -77,10 +77,10 @@ describe MiniTest::Spec do
77
77
  it "needs to catch an unexpected exception" do
78
78
  @assertion_count -= 2 # no positive
79
79
 
80
- msg = <<-EOM.gsub(/^ {6}/, '').chomp
80
+ msg = <<-EOM.gsub(/^ {6}/, "").chomp
81
81
  [RuntimeError] exception expected, not
82
82
  Class: <MiniTest::Assertion>
83
- Message: <\"MiniTest::Assertion\">
83
+ Message: <"MiniTest::Assertion">
84
84
  ---Backtrace---
85
85
  EOM
86
86
 
@@ -133,7 +133,7 @@ describe MiniTest::Spec do
133
133
 
134
134
  bad = %w[not raise throw send output be_silent]
135
135
 
136
- expected_wonts = expected_musts.map { |m| m.sub(/^must/, 'wont') }
136
+ expected_wonts = expected_musts.map { |m| m.sub(/^must/, "wont") }
137
137
  expected_wonts.reject! { |m| m =~ /wont_#{Regexp.union(*bad)}/ }
138
138
 
139
139
  musts.must_equal expected_musts
@@ -155,7 +155,7 @@ describe MiniTest::Spec do
155
155
  it "needs to verify binary messages" do
156
156
  42.wont_be(:<, 24).must_equal false
157
157
 
158
- assert_triggered 'Expected 24 to not be < 42.' do
158
+ assert_triggered "Expected 24 to not be < 42." do
159
159
  24.wont_be :<, 42
160
160
  end
161
161
 
@@ -195,15 +195,16 @@ describe MiniTest::Spec do
195
195
 
196
196
  24.wont_be_close_to(42).must_equal false
197
197
 
198
- assert_triggered 'Expected |42 - 42.0| (0.0) to not be < 0.001.' do
198
+ assert_triggered "Expected |42 - 42.0| (0.0) to not be < 0.001." do
199
199
  (6 * 7.0).wont_be_close_to 42
200
200
  end
201
201
 
202
- assert_triggered 'Expected |42 - 42.0| (0.0) to not be < 1.0e-05.' do
202
+ x = maglev? ? "1.0000000000000001e-05" : "1.0e-05"
203
+ assert_triggered "Expected |42 - 42.0| (0.0) to not be < #{x}." do
203
204
  (6 * 7.0).wont_be_close_to 42, 0.00001
204
205
  end
205
206
 
206
- assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be < 1.0e-05." do
207
+ assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be < #{x}." do
207
208
  (6 * 7.0).wont_be_close_to 42, 0.00001, "msg"
208
209
  end
209
210
  end
@@ -213,15 +214,17 @@ describe MiniTest::Spec do
213
214
 
214
215
  24.wont_be_within_epsilon(42).must_equal false
215
216
 
216
- assert_triggered 'Expected |42 - 42.0| (0.0) to not be < 0.042.' do
217
+ x = maglev? ? "0.042000000000000003" : "0.042"
218
+ assert_triggered "Expected |42 - 42.0| (0.0) to not be < #{x}." do
217
219
  (6 * 7.0).wont_be_within_epsilon 42
218
220
  end
219
221
 
220
- assert_triggered 'Expected |42 - 42.0| (0.0) to not be < 0.00042.' do
222
+ x = maglev? ? "0.00042000000000000002" : "0.00042"
223
+ assert_triggered "Expected |42 - 42.0| (0.0) to not be < #{x}." do
221
224
  (6 * 7.0).wont_be_within_epsilon 42, 0.00001
222
225
  end
223
226
 
224
- assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be < 0.00042." do
227
+ assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be < #{x}." do
225
228
  (6 * 7.0).wont_be_within_epsilon 42, 0.00001, "msg"
226
229
  end
227
230
  end
@@ -231,15 +234,16 @@ describe MiniTest::Spec do
231
234
 
232
235
  (6.0 * 7).must_be_close_to(42.0).must_equal true
233
236
 
234
- assert_triggered 'Expected |0.0 - 0.01| (0.01) to be < 0.001.' do
237
+ assert_triggered "Expected |0.0 - 0.01| (0.01) to be < 0.001." do
235
238
  (1.0 / 100).must_be_close_to 0.0
236
239
  end
237
240
 
238
- assert_triggered 'Expected |0.0 - 0.001| (0.001) to be < 1.0e-06.' do
241
+ x = maglev? ? "9.9999999999999995e-07" : "1.0e-06"
242
+ assert_triggered "Expected |0.0 - 0.001| (0.001) to be < #{x}." do
239
243
  (1.0 / 1000).must_be_close_to 0.0, 0.000001
240
244
  end
241
245
 
242
- assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be < 1.0e-06." do
246
+ assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be < #{x}." do
243
247
  (1.0 / 1000).must_be_close_to 0.0, 0.000001, "msg"
244
248
  end
245
249
  end
@@ -249,11 +253,11 @@ describe MiniTest::Spec do
249
253
 
250
254
  (6.0 * 7).must_be_within_epsilon(42.0).must_equal true
251
255
 
252
- assert_triggered 'Expected |0.0 - 0.01| (0.01) to be < 0.0.' do
256
+ assert_triggered "Expected |0.0 - 0.01| (0.01) to be < 0.0." do
253
257
  (1.0 / 100).must_be_within_epsilon 0.0
254
258
  end
255
259
 
256
- assert_triggered 'Expected |0.0 - 0.001| (0.001) to be < 0.0.' do
260
+ assert_triggered "Expected |0.0 - 0.001| (0.001) to be < 0.0." do
257
261
  (1.0 / 1000).must_be_within_epsilon 0.0, 0.000001
258
262
  end
259
263
 
@@ -289,7 +293,7 @@ describe MiniTest::Spec do
289
293
  it "needs to verify instances of a class" do
290
294
  42.wont_be_instance_of(String).must_equal false
291
295
 
292
- assert_triggered 'Expected 42 to not be an instance of Fixnum.' do
296
+ assert_triggered "Expected 42 to not be an instance of Fixnum." do
293
297
  42.wont_be_instance_of Fixnum
294
298
  end
295
299
 
@@ -301,7 +305,7 @@ describe MiniTest::Spec do
301
305
  it "needs to verify kinds of a class" do
302
306
  42.wont_be_kind_of(String).must_equal false
303
307
 
304
- assert_triggered 'Expected 42 to not be a kind of Integer.' do
308
+ assert_triggered "Expected 42 to not be a kind of Integer." do
305
309
  42.wont_be_kind_of Integer
306
310
  end
307
311
 
@@ -354,7 +358,7 @@ describe MiniTest::Spec do
354
358
  it "needs to verify non-emptyness" do
355
359
  @assertion_count += 3 # empty is 2 assertions
356
360
 
357
- ['some item'].wont_be_empty.must_equal false
361
+ ["some item"].wont_be_empty.must_equal false
358
362
 
359
363
  assert_triggered "Expected [] to not be empty." do
360
364
  [].wont_be_empty
@@ -392,7 +396,7 @@ describe MiniTest::Spec do
392
396
  it "needs to verify objects not responding to a message" do
393
397
  "".wont_respond_to(:woot!).must_equal false
394
398
 
395
- assert_triggered 'Expected "" to not respond to to_s.' do
399
+ assert_triggered "Expected \"\" to not respond to to_s." do
396
400
  "".wont_respond_to :to_s
397
401
  end
398
402
 
@@ -472,7 +476,7 @@ describe MiniTest::Spec do
472
476
  end
473
477
 
474
478
  it "needs to verify using any (negative) predicate" do
475
- @assertion_count -= 1 # doesn't take a message
479
+ @assertion_count -= 1 # doesn"t take a message
476
480
 
477
481
  "blah".wont_be(:empty?).must_equal false
478
482
 
@@ -693,7 +697,7 @@ class TestMeta < MiniTest::Unit::TestCase
693
697
  z = describe "second thingy" do end
694
698
  end
695
699
 
696
- test_methods = ['test_0001_top level it', 'test_0002_не латинские буквы-и-спецсимволы&いった α, β, γ, δ, ε hello!!! world'].sort
700
+ test_methods = ["test_0001_top level it", "test_0002_не латинские буквы-и-спецсимволы&いった α, β, γ, δ, ε hello!!! world"].sort
697
701
 
698
702
  assert_equal test_methods, [x1, x2]
699
703
  assert_equal test_methods,
@@ -729,3 +733,48 @@ class TestMeta < MiniTest::Unit::TestCase
729
733
  end
730
734
  end
731
735
  end
736
+
737
+ require "minitest/metametameta"
738
+
739
+ class TestSpecInTestCase < MetaMetaMetaTestCase
740
+ def setup
741
+ super
742
+
743
+ @tc = MiniTest::Unit::TestCase.new "fake tc"
744
+ @assertion_count = 1
745
+ end
746
+
747
+ def util_assert_triggered expected, klass = MiniTest::Assertion # REFACTOR
748
+ e = assert_raises klass do
749
+ yield
750
+ end
751
+
752
+ msg = e.message.sub(/(---Backtrace---).*/m, "\1")
753
+ msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
754
+
755
+ assert_equal expected, msg
756
+ end
757
+
758
+ def teardown # REFACTOR
759
+ assert_equal(@assertion_count, @tc._assertions,
760
+ "expected #{@assertion_count} assertions to be fired during the test, not #{@tc._assertions}") if @tc.passed?
761
+ end
762
+
763
+ def test_expectation
764
+ @assertion_count = 2
765
+
766
+ @tc.assert_equal true, 1.must_equal(1)
767
+ end
768
+
769
+ def test_expectation_triggered
770
+ util_assert_triggered "Expected: 2\n Actual: 1" do
771
+ 1.must_equal 2
772
+ end
773
+ end
774
+
775
+ def test_expectation_with_a_message
776
+ util_assert_triggered "Expected: 2\n Actual: 1" do
777
+ 1.must_equal 2, ""
778
+ end
779
+ end
780
+ end
@@ -306,7 +306,7 @@ class TestMiniTestRunner < MetaMetaMetaTestCase
306
306
  1) Error:
307
307
  test_error(#<Class:0xXXX>):
308
308
  RuntimeError: unhandled exception
309
- FILE:LINE:in `test_error'
309
+ FILE:LINE:in \`test_error\'
310
310
 
311
311
  2 tests, 1 assertions, 0 failures, 1 errors, 0 skips
312
312
  EOM
@@ -333,7 +333,7 @@ class TestMiniTestRunner < MetaMetaMetaTestCase
333
333
  1) Error:
334
334
  test_something(#<Class:0xXXX>):
335
335
  RuntimeError: unhandled exception
336
- FILE:LINE:in `teardown'
336
+ FILE:LINE:in \`teardown\'
337
337
 
338
338
  1 tests, 1 assertions, 0 failures, 1 errors, 0 skips
339
339
  EOM
@@ -516,6 +516,8 @@ class TestMiniTestRunner < MetaMetaMetaTestCase
516
516
  end
517
517
 
518
518
  def test_run_parallel
519
+ skip "I don't have ParallelEach debugged yet" if maglev?
520
+
519
521
  test_count = 2
520
522
  test_latch = Latch.new test_count
521
523
  main_latch = Latch.new
@@ -644,12 +646,12 @@ class TestMiniTestUnitOrder < MetaMetaMetaTestCase
644
646
  def test_setup_and_teardown_survive_inheritance
645
647
  call_order = []
646
648
 
647
- parent = Class.new MiniTest::Spec do
648
- before do
649
+ parent = Class.new MiniTest::Unit::TestCase do
650
+ define_method :setup do
649
651
  call_order << :setup_method
650
652
  end
651
653
 
652
- after do
654
+ define_method :teardown do
653
655
  call_order << :teardown_method
654
656
  end
655
657
 
@@ -690,7 +692,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
690
692
 
691
693
  def teardown
692
694
  assert_equal(@assertion_count, @tc._assertions,
693
- "expected #{@assertion_count} assertions to be fired during the test, not #{@tc._assertions}") if @tc._assertions
695
+ "expected #{@assertion_count} assertions to be fired during the test, not #{@tc._assertions}") if @tc.passed?
694
696
  end
695
697
 
696
698
  def non_verbose
@@ -787,6 +789,8 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
787
789
  end
788
790
 
789
791
  def test_assert_equal_different_diff_deactivated
792
+ skip "https://github.com/MagLev/maglev/issues/209" if maglev?
793
+
790
794
  without_diff do
791
795
  util_assert_triggered util_msg("haha" * 10, "blah" * 10) do
792
796
  o1 = "haha" * 10
@@ -900,7 +904,8 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
900
904
  end
901
905
 
902
906
  def test_assert_in_delta_triggered
903
- util_assert_triggered 'Expected |0.0 - 0.001| (0.001) to be < 1.0e-06.' do
907
+ x = maglev? ? "9.9999999999999995e-07" : "1.0e-06"
908
+ util_assert_triggered "Expected |0.0 - 0.001| (0.001) to be < #{x}." do
904
909
  @tc.assert_in_delta 0.0, 1.0 / 1000, 0.000001
905
910
  end
906
911
  end
@@ -929,8 +934,9 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
929
934
  end
930
935
 
931
936
  def test_assert_in_epsilon_triggered_negative_case
932
- x = RUBY18 ? "0.1" : "0.10000000000000009"
933
- util_assert_triggered "Expected |-1.1 - -1| (#{x}) to be < 0.1." do
937
+ x = (RUBY18 and not maglev?) ? "0.1" : "0.10000000000000009"
938
+ y = maglev? ? "0.10000000000000001" : "0.1"
939
+ util_assert_triggered "Expected |-1.1 - -1| (#{x}) to be < #{y}." do
934
940
  @tc.assert_in_epsilon(-1.1, -1, 0.1)
935
941
  end
936
942
  end
@@ -1158,7 +1164,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
1158
1164
  Class: <SyntaxError>
1159
1165
  Message: <\"icky\">
1160
1166
  ---Backtrace---
1161
- FILE:LINE:in `test_assert_raises_triggered_different'
1167
+ FILE:LINE:in \`test_assert_raises_triggered_different\'
1162
1168
  ---------------
1163
1169
  EOM
1164
1170
 
@@ -1181,7 +1187,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
1181
1187
  Class: <SyntaxError>
1182
1188
  Message: <\"icky\">
1183
1189
  ---Backtrace---
1184
- FILE:LINE:in `test_assert_raises_triggered_different_msg'
1190
+ FILE:LINE:in \`test_assert_raises_triggered_different_msg\'
1185
1191
  ---------------
1186
1192
  EOM
1187
1193
 
@@ -1227,7 +1233,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
1227
1233
  Class: <AnError>
1228
1234
  Message: <\"AnError\">
1229
1235
  ---Backtrace---
1230
- FILE:LINE:in `test_assert_raises_triggered_subclass'
1236
+ FILE:LINE:in \`test_assert_raises_triggered_subclass\'
1231
1237
  ---------------
1232
1238
  EOM
1233
1239
 
@@ -1335,7 +1341,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
1335
1341
  non_verbose do
1336
1342
  out, err = capture_io do
1337
1343
  puts 'hi'
1338
- warn 'bye!'
1344
+ $stderr.puts 'bye!'
1339
1345
  end
1340
1346
 
1341
1347
  assert_equal "hi\n", out
@@ -1381,24 +1387,6 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
1381
1387
  assert_empty asserts.map { |n| n.sub(/^assert/, 'refute') } - refutes
1382
1388
  end
1383
1389
 
1384
- def test_expectation
1385
- @assertion_count = 2
1386
-
1387
- @tc.assert_equal true, 1.must_equal(1)
1388
- end
1389
-
1390
- def test_expectation_triggered
1391
- util_assert_triggered "Expected: 2\n Actual: 1" do
1392
- 1.must_equal 2
1393
- end
1394
- end
1395
-
1396
- def test_expectation_with_a_message
1397
- util_assert_triggered "Expected: 2\n Actual: 1" do
1398
- 1.must_equal 2, ''
1399
- end
1400
- end
1401
-
1402
1390
  def test_flunk
1403
1391
  util_assert_triggered 'Epic Fail!' do
1404
1392
  @tc.flunk
@@ -1494,7 +1482,8 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
1494
1482
  end
1495
1483
 
1496
1484
  def test_refute_in_delta_triggered
1497
- util_assert_triggered 'Expected |0.0 - 0.001| (0.001) to not be < 0.1.' do
1485
+ x = maglev? ? "0.10000000000000001" : "0.1"
1486
+ util_assert_triggered "Expected |0.0 - 0.001| (0.001) to not be < #{x}." do
1498
1487
  @tc.refute_in_delta 0.0, 1.0 / 1000, 0.1
1499
1488
  end
1500
1489
  end
@@ -1652,7 +1641,12 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
1652
1641
  end
1653
1642
 
1654
1643
  srand 42
1655
- expected = %w(test_test2 test_test1 test_test3)
1644
+ expected = case
1645
+ when maglev? then
1646
+ %w(test_test2 test_test3 test_test1)
1647
+ else
1648
+ %w(test_test2 test_test1 test_test3)
1649
+ end
1656
1650
  assert_equal expected, sample_test_case.test_methods
1657
1651
  end
1658
1652
 
@@ -1742,3 +1736,85 @@ class TestMiniTestGuard < MiniTest::Unit::TestCase
1742
1736
  assert self.windows? "mswin"
1743
1737
  end
1744
1738
  end
1739
+
1740
+ class TestMiniTestUnitRecording < MetaMetaMetaTestCase
1741
+ # do not parallelize this suite... it just can't handle it.
1742
+
1743
+ def assert_run_record(*expected, &block)
1744
+ def @tu.record suite, method, assertions, time, error
1745
+ recording[method] << error
1746
+ end
1747
+
1748
+ def @tu.recording
1749
+ @recording ||= Hash.new { |h,k| h[k] = [] }
1750
+ end
1751
+
1752
+ MiniTest::Unit.runner = @tu
1753
+
1754
+ Class.new MiniTest::Unit::TestCase, &block
1755
+
1756
+ with_output do
1757
+ @tu.run
1758
+ end
1759
+
1760
+ recorded = @tu.recording.fetch("test_method").map(&:class)
1761
+
1762
+ assert_equal expected, recorded
1763
+ end
1764
+
1765
+ def test_record_passing
1766
+ assert_run_record NilClass do
1767
+ def test_method
1768
+ assert true
1769
+ end
1770
+ end
1771
+ end
1772
+
1773
+ def test_record_failing
1774
+ assert_run_record MiniTest::Assertion do
1775
+ def test_method
1776
+ assert false
1777
+ end
1778
+ end
1779
+ end
1780
+
1781
+ def test_record_error
1782
+ assert_run_record RuntimeError do
1783
+ def test_method
1784
+ raise "unhandled exception"
1785
+ end
1786
+ end
1787
+ end
1788
+
1789
+ def test_record_error_teardown
1790
+ assert_run_record NilClass, RuntimeError do
1791
+ def test_method
1792
+ assert true
1793
+ end
1794
+
1795
+ def teardown
1796
+ raise "unhandled exception"
1797
+ end
1798
+ end
1799
+ end
1800
+
1801
+ def test_record_error_in_test_and_teardown
1802
+ assert_run_record AnError, RuntimeError do
1803
+ def test_method
1804
+ raise AnError
1805
+ end
1806
+
1807
+ def teardown
1808
+ raise "unhandled exception"
1809
+ end
1810
+ end
1811
+ end
1812
+
1813
+ def test_record_skip
1814
+ assert_run_record MiniTest::Skip do
1815
+ def test_method
1816
+ skip "not yet"
1817
+ end
1818
+ end
1819
+ end
1820
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest
3
3
  version: !ruby/object:Gem::Version
4
- hash: 47
4
+ hash: 43
5
5
  prerelease:
6
6
  segments:
7
7
  - 4
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 4.4.0
10
+ version: 4.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Davis
@@ -36,7 +36,7 @@ cert_chain:
36
36
  FBHgymkyj/AOSqKRIpXPhjC6
37
37
  -----END CERTIFICATE-----
38
38
 
39
- date: 2013-01-08 00:00:00 Z
39
+ date: 2013-01-23 00:00:00 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
@@ -61,11 +61,11 @@ dependencies:
61
61
  requirements:
62
62
  - - ~>
63
63
  - !ruby/object:Gem::Version
64
- hash: 15
64
+ hash: 13
65
65
  segments:
66
66
  - 3
67
- - 4
68
- version: "3.4"
67
+ - 5
68
+ version: "3.5"
69
69
  type: :development
70
70
  version_requirements: *id002
71
71
  description: |-
metadata.gz.sig CHANGED
Binary file