minitest 2.8.1 → 2.9.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 +0 -0
- data/.autotest +3 -3
- data/History.txt +9 -0
- data/Manifest.txt +3 -0
- data/README.txt +3 -0
- data/lib/hoe/minitest.rb +5 -0
- data/lib/minitest/benchmark.rb +10 -3
- data/lib/minitest/excludes.rb +76 -0
- data/lib/minitest/mock.rb +2 -1
- data/lib/minitest/pride.rb +25 -6
- data/lib/minitest/spec.rb +13 -1
- data/lib/minitest/unit.rb +80 -8
- data/test/metametameta.rb +43 -0
- data/test/test_minitest_excludes.rb +54 -0
- data/test/test_minitest_spec.rb +1 -1
- data/test/test_minitest_unit.rb +47 -54
- metadata +20 -16
- metadata.gz.sig +2 -1
data.tar.gz.sig
CHANGED
Binary file
|
data/.autotest
CHANGED
@@ -5,9 +5,9 @@ require 'autotest/restart'
|
|
5
5
|
Autotest.add_hook :initialize do |at|
|
6
6
|
at.testlib = 'minitest/unit'
|
7
7
|
|
8
|
-
at.extra_class_map["MiniSpec"] = "test/
|
9
|
-
at.extra_class_map["TestMiniTestTestCase"] = "test/
|
10
|
-
|
8
|
+
at.extra_class_map["MiniSpec"] = "test/test_minitest_spec.rb"
|
9
|
+
at.extra_class_map["TestMiniTestTestCase"] = "test/test_minitest_unit.rb"
|
10
|
+
at.extra_class_map["TestMiniTestUnit"] = "test/test_minitest_unit.rb"
|
11
11
|
at.add_exception 'coverage.info'
|
12
12
|
at.add_exception 'coverage'
|
13
13
|
end
|
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
=== 2.9.0 / 2011-12-07
|
2
|
+
|
3
|
+
* 4 minor enhancements:
|
4
|
+
|
5
|
+
* Added TestCase.exclude and load_excludes for programmatic filtering of tests.
|
6
|
+
* Added guard methods so you can cleanly skip based on platform/impl
|
7
|
+
* Holy crap! 100% doco! `rdoc -C` ftw
|
8
|
+
* Switch assert_output to test stderr before stdout to possibly improve debugging
|
9
|
+
|
1
10
|
=== 2.8.1 / 2011-11-17
|
2
11
|
|
3
12
|
* 1 bug fix:
|
data/Manifest.txt
CHANGED
@@ -7,11 +7,14 @@ design_rationale.rb
|
|
7
7
|
lib/hoe/minitest.rb
|
8
8
|
lib/minitest/autorun.rb
|
9
9
|
lib/minitest/benchmark.rb
|
10
|
+
lib/minitest/excludes.rb
|
10
11
|
lib/minitest/mock.rb
|
11
12
|
lib/minitest/pride.rb
|
12
13
|
lib/minitest/spec.rb
|
13
14
|
lib/minitest/unit.rb
|
15
|
+
test/metametameta.rb
|
14
16
|
test/test_minitest_benchmark.rb
|
17
|
+
test/test_minitest_excludes.rb
|
15
18
|
test/test_minitest_mock.rb
|
16
19
|
test/test_minitest_spec.rb
|
17
20
|
test/test_minitest_unit.rb
|
data/README.txt
CHANGED
@@ -117,6 +117,9 @@ Given that you'd like to test the following class:
|
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
+
For matchers support check out:
|
121
|
+
https://github.com/zenspider/minitest-matchers
|
122
|
+
|
120
123
|
=== Benchmarks
|
121
124
|
|
122
125
|
Add benchmarks to your regular unit tests. If the unit tests fail, the
|
data/lib/hoe/minitest.rb
CHANGED
data/lib/minitest/benchmark.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'minitest/unit'
|
2
2
|
require 'minitest/spec'
|
3
3
|
|
4
|
-
class MiniTest::Unit
|
5
|
-
attr_accessor :runner
|
6
|
-
|
4
|
+
class MiniTest::Unit # :nodoc:
|
7
5
|
def run_benchmarks # :nodoc:
|
8
6
|
_run_anything :benchmark
|
9
7
|
end
|
@@ -312,6 +310,15 @@ class MiniTest::Spec
|
|
312
310
|
define_method "bench_#{name.gsub(/\W+/, '_')}", &block
|
313
311
|
end
|
314
312
|
|
313
|
+
##
|
314
|
+
# Specifies the ranges used for benchmarking for that class.
|
315
|
+
#
|
316
|
+
# bench_range do
|
317
|
+
# bench_exp(2, 16, 2)
|
318
|
+
# end
|
319
|
+
#
|
320
|
+
# See Unit::TestCase.bench_range for more details.
|
321
|
+
|
315
322
|
def self.bench_range &block
|
316
323
|
return super unless block
|
317
324
|
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'minitest/unit'
|
2
|
+
|
3
|
+
##
|
4
|
+
# minitest/excludes.rb extends MiniTest::Unit::TestCase to provide a
|
5
|
+
# clean API for excluding certain tests you don't want to run under
|
6
|
+
# certain conditions.
|
7
|
+
#
|
8
|
+
# For example, in test/test_xyz.rb you have:
|
9
|
+
#
|
10
|
+
# class TestXYZ < MiniTest::Unit::TestCase
|
11
|
+
# def test_good
|
12
|
+
# # test that passes
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# def test_bad
|
16
|
+
# # test that fails only on jruby
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# For jruby runs, you can add test/excludes/TestXYZ.rb with:
|
21
|
+
#
|
22
|
+
# exclude :test_bad, "Uses ObjectSpace" if jruby?
|
23
|
+
#
|
24
|
+
# The file is instance_eval'd on TestXYZ so you can call the exclude
|
25
|
+
# class method directly. Since it is ruby you can provide any sort
|
26
|
+
# of conditions you want to figure out if your tests should be
|
27
|
+
# excluded.
|
28
|
+
#
|
29
|
+
# TestCase.exclude causes test methods to call skip with the reason
|
30
|
+
# you provide. If you run your tests in verbose mode, you'll see a
|
31
|
+
# full report of the tests you've excluded.
|
32
|
+
#
|
33
|
+
# If you want to change where the exclude files are located, you can
|
34
|
+
# set the EXCLUDE_DIR environment variable.
|
35
|
+
|
36
|
+
class MiniTest::Unit::TestCase
|
37
|
+
ENV['EXCLUDE_DIR'] ||= "test/excludes"
|
38
|
+
|
39
|
+
##
|
40
|
+
# Exclude a test from a testcase. This is intended to be used by
|
41
|
+
# exclusion files.
|
42
|
+
|
43
|
+
def self.exclude name, reason
|
44
|
+
return warn "Method #{self}##{name} is not defined" unless
|
45
|
+
method_defined? name
|
46
|
+
|
47
|
+
alias_method :"old_#{name}", name
|
48
|
+
|
49
|
+
define_method name do
|
50
|
+
skip reason
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# Loads the exclusion file for the class, if any.
|
56
|
+
|
57
|
+
def self.load_excludes
|
58
|
+
@__load_excludes__ ||=
|
59
|
+
begin
|
60
|
+
if name and not name.empty? then
|
61
|
+
file = File.join ENV['EXCLUDE_DIR'], "#{name}.rb"
|
62
|
+
instance_eval File.read file if File.exist? file
|
63
|
+
end
|
64
|
+
true
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class << self
|
69
|
+
alias :old_test_methods :test_methods # :nodoc:
|
70
|
+
|
71
|
+
def test_methods # :nodoc:
|
72
|
+
load_excludes
|
73
|
+
old_test_methods
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/minitest/mock.rb
CHANGED
data/lib/minitest/pride.rb
CHANGED
@@ -4,12 +4,17 @@ require "minitest/unit"
|
|
4
4
|
# Show your testing pride!
|
5
5
|
|
6
6
|
class PrideIO
|
7
|
+
|
8
|
+
# Start an escape sequence
|
7
9
|
ESC = "\e["
|
10
|
+
|
11
|
+
# End the escape sequence
|
8
12
|
NND = "#{ESC}0m"
|
9
13
|
|
14
|
+
# The IO we're going to pipe through.
|
10
15
|
attr_reader :io
|
11
16
|
|
12
|
-
def initialize io
|
17
|
+
def initialize io # :nodoc:
|
13
18
|
@io = io
|
14
19
|
# stolen from /System/Library/Perl/5.10.0/Term/ANSIColor.pm
|
15
20
|
# also reference http://en.wikipedia.org/wiki/ANSI_escape_code
|
@@ -19,6 +24,9 @@ class PrideIO
|
|
19
24
|
# io.sync = true
|
20
25
|
end
|
21
26
|
|
27
|
+
##
|
28
|
+
# Wrap print to colorize the output.
|
29
|
+
|
22
30
|
def print o
|
23
31
|
case o
|
24
32
|
when "." then
|
@@ -30,7 +38,7 @@ class PrideIO
|
|
30
38
|
end
|
31
39
|
end
|
32
40
|
|
33
|
-
def puts(*o)
|
41
|
+
def puts(*o) # :nodoc:
|
34
42
|
o.map! { |s|
|
35
43
|
s.sub(/Finished tests/) {
|
36
44
|
@index = 0
|
@@ -43,6 +51,9 @@ class PrideIO
|
|
43
51
|
super
|
44
52
|
end
|
45
53
|
|
54
|
+
##
|
55
|
+
# Color a string.
|
56
|
+
|
46
57
|
def pride string
|
47
58
|
string = "*" if string == "."
|
48
59
|
c = @colors[@index % @size]
|
@@ -50,15 +61,20 @@ class PrideIO
|
|
50
61
|
"#{ESC}#{c}m#{string}#{NND}"
|
51
62
|
end
|
52
63
|
|
53
|
-
def method_missing msg, *args
|
64
|
+
def method_missing msg, *args # :nodoc:
|
54
65
|
io.send(msg, *args)
|
55
66
|
end
|
56
67
|
end
|
57
68
|
|
58
|
-
|
59
|
-
|
69
|
+
##
|
70
|
+
# If you thought the PrideIO was colorful...
|
71
|
+
#
|
72
|
+
# (Inspired by lolcat, but with clean math)
|
73
|
+
|
74
|
+
class PrideLOL < PrideIO
|
75
|
+
PI_3 = Math::PI / 3 # :nodoc:
|
60
76
|
|
61
|
-
def initialize io
|
77
|
+
def initialize io # :nodoc:
|
62
78
|
# walk red, green, and blue around a circle separated by equal thirds.
|
63
79
|
#
|
64
80
|
# To visualize, type this into wolfram-alpha:
|
@@ -82,6 +98,9 @@ class PrideLOL < PrideIO # inspired by lolcat, but massively cleaned up
|
|
82
98
|
super
|
83
99
|
end
|
84
100
|
|
101
|
+
##
|
102
|
+
# Make the string even more colorful. Damnit.
|
103
|
+
|
85
104
|
def pride string
|
86
105
|
c = @colors[@index % @size]
|
87
106
|
@index += 1
|
data/lib/minitest/spec.rb
CHANGED
@@ -197,6 +197,11 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
200
|
+
##
|
201
|
+
# Essentially, define an accessor for +name+ with +block+.
|
202
|
+
#
|
203
|
+
# Why use let instead of def? I honestly don't know.
|
204
|
+
|
200
205
|
def self.let name, &block
|
201
206
|
define_method name do
|
202
207
|
@_memoized ||= {}
|
@@ -204,6 +209,10 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
204
209
|
end
|
205
210
|
end
|
206
211
|
|
212
|
+
##
|
213
|
+
# Another lazy man's accessor generator. Made even more lazy by
|
214
|
+
# setting the name for you to +subject+.
|
215
|
+
|
207
216
|
def self.subject &block
|
208
217
|
let :subject, &block
|
209
218
|
end
|
@@ -234,6 +243,9 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
234
243
|
# :startdoc:
|
235
244
|
end
|
236
245
|
|
246
|
+
##
|
247
|
+
# It's where you hide your "assertions".
|
248
|
+
|
237
249
|
module MiniTest::Expectations
|
238
250
|
##
|
239
251
|
# See MiniTest::Assertions#assert_empty.
|
@@ -511,6 +523,6 @@ module MiniTest::Expectations
|
|
511
523
|
infect_an_assertion :refute_same, :wont_be_same_as
|
512
524
|
end
|
513
525
|
|
514
|
-
class Object
|
526
|
+
class Object # :nodoc:
|
515
527
|
include MiniTest::Expectations
|
516
528
|
end
|
data/lib/minitest/unit.rb
CHANGED
@@ -55,8 +55,13 @@ module MiniTest
|
|
55
55
|
# printed if the assertion fails.
|
56
56
|
|
57
57
|
module Assertions
|
58
|
+
UNDEFINED = Object.new # :nodoc:
|
58
59
|
|
59
|
-
|
60
|
+
def UNDEFINED.inspect # :nodoc:
|
61
|
+
"UNDEFINED" # again with the rdoc bugs... :(
|
62
|
+
end
|
63
|
+
|
64
|
+
WINDOZE = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ # :nodoc:
|
60
65
|
|
61
66
|
##
|
62
67
|
# Returns the diff command to use in #diff. Tries to intelligently
|
@@ -281,9 +286,6 @@ module MiniTest
|
|
281
286
|
assert obj.nil?, msg
|
282
287
|
end
|
283
288
|
|
284
|
-
UNDEFINED = Object.new
|
285
|
-
def UNDEFINED.inspect; "UNDEFINED"; end
|
286
|
-
|
287
289
|
##
|
288
290
|
# For testing with binary operators.
|
289
291
|
#
|
@@ -307,8 +309,8 @@ module MiniTest
|
|
307
309
|
yield
|
308
310
|
end
|
309
311
|
|
310
|
-
x = assert_equal stdout, out, "In stdout" if stdout
|
311
312
|
y = assert_equal stderr, err, "In stderr" if stderr
|
313
|
+
x = assert_equal stdout, out, "In stdout" if stdout
|
312
314
|
|
313
315
|
(!stdout || x) && (!stderr || y)
|
314
316
|
end
|
@@ -640,8 +642,8 @@ module MiniTest
|
|
640
642
|
end
|
641
643
|
end
|
642
644
|
|
643
|
-
class Unit
|
644
|
-
VERSION = "2.
|
645
|
+
class Unit # :nodoc:
|
646
|
+
VERSION = "2.9.0" # :nodoc:
|
645
647
|
|
646
648
|
attr_accessor :report, :failures, :errors, :skips # :nodoc:
|
647
649
|
attr_accessor :test_count, :assertion_count # :nodoc:
|
@@ -650,6 +652,9 @@ module MiniTest
|
|
650
652
|
attr_accessor :verbose # :nodoc:
|
651
653
|
attr_writer :options # :nodoc:
|
652
654
|
|
655
|
+
##
|
656
|
+
# Lazy accessor for options.
|
657
|
+
|
653
658
|
def options
|
654
659
|
@options ||= {}
|
655
660
|
end
|
@@ -738,6 +743,9 @@ module MiniTest
|
|
738
743
|
grep(/^run_/).map { |s| s.to_s }).uniq
|
739
744
|
end
|
740
745
|
|
746
|
+
##
|
747
|
+
# Return the IO for output.
|
748
|
+
|
741
749
|
def output
|
742
750
|
self.class.output
|
743
751
|
end
|
@@ -750,6 +758,9 @@ module MiniTest
|
|
750
758
|
output.print(*a)
|
751
759
|
end
|
752
760
|
|
761
|
+
##
|
762
|
+
# Runner for a given +type+ (eg, test vs bench).
|
763
|
+
|
753
764
|
def _run_anything type
|
754
765
|
suites = TestCase.send "#{type}_suites"
|
755
766
|
return if suites.empty?
|
@@ -787,10 +798,16 @@ module MiniTest
|
|
787
798
|
status
|
788
799
|
end
|
789
800
|
|
801
|
+
##
|
802
|
+
# Runs all the +suites+ for a given +type+.
|
803
|
+
|
790
804
|
def _run_suites suites, type
|
791
805
|
suites.map { |suite| _run_suite suite, type }
|
792
806
|
end
|
793
807
|
|
808
|
+
##
|
809
|
+
# Run a single +suite+ for a given +type+.
|
810
|
+
|
794
811
|
def _run_suite suite, type
|
795
812
|
header = "#{type}_suite_header"
|
796
813
|
puts send(header, suite) if respond_to? header
|
@@ -855,7 +872,7 @@ module MiniTest
|
|
855
872
|
@verbose = false
|
856
873
|
end
|
857
874
|
|
858
|
-
def process_args args = []
|
875
|
+
def process_args args = [] # :nodoc:
|
859
876
|
options = {}
|
860
877
|
orig_args = args.dup
|
861
878
|
|
@@ -938,6 +955,52 @@ module MiniTest
|
|
938
955
|
io.puts format % [test_count, assertion_count, failures, errors, skips]
|
939
956
|
end
|
940
957
|
|
958
|
+
##
|
959
|
+
# Provides a simple set of guards that you can use in your tests
|
960
|
+
# to skip execution if it is not applicable. These methods are
|
961
|
+
# mixed into TestCase as both instance and class methods so you
|
962
|
+
# can use them inside or outside of the test methods.
|
963
|
+
#
|
964
|
+
# def test_something_for_mri
|
965
|
+
# skip "bug 1234" if jruby?
|
966
|
+
# # ...
|
967
|
+
# end
|
968
|
+
#
|
969
|
+
# if windows? then
|
970
|
+
# # ... lots of test methods ...
|
971
|
+
# end
|
972
|
+
|
973
|
+
module Guard
|
974
|
+
|
975
|
+
##
|
976
|
+
# Is this running on jruby?
|
977
|
+
|
978
|
+
def jruby? platform = RUBY_PLATFORM
|
979
|
+
"java" == platform
|
980
|
+
end
|
981
|
+
|
982
|
+
##
|
983
|
+
# Is this running on mri?
|
984
|
+
|
985
|
+
def mri? platform = RUBY_DESCRIPTION
|
986
|
+
/^ruby/ =~ platform
|
987
|
+
end
|
988
|
+
|
989
|
+
##
|
990
|
+
# Is this running on rubinius?
|
991
|
+
|
992
|
+
def rubinius? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
|
993
|
+
"rbx" == platform
|
994
|
+
end
|
995
|
+
|
996
|
+
##
|
997
|
+
# Is this running on windows?
|
998
|
+
|
999
|
+
def windows? platform = RUBY_PLATFORM
|
1000
|
+
/mswin|mingw/ =~ platform
|
1001
|
+
end
|
1002
|
+
end
|
1003
|
+
|
941
1004
|
##
|
942
1005
|
# Subclass TestCase to create your own tests. Typically you'll want a
|
943
1006
|
# TestCase subclass per implementation class.
|
@@ -945,6 +1008,9 @@ module MiniTest
|
|
945
1008
|
# See MiniTest::Assertions
|
946
1009
|
|
947
1010
|
class TestCase
|
1011
|
+
include Guard
|
1012
|
+
extend Guard
|
1013
|
+
|
948
1014
|
attr_reader :__name__ # :nodoc:
|
949
1015
|
|
950
1016
|
PASSTHROUGH_EXCEPTIONS = [NoMemoryError, SignalException,
|
@@ -1002,11 +1068,17 @@ module MiniTest
|
|
1002
1068
|
@@current
|
1003
1069
|
end
|
1004
1070
|
|
1071
|
+
##
|
1072
|
+
# Return the output IO object
|
1073
|
+
|
1005
1074
|
def io
|
1006
1075
|
@__io__ = true
|
1007
1076
|
MiniTest::Unit.output
|
1008
1077
|
end
|
1009
1078
|
|
1079
|
+
##
|
1080
|
+
# Have we hooked up the IO yet?
|
1081
|
+
|
1010
1082
|
def io?
|
1011
1083
|
@__io__
|
1012
1084
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'stringio'
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
class MetaMetaMetaTestCase < MiniTest::Unit::TestCase
|
6
|
+
def assert_report expected = nil
|
7
|
+
expected ||= <<-EOM.gsub(/^ {6}/, '')
|
8
|
+
Run options: --seed 42
|
9
|
+
|
10
|
+
# Running tests:
|
11
|
+
|
12
|
+
.
|
13
|
+
|
14
|
+
Finished tests in 0.00
|
15
|
+
|
16
|
+
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
|
17
|
+
EOM
|
18
|
+
|
19
|
+
output = @output.string.dup
|
20
|
+
output.sub!(/Finished tests in .*/, "Finished tests in 0.00")
|
21
|
+
output.sub!(/Loaded suite .*/, 'Loaded suite blah')
|
22
|
+
output.gsub!(/[\w\/]+\/test\/[^:]+:\d+/, 'FILE:LINE')
|
23
|
+
output.gsub!(/(?:.\/)?test\/[^:]+:\d+/, 'FILE:LINE')
|
24
|
+
output.gsub!(/\[[^\]]+\]/, '[FILE:LINE]')
|
25
|
+
assert_equal(expected, output)
|
26
|
+
end
|
27
|
+
|
28
|
+
def setup
|
29
|
+
super
|
30
|
+
srand 42
|
31
|
+
MiniTest::Unit::TestCase.reset
|
32
|
+
@tu = MiniTest::Unit.new
|
33
|
+
@output = StringIO.new("")
|
34
|
+
MiniTest::Unit.runner = nil # protect the outer runner from the inner tests
|
35
|
+
MiniTest::Unit.output = @output
|
36
|
+
end
|
37
|
+
|
38
|
+
def teardown
|
39
|
+
super
|
40
|
+
MiniTest::Unit.output = $stdout
|
41
|
+
Object.send :remove_const, :ATestCase if defined? ATestCase
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'test/metametameta'
|
2
|
+
require 'minitest/excludes'
|
3
|
+
|
4
|
+
class TestMiniTestExcludes < MetaMetaMetaTestCase
|
5
|
+
def test_cls_excludes
|
6
|
+
srand 42
|
7
|
+
old_exclude_base = ENV['EXCLUDE_DIR']
|
8
|
+
|
9
|
+
@assertion_count = 0
|
10
|
+
|
11
|
+
Dir.mktmpdir do |path|
|
12
|
+
ENV['EXCLUDE_DIR'] = path
|
13
|
+
File.open File.join(path, "ATestCase.rb"), "w" do |f|
|
14
|
+
f.puts <<-EOM
|
15
|
+
exclude :test_test2, "because it is borked"
|
16
|
+
EOM
|
17
|
+
end
|
18
|
+
|
19
|
+
tc = Class.new(MiniTest::Unit::TestCase) do
|
20
|
+
def test_test1; assert true end
|
21
|
+
def test_test2; assert false end # oh noes!
|
22
|
+
def test_test3; assert true end
|
23
|
+
end
|
24
|
+
|
25
|
+
Object.const_set(:ATestCase, tc)
|
26
|
+
|
27
|
+
assert_equal %w(test_test1 test_test2 test_test3), ATestCase.test_methods
|
28
|
+
|
29
|
+
@tu.run %w[--seed 42 --verbose]
|
30
|
+
|
31
|
+
expected = <<-EOM.gsub(/^ {8}/, '')
|
32
|
+
Run options: --seed 42 --verbose
|
33
|
+
|
34
|
+
# Running tests:
|
35
|
+
|
36
|
+
ATestCase#test_test2 = 0.00 s = S
|
37
|
+
ATestCase#test_test1 = 0.00 s = .
|
38
|
+
ATestCase#test_test3 = 0.00 s = .
|
39
|
+
|
40
|
+
|
41
|
+
Finished tests in 0.00
|
42
|
+
|
43
|
+
1) Skipped:
|
44
|
+
test_test2(ATestCase) [FILE:LINE]:
|
45
|
+
because it is borked
|
46
|
+
|
47
|
+
3 tests, 2 assertions, 0 failures, 0 errors, 1 skips
|
48
|
+
EOM
|
49
|
+
assert_report expected
|
50
|
+
end
|
51
|
+
ensure
|
52
|
+
ENV['EXCLUDE_DIR'] = old_exclude_base
|
53
|
+
end
|
54
|
+
end
|
data/test/test_minitest_spec.rb
CHANGED
data/test/test_minitest_unit.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
require 'stringio'
|
2
1
|
require 'pathname'
|
3
|
-
require '
|
2
|
+
require 'test/metametameta'
|
4
3
|
|
5
4
|
module MyModule; end
|
6
5
|
class AnError < StandardError; include MyModule; end
|
7
6
|
class ImmutableString < String; def inspect; super.freeze; end; end
|
8
7
|
|
9
|
-
class TestMiniTestUnit <
|
8
|
+
class TestMiniTestUnit < MetaMetaMetaTestCase
|
10
9
|
pwd = Pathname.new(File.expand_path(Dir.pwd))
|
11
10
|
basedir = Pathname.new(File.expand_path("lib/minitest")) + 'mini'
|
12
11
|
basedir = basedir.relative_path_from(pwd).to_s
|
@@ -16,38 +15,6 @@ class TestMiniTestUnit < MiniTest::Unit::TestCase
|
|
16
15
|
"#{MINITEST_BASE_DIR}/test.rb:139:in `run'",
|
17
16
|
"#{MINITEST_BASE_DIR}/test.rb:106:in `run'"]
|
18
17
|
|
19
|
-
def assert_report expected = nil
|
20
|
-
expected ||= "Run options: --seed 42
|
21
|
-
|
22
|
-
# Running tests:
|
23
|
-
|
24
|
-
.
|
25
|
-
|
26
|
-
Finished tests in 0.00
|
27
|
-
|
28
|
-
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
|
29
|
-
"
|
30
|
-
output = @output.string.sub(/Finished tests in .*/, "Finished tests in 0.00")
|
31
|
-
output.sub!(/Loaded suite .*/, 'Loaded suite blah')
|
32
|
-
output.sub!(/^(\s+)(?:#{Regexp.union(__FILE__, File.expand_path(__FILE__))}):\d+:/o, '\1FILE:LINE:')
|
33
|
-
output.sub!(/\[(?:#{Regexp.union(__FILE__, File.expand_path(__FILE__))}):\d+\]/o, '[FILE:LINE]')
|
34
|
-
assert_equal(expected, output)
|
35
|
-
end
|
36
|
-
|
37
|
-
def setup
|
38
|
-
srand 42
|
39
|
-
MiniTest::Unit::TestCase.reset
|
40
|
-
@tu = MiniTest::Unit.new
|
41
|
-
@output = StringIO.new("")
|
42
|
-
MiniTest::Unit.runner = nil # protect the outer runner from the inner tests
|
43
|
-
MiniTest::Unit.output = @output
|
44
|
-
end
|
45
|
-
|
46
|
-
def teardown
|
47
|
-
MiniTest::Unit.output = $stdout
|
48
|
-
Object.send :remove_const, :ATestCase if defined? ATestCase
|
49
|
-
end
|
50
|
-
|
51
18
|
def test_class_puke_with_assertion_failed
|
52
19
|
exception = MiniTest::Assertion.new "Oh no!"
|
53
20
|
exception.set_backtrace ["unhappy"]
|
@@ -229,21 +196,23 @@ Finished tests in 0.00
|
|
229
196
|
|
230
197
|
@tu.run %w[--seed 42]
|
231
198
|
|
232
|
-
expected =
|
199
|
+
expected = <<-EOM.gsub(/^ {6}/, '')
|
200
|
+
Run options: --seed 42
|
233
201
|
|
234
|
-
# Running tests:
|
202
|
+
# Running tests:
|
235
203
|
|
236
|
-
E.
|
204
|
+
E.
|
237
205
|
|
238
|
-
Finished tests in 0.00
|
206
|
+
Finished tests in 0.00
|
239
207
|
|
240
|
-
|
241
|
-
test_error(ATestCase):
|
242
|
-
RuntimeError: unhandled exception
|
243
|
-
|
208
|
+
1) Error:
|
209
|
+
test_error(ATestCase):
|
210
|
+
RuntimeError: unhandled exception
|
211
|
+
FILE:LINE:in `test_error'
|
212
|
+
|
213
|
+
2 tests, 1 assertions, 0 failures, 1 errors, 0 skips
|
214
|
+
EOM
|
244
215
|
|
245
|
-
2 tests, 1 assertions, 0 failures, 1 errors, 0 skips
|
246
|
-
"
|
247
216
|
assert_report expected
|
248
217
|
end
|
249
218
|
|
@@ -621,6 +590,8 @@ end
|
|
621
590
|
|
622
591
|
class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
623
592
|
def setup
|
593
|
+
super
|
594
|
+
|
624
595
|
MiniTest::Unit::TestCase.reset
|
625
596
|
|
626
597
|
@tc = MiniTest::Unit::TestCase.new 'fake tc'
|
@@ -950,7 +921,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
|
950
921
|
end
|
951
922
|
|
952
923
|
def test_assert_output_triggered_both
|
953
|
-
util_assert_triggered util_msg("
|
924
|
+
util_assert_triggered util_msg("blah", "blah blah", "In stderr") do
|
954
925
|
@tc.assert_output "yay", "blah" do
|
955
926
|
print "boo"
|
956
927
|
$stderr.print "blah blah"
|
@@ -980,6 +951,12 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
|
980
951
|
end
|
981
952
|
end
|
982
953
|
|
954
|
+
def test_assert_raises_module
|
955
|
+
@tc.assert_raises MyModule do
|
956
|
+
raise AnError
|
957
|
+
end
|
958
|
+
end
|
959
|
+
|
983
960
|
##
|
984
961
|
# *sigh* This is quite an odd scenario, but it is from real (albeit
|
985
962
|
# ugly) test code in ruby-core:
|
@@ -1000,12 +977,6 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
|
1000
977
|
end
|
1001
978
|
end
|
1002
979
|
|
1003
|
-
def test_assert_raises_module
|
1004
|
-
@tc.assert_raises MyModule do
|
1005
|
-
raise AnError
|
1006
|
-
end
|
1007
|
-
end
|
1008
|
-
|
1009
980
|
def test_assert_raises_triggered_different
|
1010
981
|
e = assert_raises MiniTest::Assertion do
|
1011
982
|
@tc.assert_raises RuntimeError do
|
@@ -1144,8 +1115,6 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|
1144
1115
|
end
|
1145
1116
|
|
1146
1117
|
def test_assert_silent_triggered_err
|
1147
|
-
@assertion_count = 2
|
1148
|
-
|
1149
1118
|
util_assert_triggered util_msg("", "blah blah", "In stderr") do
|
1150
1119
|
@tc.assert_silent do
|
1151
1120
|
$stderr.print "blah blah"
|
@@ -1154,6 +1123,8 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|
1154
1123
|
end
|
1155
1124
|
|
1156
1125
|
def test_assert_silent_triggered_out
|
1126
|
+
@assertion_count = 2
|
1127
|
+
|
1157
1128
|
util_assert_triggered util_msg("", "blah blah", "In stdout") do
|
1158
1129
|
@tc.assert_silent do
|
1159
1130
|
print "blah blah"
|
@@ -1502,3 +1473,25 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|
1502
1473
|
MiniTest::Assertions.diff = old_diff
|
1503
1474
|
end
|
1504
1475
|
end
|
1476
|
+
|
1477
|
+
class TestMiniTestGuard < MiniTest::Unit::TestCase
|
1478
|
+
def test_mri_eh
|
1479
|
+
assert self.class.mri? "ruby blah"
|
1480
|
+
assert self.mri? "ruby blah"
|
1481
|
+
end
|
1482
|
+
|
1483
|
+
def test_jruby_eh
|
1484
|
+
assert self.class.jruby? "java"
|
1485
|
+
assert self.jruby? "java"
|
1486
|
+
end
|
1487
|
+
|
1488
|
+
def test_rubinius_eh
|
1489
|
+
assert self.class.rubinius? "rbx"
|
1490
|
+
assert self.rubinius? "rbx"
|
1491
|
+
end
|
1492
|
+
|
1493
|
+
def test_windows_eh
|
1494
|
+
assert self.class.windows? "mswin"
|
1495
|
+
assert self.windows? "mswin"
|
1496
|
+
end
|
1497
|
+
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:
|
4
|
+
hash: 43
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 2.
|
8
|
+
- 9
|
9
|
+
- 0
|
10
|
+
version: 2.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Davis
|
@@ -36,36 +36,36 @@ cert_chain:
|
|
36
36
|
FBHgymkyj/AOSqKRIpXPhjC6
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2011-
|
39
|
+
date: 2011-12-08 00:00:00 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: hoe
|
43
43
|
prerelease: false
|
44
44
|
requirement: &id001 !ruby/object:Gem::Requirement
|
45
45
|
none: false
|
46
46
|
requirements:
|
47
47
|
- - ~>
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
hash:
|
49
|
+
hash: 27
|
50
50
|
segments:
|
51
|
-
-
|
52
|
-
-
|
53
|
-
version: "
|
51
|
+
- 2
|
52
|
+
- 12
|
53
|
+
version: "2.12"
|
54
54
|
type: :development
|
55
55
|
version_requirements: *id001
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: rdoc
|
58
58
|
prerelease: false
|
59
59
|
requirement: &id002 !ruby/object:Gem::Requirement
|
60
60
|
none: false
|
61
61
|
requirements:
|
62
62
|
- - ~>
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
hash:
|
64
|
+
hash: 19
|
65
65
|
segments:
|
66
|
-
-
|
67
|
-
-
|
68
|
-
version: "
|
66
|
+
- 3
|
67
|
+
- 10
|
68
|
+
version: "3.10"
|
69
69
|
type: :development
|
70
70
|
version_requirements: *id002
|
71
71
|
description: "minitest provides a complete suite of testing facilities supporting\n\
|
@@ -108,11 +108,14 @@ files:
|
|
108
108
|
- lib/hoe/minitest.rb
|
109
109
|
- lib/minitest/autorun.rb
|
110
110
|
- lib/minitest/benchmark.rb
|
111
|
+
- lib/minitest/excludes.rb
|
111
112
|
- lib/minitest/mock.rb
|
112
113
|
- lib/minitest/pride.rb
|
113
114
|
- lib/minitest/spec.rb
|
114
115
|
- lib/minitest/unit.rb
|
116
|
+
- test/metametameta.rb
|
115
117
|
- test/test_minitest_benchmark.rb
|
118
|
+
- test/test_minitest_excludes.rb
|
116
119
|
- test/test_minitest_mock.rb
|
117
120
|
- test/test_minitest_spec.rb
|
118
121
|
- test/test_minitest_unit.rb
|
@@ -147,12 +150,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
150
|
requirements: []
|
148
151
|
|
149
152
|
rubyforge_project: bfts
|
150
|
-
rubygems_version: 1.8.
|
153
|
+
rubygems_version: 1.8.12
|
151
154
|
signing_key:
|
152
155
|
specification_version: 3
|
153
156
|
summary: minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking
|
154
157
|
test_files:
|
155
158
|
- test/test_minitest_benchmark.rb
|
159
|
+
- test/test_minitest_excludes.rb
|
156
160
|
- test/test_minitest_mock.rb
|
157
161
|
- test/test_minitest_spec.rb
|
158
162
|
- test/test_minitest_unit.rb
|
metadata.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
!�%�G`b{��l��hwE��*��r.9�U^���{ݯg�I-ƭ=�+Jﳐ��|%�[�C�bO�q��IU�D��-e~+Ŕ؋F0U�7 �����#�IZi�o��&T���9���O��Бpr�w*��[��r{{.J��5W"�~t~���MIh�W6���tv�(��<�Pc�x.y���̌�m�8��Q�
|
2
|
+
B�覙�-��hf�
|