minitest 4.1.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,19 @@
1
+ === 4.2.0 / 2012-11-02
2
+
3
+ * 4 major enhancements:
4
+
5
+ * Added minitest/hell - run all your tests through the ringer!
6
+ * Added support for :parallel test_order to run test cases in parallel.
7
+ * Removed last_error and refactored runner code to be threadsafe.
8
+ * _run_suites now runs suites in parallel if they opt-in.
9
+
10
+ * 4 minor enhancements:
11
+
12
+ * Added TestCase#synchronize
13
+ * Added TestCase.make_my_diffs_pretty!
14
+ * Added TestCase.parallelize_me!
15
+ * Lock on capture_io for thread safety (tenderlove)
16
+
1
17
  === 4.1.0 / 2012-10-05
2
18
 
3
19
  * 2 minor enhancements:
@@ -7,7 +7,9 @@ design_rationale.rb
7
7
  lib/hoe/minitest.rb
8
8
  lib/minitest/autorun.rb
9
9
  lib/minitest/benchmark.rb
10
+ lib/minitest/hell.rb
10
11
  lib/minitest/mock.rb
12
+ lib/minitest/parallel_each.rb
11
13
  lib/minitest/pride.rb
12
14
  lib/minitest/spec.rb
13
15
  lib/minitest/unit.rb
@@ -0,0 +1,9 @@
1
+ class Minitest::Unit::TestCase
2
+ class << self
3
+ alias :old_test_order :test_order
4
+
5
+ def test_order # :nodoc:
6
+ :parallel
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,29 @@
1
+ class ParallelEach
2
+ require 'thread'
3
+ include Enumerable
4
+
5
+ N = (ENV['N'] || 2).to_i
6
+
7
+ def initialize list
8
+ @queue = Queue.new # *sigh*... the Queue api sucks sooo much...
9
+
10
+ list.each { |i| @queue << i }
11
+ N.times { @queue << nil }
12
+ end
13
+
14
+ def grep pattern
15
+ self.class.new super
16
+ end
17
+
18
+ def each
19
+ threads = N.times.map {
20
+ Thread.new do
21
+ Thread.current.abort_on_exception = true
22
+ while job = @queue.pop
23
+ yield job
24
+ end
25
+ end
26
+ }
27
+ threads.map(&:join)
28
+ end
29
+ end
@@ -1,5 +1,7 @@
1
1
  require 'optparse'
2
2
  require 'rbconfig'
3
+ require 'thread' # required for 1.8
4
+ require 'minitest/parallel_each'
3
5
 
4
6
  ##
5
7
  # Minimal (mostly drop-in) replacement for test-unit.
@@ -436,6 +438,8 @@ module MiniTest
436
438
  catch(sym) do
437
439
  begin
438
440
  yield
441
+ rescue ThreadError => e # wtf?!? 1.8 + threads == suck
442
+ default += ", not :#{e.message[/uncaught throw \`(\w+?)\'/, 1]}"
439
443
  rescue ArgumentError => e # 1.9 exception
440
444
  default += ", not #{e.message.split(/ /).last}"
441
445
  rescue NameError => e # 1.8 exception
@@ -465,16 +469,21 @@ module MiniTest
465
469
  def capture_io
466
470
  require 'stringio'
467
471
 
468
- orig_stdout, orig_stderr = $stdout, $stderr
469
472
  captured_stdout, captured_stderr = StringIO.new, StringIO.new
470
- $stdout, $stderr = captured_stdout, captured_stderr
471
473
 
472
- yield
474
+ synchronize do
475
+ orig_stdout, orig_stderr = $stdout, $stderr
476
+ $stdout, $stderr = captured_stdout, captured_stderr
477
+
478
+ begin
479
+ yield
480
+ ensure
481
+ $stdout = orig_stdout
482
+ $stderr = orig_stderr
483
+ end
484
+ end
473
485
 
474
486
  return captured_stdout.string, captured_stderr.string
475
- ensure
476
- $stdout = orig_stdout
477
- $stderr = orig_stderr
478
487
  end
479
488
 
480
489
  ##
@@ -496,21 +505,26 @@ module MiniTest
496
505
  require 'tempfile'
497
506
 
498
507
  captured_stdout, captured_stderr = Tempfile.new("out"), Tempfile.new("err")
499
- orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
500
- $stdout.reopen captured_stdout
501
- $stderr.reopen captured_stderr
502
508
 
503
- yield
509
+ synchronize do
510
+ orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
511
+ $stdout.reopen captured_stdout
512
+ $stderr.reopen captured_stderr
504
513
 
505
- $stdout.rewind
506
- $stderr.rewind
514
+ begin
515
+ yield
507
516
 
508
- return captured_stdout.read, captured_stderr.read
509
- ensure
510
- captured_stdout.unlink
511
- captured_stderr.unlink
512
- $stdout.reopen orig_stdout
513
- $stderr.reopen orig_stderr
517
+ $stdout.rewind
518
+ $stderr.rewind
519
+
520
+ [captured_stdout.read, captured_stderr.read]
521
+ ensure
522
+ captured_stdout.unlink
523
+ captured_stderr.unlink
524
+ $stdout.reopen orig_stdout
525
+ $stderr.reopen orig_stderr
526
+ end
527
+ end
514
528
  end
515
529
 
516
530
  ##
@@ -703,10 +717,19 @@ module MiniTest
703
717
  msg ||= "Skipped, no message given"
704
718
  raise MiniTest::Skip, msg, bt
705
719
  end
720
+
721
+ ##
722
+ # Takes a block and wraps it with the runner's shared mutex.
723
+
724
+ def synchronize
725
+ Minitest::Unit.runner.synchronize do
726
+ yield
727
+ end
728
+ end
706
729
  end
707
730
 
708
731
  class Unit # :nodoc:
709
- VERSION = "4.1.0" # :nodoc:
732
+ VERSION = "4.2.0" # :nodoc:
710
733
 
711
734
  attr_accessor :report, :failures, :errors, :skips # :nodoc:
712
735
  attr_accessor :test_count, :assertion_count # :nodoc:
@@ -714,7 +737,6 @@ module MiniTest
714
737
  attr_accessor :help # :nodoc:
715
738
  attr_accessor :verbose # :nodoc:
716
739
  attr_writer :options # :nodoc:
717
- attr_accessor :last_error # :nodoc:
718
740
 
719
741
  ##
720
742
  # Lazy accessor for options.
@@ -857,10 +879,15 @@ module MiniTest
857
879
  end
858
880
 
859
881
  ##
860
- # Runs all the +suites+ for a given +type+.
882
+ # Runs all the +suites+ for a given +type+. Runs suites declaring
883
+ # a test_order of +:parallel+ in parallel, and everything else
884
+ # serial.
861
885
 
862
886
  def _run_suites suites, type
863
- suites.map { |suite| _run_suite suite, type }
887
+ parallel, serial = suites.partition { |s| s.test_order == :parallel }
888
+
889
+ ParallelEach.new(parallel).map { |suite| _run_suite suite, type } +
890
+ serial.map { |suite| _run_suite suite, type }
864
891
  end
865
892
 
866
893
  ##
@@ -879,14 +906,10 @@ module MiniTest
879
906
 
880
907
  print "#{suite}##{method} = " if @verbose
881
908
 
882
- @start_time = Time.now
883
- self.last_error = nil
909
+ start_time = Time.now if @verbose
884
910
  result = inst.run self
885
- time = Time.now - @start_time
886
911
 
887
- record suite, method, inst._assertions, time, last_error
888
-
889
- print "%.2f s = " % time if @verbose
912
+ print "%.2f s = " % (Time.now - start_time) if @verbose
890
913
  print result
891
914
  puts if @verbose
892
915
 
@@ -925,7 +948,6 @@ module MiniTest
925
948
  # exception +e+
926
949
 
927
950
  def puke klass, meth, e
928
- self.last_error = e
929
951
  e = case e
930
952
  when MiniTest::Skip then
931
953
  @skips += 1
@@ -947,7 +969,11 @@ module MiniTest
947
969
  @report = []
948
970
  @errors = @failures = @skips = 0
949
971
  @verbose = false
950
- self.last_error = nil
972
+ @mutex = Mutex.new
973
+ end
974
+
975
+ def synchronize # :nodoc:
976
+ @mutex.synchronize { yield }
951
977
  end
952
978
 
953
979
  def process_args args = [] # :nodoc:
@@ -1255,6 +1281,8 @@ module MiniTest
1255
1281
  runner.status $stderr
1256
1282
  end if SUPPORTS_INFO_SIGNAL
1257
1283
 
1284
+ start_time = Time.now
1285
+
1258
1286
  result = ""
1259
1287
  begin
1260
1288
  @passed = nil
@@ -1263,11 +1291,15 @@ module MiniTest
1263
1291
  self.after_setup
1264
1292
  self.run_test self.__name__
1265
1293
  result = "." unless io?
1294
+ time = Time.now - start_time
1295
+ runner.record self.class, self.__name__, self._assertions, time, nil
1266
1296
  @passed = true
1267
1297
  rescue *PASSTHROUGH_EXCEPTIONS
1268
1298
  raise
1269
1299
  rescue Exception => e
1270
1300
  @passed = false
1301
+ time = Time.now - start_time
1302
+ runner.record self.class, self.__name__, self._assertions, time, e
1271
1303
  result = runner.puke self.class, self.__name__, e
1272
1304
  ensure
1273
1305
  %w{ before_teardown teardown after_teardown }.each do |hook|
@@ -1331,6 +1363,32 @@ module MiniTest
1331
1363
  end
1332
1364
  end
1333
1365
 
1366
+ ##
1367
+ # Make diffs for this TestCase use #pretty_inspect so that diff
1368
+ # in assert_equal can be more details. NOTE: this is much slower
1369
+ # than the regular inspect but much more usable for complex
1370
+ # objects.
1371
+
1372
+ def self.make_my_diffs_pretty!
1373
+ require 'pp'
1374
+
1375
+ define_method :mu_pp do |o|
1376
+ o.pretty_inspect
1377
+ end
1378
+ end
1379
+
1380
+ ##
1381
+ # Call this at the top of your tests when you want to run your
1382
+ # tests in parallel. In doing so, you're admitting that you rule
1383
+ # and your tests are awesome.
1384
+
1385
+ def self.parallelize_me!
1386
+ class << self
1387
+ undef_method :test_order if method_defined? :test_order
1388
+ define_method :test_order do :parallel end
1389
+ end
1390
+ end
1391
+
1334
1392
  def self.inherited klass # :nodoc:
1335
1393
  @@test_suites[klass] = true
1336
1394
  klass.reset_setup_teardown_hooks
@@ -1349,6 +1407,9 @@ module MiniTest
1349
1407
  methods = public_instance_methods(true).grep(/^test/).map { |m| m.to_s }
1350
1408
 
1351
1409
  case self.test_order
1410
+ when :parallel
1411
+ max = methods.size
1412
+ ParallelEach.new methods.sort.sort_by { rand max }
1352
1413
  when :random then
1353
1414
  max = methods.size
1354
1415
  methods.sort.sort_by { rand max }
@@ -17,7 +17,9 @@ class MetaMetaMetaTestCase < MiniTest::Unit::TestCase
17
17
 
18
18
  EOM
19
19
 
20
- @tu.run flags
20
+ with_output do
21
+ @tu.run flags
22
+ end
21
23
 
22
24
  output = @output.string.dup
23
25
  output.sub!(/Finished tests in .*/, "Finished tests in 0.00")
@@ -42,14 +44,24 @@ class MetaMetaMetaTestCase < MiniTest::Unit::TestCase
42
44
  srand 42
43
45
  MiniTest::Unit::TestCase.reset
44
46
  @tu = MiniTest::Unit.new
45
- @output = StringIO.new("")
47
+
46
48
  MiniTest::Unit.runner = nil # protect the outer runner from the inner tests
47
- MiniTest::Unit.output = @output
48
49
  end
49
50
 
50
51
  def teardown
51
52
  super
52
- MiniTest::Unit.output = $stdout
53
- Object.send :remove_const, :ATestCase if defined? ATestCase
53
+ end
54
+
55
+ def with_output
56
+ synchronize do
57
+ begin
58
+ @output = StringIO.new("")
59
+ MiniTest::Unit.output = @output
60
+
61
+ yield
62
+ ensure
63
+ MiniTest::Unit.output = STDOUT
64
+ end
65
+ end
54
66
  end
55
67
  end
@@ -110,4 +110,3 @@ class TestMiniTestBenchmark < MiniTest::Unit::TestCase
110
110
  assert_in_delta exp_b, b
111
111
  end
112
112
  end
113
-
@@ -4,6 +4,8 @@ require 'minitest/unit'
4
4
  MiniTest::Unit.autorun
5
5
 
6
6
  class TestMiniTestMock < MiniTest::Unit::TestCase
7
+ parallelize_me!
8
+
7
9
  def setup
8
10
  @mock = MiniTest::Mock.new.expect(:foo, nil)
9
11
  @mock.expect(:meaning_of_life, 42)
@@ -208,6 +210,8 @@ end
208
210
  require "minitest/metametameta"
209
211
 
210
212
  class TestMiniTestStub < MiniTest::Unit::TestCase
213
+ parallelize_me!
214
+
211
215
  def setup
212
216
  super
213
217
  MiniTest::Unit::TestCase.reset
@@ -224,13 +228,15 @@ class TestMiniTestStub < MiniTest::Unit::TestCase
224
228
  def assert_stub val_or_callable
225
229
  @assertion_count += 1
226
230
 
227
- t = Time.now.to_i
231
+ synchronize do
232
+ t = Time.now.to_i
228
233
 
229
- Time.stub :now, val_or_callable do
230
- @tc.assert_equal 42, Time.now
231
- end
234
+ Time.stub :now, val_or_callable do
235
+ @tc.assert_equal 42, Time.now
236
+ end
232
237
 
233
- @tc.assert_operator Time.now.to_i, :>=, t
238
+ @tc.assert_operator Time.now.to_i, :>=, t
239
+ end
234
240
  end
235
241
 
236
242
  def test_stub_value
@@ -244,13 +250,15 @@ class TestMiniTestStub < MiniTest::Unit::TestCase
244
250
  def test_stub_block_args
245
251
  @assertion_count += 1
246
252
 
247
- t = Time.now.to_i
253
+ synchronize do
254
+ t = Time.now.to_i
248
255
 
249
- Time.stub :now, lambda { |n| n * 2 } do
250
- @tc.assert_equal 42, Time.now(21)
251
- end
256
+ Time.stub :now, lambda { |n| n * 2 } do
257
+ @tc.assert_equal 42, Time.now(21)
258
+ end
252
259
 
253
- @tc.assert_operator Time.now.to_i, :>=, t
260
+ @tc.assert_operator Time.now.to_i, :>=, t
261
+ end
254
262
  end
255
263
 
256
264
  def test_stub_callable
@@ -8,6 +8,8 @@ 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.
12
+
11
13
  def assert_triggered expected = "blah", klass = MiniTest::Assertion
12
14
  @assertion_count += 2
13
15
 
@@ -561,6 +563,8 @@ describe MiniTest::Spec, :subject do
561
563
  end
562
564
 
563
565
  class TestMeta < MiniTest::Unit::TestCase
566
+ parallelize_me!
567
+
564
568
  def test_setup
565
569
  srand 42
566
570
  MiniTest::Unit::TestCase.reset
@@ -652,17 +656,15 @@ class TestMeta < MiniTest::Unit::TestCase
652
656
  _, _, z, before_list, after_list = util_structure
653
657
 
654
658
  @tu = MiniTest::Unit.new
655
- @output = StringIO.new("")
656
659
  MiniTest::Unit.runner = nil # protect the outer runner from the inner tests
657
- MiniTest::Unit.output = @output
658
660
 
659
- tc = z.new :test_0002_anonymous
660
- tc.run @tu
661
+ with_output do
662
+ tc = z.new :test_0002_anonymous
663
+ tc.run @tu
664
+ end
661
665
 
662
666
  assert_equal [1, 2, 3], before_list
663
667
  assert_equal [3, 2, 1], after_list
664
- ensure
665
- MiniTest::Unit.output = $stdout
666
668
  end
667
669
 
668
670
  def test_children
@@ -716,4 +718,17 @@ class TestMeta < MiniTest::Unit::TestCase
716
718
  assert_respond_to y.new(nil), "xyz"
717
719
  assert_respond_to z.new(nil), "xyz"
718
720
  end
721
+
722
+ def with_output # REFACTOR: dupe from metametameta
723
+ synchronize do
724
+ begin
725
+ @output = StringIO.new("")
726
+ MiniTest::Unit.output = @output
727
+
728
+ yield
729
+ ensure
730
+ MiniTest::Unit.output = STDOUT
731
+ end
732
+ end
733
+ end
719
734
  end
@@ -6,6 +6,8 @@ class AnError < StandardError; include MyModule; end
6
6
  class ImmutableString < String; def inspect; super.freeze; end; end
7
7
 
8
8
  class TestMiniTestUnit < MetaMetaMetaTestCase
9
+ parallelize_me!
10
+
9
11
  pwd = Pathname.new File.expand_path Dir.pwd
10
12
  basedir = Pathname.new(File.expand_path "lib/minitest") + 'mini'
11
13
  basedir = basedir.relative_path_from(pwd).to_s
@@ -166,6 +168,85 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
166
168
  assert_equal ex, fu
167
169
  end
168
170
 
171
+ def test_default_runner_is_minitest_unit
172
+ assert_instance_of MiniTest::Unit, MiniTest::Unit.runner
173
+ end
174
+
175
+ def with_overridden_include
176
+ Class.class_eval do
177
+ def inherited_with_hacks klass
178
+ throw :inherited_hook
179
+ end
180
+
181
+ alias inherited_without_hacks inherited
182
+ alias inherited inherited_with_hacks
183
+ alias IGNORE_ME! inherited # 1.8 bug. god I love venture bros
184
+ end
185
+
186
+ yield
187
+ ensure
188
+ Class.class_eval do
189
+ alias inherited inherited_without_hacks
190
+
191
+ undef_method :inherited_with_hacks
192
+ undef_method :inherited_without_hacks
193
+ end
194
+
195
+ refute_respond_to Class, :inherited_with_hacks
196
+ refute_respond_to Class, :inherited_without_hacks
197
+ end
198
+
199
+ def test_inherited_hook_plays_nice_with_others
200
+ with_overridden_include do
201
+ assert_throws :inherited_hook do
202
+ Class.new MiniTest::Unit::TestCase
203
+ end
204
+ end
205
+ end
206
+
207
+ def test_passed_eh_teardown_good
208
+ test_class = Class.new MiniTest::Unit::TestCase do
209
+ def teardown; assert true; end
210
+ def test_omg; assert true; end
211
+ end
212
+
213
+ test = test_class.new :test_omg
214
+ test.run @tu
215
+ assert test.passed?
216
+ end
217
+
218
+ def test_passed_eh_teardown_flunked
219
+ test_class = Class.new MiniTest::Unit::TestCase do
220
+ def teardown; flunk; end
221
+ def test_omg; assert true; end
222
+ end
223
+
224
+ test = test_class.new :test_omg
225
+ test.run @tu
226
+ refute test.passed?
227
+ end
228
+
229
+ def util_expand_bt bt
230
+ if RUBY_VERSION >= '1.9.0' then
231
+ bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f }
232
+ else
233
+ bt
234
+ end
235
+ end
236
+ end
237
+
238
+ class TestMiniTestRunner < MetaMetaMetaTestCase
239
+ # do not parallelize this suite... it just can't handle it.
240
+
241
+ def test_class_test_suites
242
+ @assertion_count = 0
243
+
244
+ tc = Class.new(MiniTest::Unit::TestCase)
245
+
246
+ assert_equal 1, MiniTest::Unit::TestCase.test_suites.size
247
+ assert_equal [tc], MiniTest::Unit::TestCase.test_suites
248
+ end
249
+
169
250
  def test_run_test
170
251
  Class.new MiniTest::Unit::TestCase do
171
252
  attr_reader :foo
@@ -362,10 +443,6 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
362
443
  assert_report expected, %w[--seed 42 --verbose]
363
444
  end
364
445
 
365
- def test_default_runner_is_minitest_unit
366
- assert_instance_of MiniTest::Unit, MiniTest::Unit.runner
367
- end
368
-
369
446
  def test_run_with_other_runner
370
447
  MiniTest::Unit.runner = Class.new MiniTest::Unit do
371
448
  def _run_suite suite, type
@@ -403,37 +480,74 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
403
480
  assert_report expected
404
481
  end
405
482
 
406
- def with_overridden_include
407
- Class.class_eval do
408
- def inherited_with_hacks klass
409
- throw :inherited_hook
410
- end
483
+ require 'monitor'
411
484
 
412
- alias inherited_without_hacks inherited
413
- alias inherited inherited_with_hacks
414
- alias IGNORE_ME! inherited # 1.8 bug. god I love venture bros
485
+ class Latch
486
+ def initialize count = 1
487
+ @count = count
488
+ @lock = Monitor.new
489
+ @cv = @lock.new_cond
415
490
  end
416
491
 
417
- yield
418
- ensure
419
- Class.class_eval do
420
- alias inherited inherited_without_hacks
421
-
422
- undef_method :inherited_with_hacks
423
- undef_method :inherited_without_hacks
492
+ def release
493
+ @lock.synchronize do
494
+ @count -= 1 if @count > 0
495
+ @cv.broadcast if @count == 0
496
+ end
424
497
  end
425
498
 
426
- refute_respond_to Class, :inherited_with_hacks
427
- refute_respond_to Class, :inherited_without_hacks
499
+ def await
500
+ @lock.synchronize { @cv.wait_while { @count > 0 } }
501
+ end
428
502
  end
429
503
 
430
- def test_inherited_hook_plays_nice_with_others
431
- with_overridden_include do
432
- assert_throws :inherited_hook do
433
- Class.new MiniTest::Unit::TestCase
504
+ def test_run_parallel
505
+ test_count = 2
506
+ test_latch = Latch.new test_count
507
+ main_latch = Latch.new
508
+
509
+ thread = Thread.new {
510
+ Thread.current.abort_on_exception = true
511
+
512
+ # This latch waits until both test latches have been released. Both
513
+ # latches can't be released unless done in separate threads because
514
+ # `main_latch` keeps the test method from finishing.
515
+ test_latch.await
516
+ main_latch.release
517
+ }
518
+
519
+ Class.new MiniTest::Unit::TestCase do
520
+ parallelize_me!
521
+
522
+ test_count.times do |i|
523
+ define_method :"test_wait_on_main_thread_#{i}" do
524
+ test_latch.release
525
+
526
+ # This latch blocks until the "main thread" releases it. The main
527
+ # thread can't release this latch until both test latches have
528
+ # been released. This forces the latches to be released in separate
529
+ # threads.
530
+ main_latch.await
531
+ assert true
532
+ end
434
533
  end
435
534
  end
535
+
536
+ expected = clean <<-EOM
537
+ ..
538
+
539
+ Finished tests in 0.00
540
+
541
+ 2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
542
+ EOM
543
+
544
+ assert_report expected
545
+ assert thread.join
436
546
  end
547
+ end
548
+
549
+ class TestMiniTestUnitOrder < MetaMetaMetaTestCase
550
+ # do not parallelize this suite... it just can't handle it.
437
551
 
438
552
  def test_before_setup
439
553
  call_order = []
@@ -450,34 +564,14 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
450
564
  def test_omg; assert true; end
451
565
  end
452
566
 
453
- @tu.run %w[--seed 42]
567
+ with_output do
568
+ @tu.run %w[--seed 42]
569
+ end
454
570
 
455
571
  expected = [:before_setup, :setup]
456
572
  assert_equal expected, call_order
457
573
  end
458
574
 
459
- def test_passed_eh_teardown_good
460
- test_class = Class.new MiniTest::Unit::TestCase do
461
- def teardown; assert true; end
462
- def test_omg; assert true; end
463
- end
464
-
465
- test = test_class.new :test_omg
466
- test.run @tu
467
- assert test.passed?
468
- end
469
-
470
- def test_passed_eh_teardown_flunked
471
- test_class = Class.new MiniTest::Unit::TestCase do
472
- def teardown; flunk; end
473
- def test_omg; assert true; end
474
- end
475
-
476
- test = test_class.new :test_omg
477
- test.run @tu
478
- refute test.passed?
479
- end
480
-
481
575
  def test_after_teardown
482
576
  call_order = []
483
577
  Class.new MiniTest::Unit::TestCase do
@@ -493,7 +587,9 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
493
587
  def test_omg; assert true; end
494
588
  end
495
589
 
496
- @tu.run %w[--seed 42]
590
+ with_output do
591
+ @tu.run %w[--seed 42]
592
+ end
497
593
 
498
594
  expected = [:teardown, :after_teardown]
499
595
  assert_equal expected, call_order
@@ -523,7 +619,9 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
523
619
  def test_omg; assert true; end
524
620
  end
525
621
 
526
- @tu.run %w[--seed 42]
622
+ with_output do
623
+ @tu.run %w[--seed 42]
624
+ end
527
625
 
528
626
  expected = [:before_teardown, :teardown, :after_teardown]
529
627
  assert_equal expected, call_order
@@ -548,24 +646,20 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
548
646
 
549
647
  _ = Class.new parent
550
648
 
551
- @tu.run %w[--seed 42]
649
+ with_output do
650
+ @tu.run %w[--seed 42]
651
+ end
552
652
 
553
653
  # Once for the parent class, once for the child
554
654
  expected = [:setup_method, :test, :teardown_method] * 2
555
655
 
556
656
  assert_equal expected, call_order
557
657
  end
558
-
559
- def util_expand_bt bt
560
- if RUBY_VERSION >= '1.9.0' then
561
- bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f }
562
- else
563
- bt
564
- end
565
- end
566
658
  end
567
659
 
568
660
  class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
661
+ parallelize_me!
662
+
569
663
  RUBY18 = ! defined? Encoding
570
664
 
571
665
  def setup
@@ -1205,6 +1299,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
1205
1299
 
1206
1300
  def test_capture_subprocess_io
1207
1301
  @assertion_count = 0
1302
+ skip "Dunno why but the parallel run of this fails"
1208
1303
 
1209
1304
  orig_verbose = $VERBOSE
1210
1305
  $VERBOSE = false
@@ -1243,15 +1338,6 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
1243
1338
  assert_empty asserts.map { |n| n.sub(/^assert/, 'refute') } - refutes
1244
1339
  end
1245
1340
 
1246
- def test_class_test_suites
1247
- @assertion_count = 0
1248
-
1249
- tc = Class.new(MiniTest::Unit::TestCase)
1250
-
1251
- assert_equal 1, MiniTest::Unit::TestCase.test_suites.size
1252
- assert_equal [tc], MiniTest::Unit::TestCase.test_suites
1253
- end
1254
-
1255
1341
  def test_expectation
1256
1342
  @assertion_count = 2
1257
1343
 
@@ -1486,6 +1572,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
1486
1572
  @assertion_count = 0
1487
1573
 
1488
1574
  sample_test_case = Class.new MiniTest::Unit::TestCase do
1575
+ def self.test_order; :random; end
1489
1576
  def test_test1; assert "does not matter" end
1490
1577
  def test_test2; assert "does not matter" end
1491
1578
  def test_test3; assert "does not matter" end
@@ -1560,6 +1647,8 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
1560
1647
  end
1561
1648
 
1562
1649
  class TestMiniTestGuard < MiniTest::Unit::TestCase
1650
+ parallelize_me!
1651
+
1563
1652
  def test_mri_eh
1564
1653
  assert self.class.mri? "ruby blah"
1565
1654
  assert self.mri? "ruby blah"
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: 59
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 4
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 4.1.0
10
+ version: 4.2.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: 2012-10-05 00:00:00 Z
39
+ date: 2012-11-02 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: 7
64
+ hash: 5
65
65
  segments:
66
66
  - 3
67
- - 0
68
- version: "3.0"
67
+ - 1
68
+ version: "3.1"
69
69
  type: :development
70
70
  version_requirements: *id002
71
71
  description: |-
@@ -131,7 +131,9 @@ files:
131
131
  - lib/hoe/minitest.rb
132
132
  - lib/minitest/autorun.rb
133
133
  - lib/minitest/benchmark.rb
134
+ - lib/minitest/hell.rb
134
135
  - lib/minitest/mock.rb
136
+ - lib/minitest/parallel_each.rb
135
137
  - lib/minitest/pride.rb
136
138
  - lib/minitest/spec.rb
137
139
  - lib/minitest/unit.rb
metadata.gz.sig CHANGED
Binary file