oktest 1.0.1 → 1.2.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.
- checksums.yaml +5 -5
- data/README.md +443 -35
- data/Rakefile.rb +5 -2
- data/benchmark/Rakefile.rb +4 -0
- data/lib/oktest.rb +549 -72
- data/oktest.gemspec +3 -3
- data/test/assertion_test.rb +70 -5
- data/test/filter_test.rb +2 -2
- data/test/fixture_test.rb +14 -1
- data/test/generator_test.rb +1 -1
- data/test/helper_test.rb +3 -3
- data/test/initialize.rb +8 -1
- data/test/mainapp_test.rb +95 -42
- data/test/matcher_test.rb +424 -0
- data/test/misc_test.rb +5 -5
- data/test/node_test.rb +27 -4
- data/test/reporter_test.rb +56 -29
- data/test/runner_test.rb +97 -25
- data/test/tc.rb +12 -0
- data/test/util_test.rb +71 -1
- data/test/utilhelper_test.rb +84 -0
- data/test/visitor_test.rb +1 -1
- metadata +9 -8
data/oktest.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.0
|
4
|
+
### $Release: 1.2.0 $
|
5
5
|
### $License: MIT License $
|
6
6
|
### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
|
7
7
|
###
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.name = "oktest"
|
14
14
|
s.author = "kwatch"
|
15
15
|
s.email = "kwatch@gmail.com"
|
16
|
-
s.version = "$Release: 1.0
|
16
|
+
s.version = "$Release: 1.2.0 $".split()[1]
|
17
17
|
s.license = "MIT"
|
18
18
|
s.platform = Gem::Platform::RUBY
|
19
19
|
s.homepage = "https://github.com/kwatch/oktest/tree/ruby"
|
@@ -30,7 +30,7 @@ Oktest.rb is a new-style testing library for Ruby.
|
|
30
30
|
|
31
31
|
See https://github.com/kwatch/oktest/tree/ruby/ruby for details.
|
32
32
|
END
|
33
|
-
s.required_ruby_version = ">= 2.
|
33
|
+
s.required_ruby_version = ">= 2.0"
|
34
34
|
s.add_dependency "diff-lcs", "~> 1.0"
|
35
35
|
s.add_dependency "benry-recorder", "~> 1.0"
|
36
36
|
|
data/test/assertion_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.0
|
4
|
+
### $Release: 1.2.0 $
|
5
5
|
### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
@@ -170,6 +170,15 @@ END
|
|
170
170
|
" $<expected>: \"str\""
|
171
171
|
FAIL!(errmsg) { ok {String}.NOT === 'str' }
|
172
172
|
end
|
173
|
+
it "[!mjh4d] raises error when combination of 'not_ok()' and matcher object." do
|
174
|
+
errmsg = "negative `===` is not available with matcher object."
|
175
|
+
assert_exc(Oktest::OktestError, errmsg) do
|
176
|
+
not_ok {Oktest::JsonMatcher.new({})} === {}
|
177
|
+
end
|
178
|
+
assert_exc(Oktest::OktestError, errmsg) do
|
179
|
+
ok {Oktest::JsonMatcher.new({})}.NOT === {}
|
180
|
+
end
|
181
|
+
end
|
173
182
|
end
|
174
183
|
|
175
184
|
describe '>' do
|
@@ -423,11 +432,11 @@ describe '#method_missing()' do
|
|
423
432
|
assert NoMethodError < NameError, "NoMethodError extends NameError"
|
424
433
|
ERROR!(NoMethodError, /foobar/) { ok {pr}.raise?(NameError) }
|
425
434
|
end
|
426
|
-
it "[!hwg0z] compares error class with '.is_a?' if '
|
435
|
+
it "[!hwg0z] compares error class with '.is_a?' if '_subclass: true' specified." do
|
427
436
|
pr = proc { "SOS".foobar }
|
428
437
|
PASS! { ok {pr}.raise?(NoMethodError, nil) }
|
429
438
|
assert NoMethodError < NameError, "NoMethodError extends NameError"
|
430
|
-
PASS! { ok {pr}.raise?(NameError, nil,
|
439
|
+
PASS! { ok {pr}.raise?(NameError, nil, _subclass: true) }
|
431
440
|
end
|
432
441
|
it "[!4n3ed] reraises if exception is not matched to specified error class." do
|
433
442
|
pr = proc { "SOS".sos }
|
@@ -483,11 +492,11 @@ describe '#method_missing()' do
|
|
483
492
|
assert NoMethodError < NameError, "NoMethodError extends NameError"
|
484
493
|
ERROR!(NoMethodError) { ok {pr}.NOT.raise?(NameError) }
|
485
494
|
end
|
486
|
-
it "[!34nd8] compares error class with '.is_a?' if '
|
495
|
+
it "[!34nd8] compares error class with '.is_a?' if '_subclass: true' specified." do
|
487
496
|
pr = proc { "SOS".foobar }
|
488
497
|
FAIL!(/foobar/) { ok {pr}.NOT.raise?(NoMethodError, nil) }
|
489
498
|
assert NoMethodError < NameError, "NoMethodError extends NameError"
|
490
|
-
FAIL!(/foobar/) { ok {pr}.NOT.raise?(NameError, nil,
|
499
|
+
FAIL!(/foobar/) { ok {pr}.NOT.raise?(NameError, nil, _subclass: true) }
|
491
500
|
end
|
492
501
|
it "[!shxne] reraises exception if different from specified error class." do
|
493
502
|
pr = proc { 1/0 }
|
@@ -814,4 +823,60 @@ describe '#method_missing()' do
|
|
814
823
|
end
|
815
824
|
end
|
816
825
|
|
826
|
+
describe '#JSON()' do
|
827
|
+
it "[!n0k03] creates JsonMatcher object." do
|
828
|
+
o = JSON({})
|
829
|
+
assert_eq o.class, Oktest::JsonMatcher
|
830
|
+
end
|
831
|
+
end
|
832
|
+
|
833
|
+
describe '#Enum()' do
|
834
|
+
it "[!fbfr0] creates Enum object which is a subclass of Set." do
|
835
|
+
o = Enum("a", "b", "c")
|
836
|
+
assert_eq o.class, Oktest::JsonMatcher::Enum
|
837
|
+
assert o.class < Set
|
838
|
+
assert_eq (o === "a"), true
|
839
|
+
assert_eq (o === "b"), true
|
840
|
+
assert_eq (o === "c"), true
|
841
|
+
assert_eq (o === "d"), false
|
842
|
+
end
|
843
|
+
end
|
844
|
+
|
845
|
+
describe '#Bool()' do
|
846
|
+
it "[!vub5j] creates a set of true and false." do
|
847
|
+
assert_eq Bool().class, Oktest::JsonMatcher::Enum
|
848
|
+
assert Bool() === true
|
849
|
+
assert Bool() === false
|
850
|
+
assert_eq (Bool() === 1), false
|
851
|
+
assert_eq (Bool() === 0), false
|
852
|
+
end
|
853
|
+
end
|
854
|
+
|
855
|
+
describe '#OR()' do
|
856
|
+
it "[!9e8im] creates `OR` object." do
|
857
|
+
o = OR(1, 2, 3)
|
858
|
+
assert_eq o.class, Oktest::JsonMatcher::OR
|
859
|
+
end
|
860
|
+
end
|
861
|
+
|
862
|
+
describe '#AND()' do
|
863
|
+
it "[!38jln] creates `AND` object." do
|
864
|
+
o = AND(4, 5, 6)
|
865
|
+
assert_eq o.class, Oktest::JsonMatcher::AND
|
866
|
+
end
|
867
|
+
end
|
868
|
+
|
869
|
+
describe '#Length()' do
|
870
|
+
it "[!qqas3] creates Length object." do
|
871
|
+
o = Length(3)
|
872
|
+
assert_eq o.class, Oktest::JsonMatcher::Length
|
873
|
+
end
|
874
|
+
end
|
875
|
+
|
876
|
+
describe '#Any()' do
|
877
|
+
it "[!dlo1o] creates an 'Any' object." do
|
878
|
+
assert_eq Any().class, Oktest::JsonMatcher::Any
|
879
|
+
end
|
880
|
+
end
|
881
|
+
|
817
882
|
end
|
data/test/filter_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.0
|
4
|
+
### $Release: 1.2.0 $
|
5
5
|
### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
@@ -188,7 +188,7 @@ class Filter_TC < TC
|
|
188
188
|
Oktest::Runner.new(reporter).start()
|
189
189
|
end
|
190
190
|
assert_eq serr, ""
|
191
|
-
return sout.sub(/^## total:.*\n/, '')
|
191
|
+
return sout.sub(/^## total:.*\n/, '').sub(/^## test\/filter_test\.rb\n/, '')
|
192
192
|
end
|
193
193
|
|
194
194
|
def uncolor(s)
|
data/test/fixture_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.0
|
4
|
+
### $Release: 1.2.0 $
|
5
5
|
### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
@@ -116,6 +116,19 @@ END
|
|
116
116
|
assert_eq sout, expected
|
117
117
|
end
|
118
118
|
|
119
|
+
it "[!gyyst] overwrites keyword params by fixture values." do
|
120
|
+
Oktest.scope do
|
121
|
+
topic "topic#1" do
|
122
|
+
fixture(:x) {|y, z: 3| {y: y, z: z} }
|
123
|
+
fixture(:y) { 2 }
|
124
|
+
spec("not overwrite") {|x| p x }
|
125
|
+
spec("overwrite", fixture: {y: 4, z: 5}) {|x| p x }
|
126
|
+
end
|
127
|
+
end
|
128
|
+
sout = run_all()
|
129
|
+
assert_eq sout, "{:y=>2, :z=>3}\n{:y=>4, :z=>5}\n"
|
130
|
+
end
|
131
|
+
|
119
132
|
it "[!4xghy] calls fixture block with context object as self." do
|
120
133
|
Oktest.scope do
|
121
134
|
topic "Parent" do
|
data/test/generator_test.rb
CHANGED
data/test/helper_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
###
|
2
|
-
### $Release: 1.0
|
2
|
+
### $Release: 1.2.0 $
|
3
3
|
### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
|
4
4
|
### $License: MIT License $
|
5
5
|
###
|
@@ -36,7 +36,7 @@ class SpecHelper_TC < TC
|
|
36
36
|
it "[!bc3l2] records invoked location." do
|
37
37
|
lineno = __LINE__ + 1
|
38
38
|
o = ok {"bar"}
|
39
|
-
assert o.location.start_with?("#{__FILE__}:#{lineno}:")
|
39
|
+
assert o.location.to_s.start_with?("#{__FILE__}:#{lineno}:")
|
40
40
|
end
|
41
41
|
it "[!mqtdy] not record invoked location when `Config.ok_location == false`." do
|
42
42
|
bkup = Oktest::Config.ok_location
|
@@ -60,7 +60,7 @@ class SpecHelper_TC < TC
|
|
60
60
|
it "[!agmx8] records invoked location." do
|
61
61
|
lineno = __LINE__ + 1
|
62
62
|
o = not_ok {"bar"}
|
63
|
-
assert o.location.start_with?("#{__FILE__}:#{lineno}:")
|
63
|
+
assert o.location.to_s.start_with?("#{__FILE__}:#{lineno}:")
|
64
64
|
end
|
65
65
|
it "[!a9508] not record invoked location when `Config.ok_location == false`." do
|
66
66
|
bkup = Oktest::Config.ok_location
|
data/test/initialize.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 1.0
|
4
|
+
### $Release: 1.2.0 $
|
5
5
|
### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
@@ -12,3 +12,10 @@ end
|
|
12
12
|
|
13
13
|
require_relative './tc'
|
14
14
|
require 'oktest'
|
15
|
+
|
16
|
+
|
17
|
+
# for Ruby 2.4 or older
|
18
|
+
require 'set'
|
19
|
+
unless Set.instance_methods(false).include?(:===)
|
20
|
+
class Set; alias === include?; end
|
21
|
+
end
|
data/test/mainapp_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
###
|
2
|
-
### $Release: 1.0
|
2
|
+
### $Release: 1.2.0 $
|
3
3
|
### $Copyright: copyright(c) 2011-2021 kuwata-lab.com all rights reserved $
|
4
4
|
### $License: MIT License $
|
5
5
|
###
|
@@ -73,15 +73,6 @@ end
|
|
73
73
|
|
74
74
|
END
|
75
75
|
|
76
|
-
def plain2colored(str)
|
77
|
-
str = str.gsub(/<R>(.*?)<\/R>/) { Oktest::Color.red($1) }
|
78
|
-
str = str.gsub(/<G>(.*?)<\/G>/) { Oktest::Color.green($1) }
|
79
|
-
str = str.gsub(/<B>(.*?)<\/B>/) { Oktest::Color.blue($1) }
|
80
|
-
str = str.gsub(/<Y>(.*?)<\/Y>/) { Oktest::Color.yellow($1) }
|
81
|
-
str = str.gsub(/<b>(.*?)<\/b>/) { Oktest::Color.bold($1) }
|
82
|
-
return str
|
83
|
-
end
|
84
|
-
|
85
76
|
def edit_actual(output)
|
86
77
|
bkup = output.dup
|
87
78
|
output = output.gsub(/^.*\r/, '')
|
@@ -165,7 +156,7 @@ END
|
|
165
156
|
|
166
157
|
it "[!18qpe] runs test scripts." do
|
167
158
|
expected = <<'END'
|
168
|
-
## total:8 (<
|
159
|
+
## total:8 (<C>pass:4</C>, <R>fail:1</R>, <E>error:1</E>, <Y>skip:1</Y>, <Y>todo:1</Y>) in 0.000s
|
169
160
|
END
|
170
161
|
ret, sout, serr = run(@testfile)
|
171
162
|
assert_eq ret, 2
|
@@ -180,7 +171,7 @@ END
|
|
180
171
|
|
181
172
|
it "[!hiu5b] finds test scripts in directory and runs them." do
|
182
173
|
expected = <<'END'
|
183
|
-
## total:8 (<
|
174
|
+
## total:8 (<C>pass:4</C>, <R>fail:1</R>, <E>error:1</E>, <Y>skip:1</Y>, <Y>todo:1</Y>) in 0.000s
|
184
175
|
END
|
185
176
|
dir = "_tmpdir.d"
|
186
177
|
dirs = [dir, "#{dir}/d1", "#{dir}/d1/d2"]
|
@@ -196,17 +187,42 @@ END
|
|
196
187
|
end
|
197
188
|
end
|
198
189
|
|
190
|
+
it "[!v5xie] parses $OKTEST_RB environment variable." do
|
191
|
+
ret, sout, serr = run(@testfile, tty: false)
|
192
|
+
expected = plain2colored(<<'END')
|
193
|
+
## _tmp_test.rb
|
194
|
+
* <b>Parent</b>
|
195
|
+
* <b>Child1</b>
|
196
|
+
- [<C>pass</C>] 1+1 should be 2
|
197
|
+
- [<C>pass</C>] 1-1 should be 0
|
198
|
+
END
|
199
|
+
assert sout.start_with?(expected), "expected verbose-style, but not."
|
200
|
+
#
|
201
|
+
begin
|
202
|
+
ENV['OKTEST_RB'] = "-ss"
|
203
|
+
ret, sout, serr = run(@testfile, tty: false)
|
204
|
+
expected = plain2colored(<<'END')
|
205
|
+
## _tmp_test.rb
|
206
|
+
* <b>Parent</b>: <C>.</C><C>.</C>
|
207
|
+
* <b>Child1</b>: <C>.</C><C>.</C>
|
208
|
+
* <b>Child2</b>: <R>f</R><E>E</E>
|
209
|
+
END
|
210
|
+
assert sout.start_with?(expected), "expected simple-style, but not."
|
211
|
+
ensure
|
212
|
+
ENV.delete('OKTEST_RB')
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
199
216
|
#HELP_MESSAGE = Oktest::MainApp::HELP_MESSAGE % {command: File.basename($0)}
|
200
217
|
HELP_MESSAGE = <<"END"
|
201
218
|
Usage: #{File.basename($0)} [<options>] [<file-or-directory>...]
|
202
219
|
-h, --help : show help
|
203
220
|
--version : print version
|
204
|
-
-s <STYLE>
|
221
|
+
-s <REPORT-STYLE> : verbose/simple/compact/plain/quiet, or v/s/c/p/q
|
205
222
|
-F <PATTERN> : filter topic or spec with pattern (see below)
|
206
223
|
--color[={on|off}] : enable/disable output coloring forcedly
|
207
|
-
-
|
224
|
+
-S, --skeleton : print test code skeleton
|
208
225
|
-G, --generate : generate test code skeleton from ruby file
|
209
|
-
--faster : make 'ok{}' faster (for very large project)
|
210
226
|
|
211
227
|
Filter examples:
|
212
228
|
$ oktest -F topic=Hello # filter by topic
|
@@ -241,7 +257,7 @@ END
|
|
241
257
|
end
|
242
258
|
|
243
259
|
it "[!qqizl] '--version' option prints version number." do
|
244
|
-
expected = '$Release: 1.0
|
260
|
+
expected = '$Release: 1.2.0 $'.split()[1] + "\n"
|
245
261
|
#
|
246
262
|
ret, sout, serr = run("--version")
|
247
263
|
assert_eq ret, 0
|
@@ -251,13 +267,14 @@ END
|
|
251
267
|
|
252
268
|
it "[!0qd92] '-s verbose' or '-sv' option prints test results in verbose mode." do
|
253
269
|
expected = <<END
|
270
|
+
## _tmp_test.rb
|
254
271
|
* <b>Parent</b>
|
255
272
|
* <b>Child1</b>
|
256
|
-
- [<
|
257
|
-
- [<
|
273
|
+
- [<C>pass</C>] 1+1 should be 2
|
274
|
+
- [<C>pass</C>] 1-1 should be 0
|
258
275
|
* <b>Child2</b>
|
259
276
|
- [<R>Fail</R>] 1*1 should be 1
|
260
|
-
- [<
|
277
|
+
- [<E>ERROR</E>] 1/1 should be 1
|
261
278
|
----------------------------------------------------------------------
|
262
279
|
END
|
263
280
|
#
|
@@ -272,9 +289,12 @@ END
|
|
272
289
|
assert_eq serr, ""
|
273
290
|
end
|
274
291
|
|
275
|
-
it "[!
|
292
|
+
it "[!zfdr5] '-s simple' or '-ss' option prints test results in simple mode." do
|
276
293
|
expected = <<END
|
277
|
-
|
294
|
+
## _tmp_test.rb
|
295
|
+
* <b>Parent</b>: <C>.</C><C>.</C>
|
296
|
+
* <b>Child1</b>: <C>.</C><C>.</C>
|
297
|
+
* <b>Child2</b>: <R>f</R><E>E</E>
|
278
298
|
----------------------------------------------------------------------
|
279
299
|
END
|
280
300
|
#
|
@@ -289,9 +309,26 @@ END
|
|
289
309
|
assert_eq serr, ""
|
290
310
|
end
|
291
311
|
|
312
|
+
it "[!ef5v7] '-s compact' or '-sc' option prints test results in compact mode." do
|
313
|
+
expected = <<END
|
314
|
+
#{@testfile}: <C>.</C><C>.</C><R>f</R><E>E</E><Y>s</Y><Y>t</Y><C>.</C><C>.</C>
|
315
|
+
----------------------------------------------------------------------
|
316
|
+
END
|
317
|
+
#
|
318
|
+
ret, sout, serr = run("-sc", @testfile)
|
319
|
+
assert_eq ret, 2
|
320
|
+
assert edit_actual(sout).start_with?(edit_expected(expected)), "invalid testcase output"
|
321
|
+
assert_eq serr, ""
|
322
|
+
#
|
323
|
+
ret, sout, serr = run("-s", "compact", @testfile)
|
324
|
+
assert_eq ret, 2
|
325
|
+
assert edit_actual(sout).start_with?(edit_expected(expected)), "invalid testcase output"
|
326
|
+
assert_eq serr, ""
|
327
|
+
end
|
328
|
+
|
292
329
|
it "[!244te] '-s plain' or '-sp' option prints test results in plain mode." do
|
293
330
|
expected = <<END
|
294
|
-
<
|
331
|
+
<C>.</C><C>.</C><R>f</R><E>E</E><Y>s</Y><Y>t</Y><C>.</C><C>.</C>
|
295
332
|
----------------------------------------------------------------------
|
296
333
|
END
|
297
334
|
#
|
@@ -308,7 +345,7 @@ END
|
|
308
345
|
|
309
346
|
it "[!ai61w] '-s quiet' or '-sq' option prints test results in quiet mode." do
|
310
347
|
expected = <<END
|
311
|
-
<R>f</R><
|
348
|
+
<R>f</R><E>E</E><Y>s</Y><Y>t</Y>
|
312
349
|
----------------------------------------------------------------------
|
313
350
|
END
|
314
351
|
#
|
@@ -325,11 +362,12 @@ END
|
|
325
362
|
|
326
363
|
it "[!yz7g5] '-F topic=...' option filters topics." do
|
327
364
|
expected = <<END
|
365
|
+
## _tmp_test.rb
|
328
366
|
* <b>Parent</b>
|
329
367
|
* <b>Child1</b>
|
330
|
-
- [<
|
331
|
-
- [<
|
332
|
-
## total:2 (<
|
368
|
+
- [<C>pass</C>] 1+1 should be 2
|
369
|
+
- [<C>pass</C>] 1-1 should be 0
|
370
|
+
## total:2 (<C>pass:2</C>, fail:0, error:0, skip:0, todo:0) in 0.000s
|
333
371
|
END
|
334
372
|
#
|
335
373
|
ret, sout, serr = run("-F", "topic=Child1", @testfile)
|
@@ -340,10 +378,11 @@ END
|
|
340
378
|
|
341
379
|
it "[!ww2mp] '-F spec=...' option filters specs." do
|
342
380
|
expected = <<END
|
381
|
+
## _tmp_test.rb
|
343
382
|
* <b>Parent</b>
|
344
383
|
* <b>Child1</b>
|
345
|
-
- [<
|
346
|
-
## total:1 (<
|
384
|
+
- [<C>pass</C>] 1-1 should be 0
|
385
|
+
## total:1 (<C>pass:1</C>, fail:0, error:0, skip:0, todo:0) in 0.000s
|
347
386
|
END
|
348
387
|
#
|
349
388
|
ret, sout, serr = run("-F", "spec=*1-1*", @testfile)
|
@@ -354,15 +393,16 @@ END
|
|
354
393
|
|
355
394
|
it "[!8uvib] '-F tag=...' option filters by tag name." do
|
356
395
|
expected = <<'END'
|
396
|
+
## _tmp_test.rb
|
357
397
|
* <b>Parent</b>
|
358
398
|
* <b>Child1</b>
|
359
|
-
- [<
|
399
|
+
- [<C>pass</C>] 1-1 should be 0
|
360
400
|
* <b>Child3</b>
|
361
401
|
- [<Y>Skip</Y>] skip example <Y>(reason: a certain condition)</Y>
|
362
402
|
- [<Y>TODO</Y>] todo example
|
363
403
|
- <b>When x is negative</b>
|
364
|
-
- [<
|
365
|
-
## total:4 (<
|
404
|
+
- [<C>pass</C>] [!6hs1j] x*x is positive.
|
405
|
+
## total:4 (<C>pass:2</C>, fail:0, error:0, <Y>skip:1</Y>, <Y>todo:1</Y>) in 0.000s
|
366
406
|
END
|
367
407
|
#
|
368
408
|
ret, sout, serr = run("-F", "tag={new,exp}", @testfile)
|
@@ -373,10 +413,11 @@ END
|
|
373
413
|
|
374
414
|
it "[!m0iwm] '-F sid=...' option filters by spec id." do
|
375
415
|
expected = <<'END'
|
416
|
+
## _tmp_test.rb
|
376
417
|
* <b>Parent</b>
|
377
418
|
- <b>When x is negative</b>
|
378
|
-
- [<
|
379
|
-
## total:1 (<
|
419
|
+
- [<C>pass</C>] [!6hs1j] x*x is positive.
|
420
|
+
## total:1 (<C>pass:1</C>, fail:0, error:0, skip:0, todo:0) in 0.000s
|
380
421
|
END
|
381
422
|
#
|
382
423
|
ret, sout, serr = run("-F", "sid=6hs1j", @testfile)
|
@@ -387,13 +428,14 @@ END
|
|
387
428
|
|
388
429
|
it "[!noi8i] '-F' option supports negative filter." do
|
389
430
|
expected = <<'END'
|
431
|
+
## _tmp_test.rb
|
390
432
|
* <b>Parent</b>
|
391
433
|
* <b>Child1</b>
|
392
|
-
- [<
|
393
|
-
- [<
|
434
|
+
- [<C>pass</C>] 1+1 should be 2
|
435
|
+
- [<C>pass</C>] 1-1 should be 0
|
394
436
|
- <b>Else</b>
|
395
|
-
- [<
|
396
|
-
## total:3 (<
|
437
|
+
- [<C>pass</C>] [!pwiq7] x*x is also positive.
|
438
|
+
## total:3 (<C>pass:3</C>, fail:0, error:0, skip:0, todo:0) in 0.000s
|
397
439
|
END
|
398
440
|
#
|
399
441
|
ret, sout, serr = run("-F", "tag!={fail,err,exp}", @testfile)
|
@@ -408,12 +450,23 @@ END
|
|
408
450
|
end
|
409
451
|
end
|
410
452
|
|
453
|
+
it "[!j01y7] if filerting by '-F' matched nothing, then prints zero result." do
|
454
|
+
expected = <<'END'
|
455
|
+
## total:0 (pass:0, fail:0, error:0, skip:0, todo:0) in 0.000s
|
456
|
+
END
|
457
|
+
#
|
458
|
+
ret, sout, serr = run("-F", "tag=blablabla", @testfile)
|
459
|
+
assert_eq ret, 0
|
460
|
+
assert_eq edit_actual(sout), edit_expected(expected)
|
461
|
+
assert_eq serr, ""
|
462
|
+
end
|
463
|
+
|
411
464
|
it "[!6ro7j] '--color=on' option enables output coloring forcedly." do
|
412
465
|
[true, false].each do |bool|
|
413
466
|
[true, false].each do |tty|
|
414
467
|
Oktest::Config.color_enabled = bool
|
415
468
|
_, sout, serr = run("--color=on", @testfile, tty: tty)
|
416
|
-
assert sout.include?(edit_expected("[<
|
469
|
+
assert sout.include?(edit_expected("[<C>pass</C>]")), "should contain blue string"
|
417
470
|
assert sout.include?(edit_expected("[<R>Fail</R>]")), "should contain red string"
|
418
471
|
assert sout.include?(edit_expected("[<Y>Skip</Y>]")), "should contain yellos string"
|
419
472
|
assert_eq serr, ""
|
@@ -426,7 +479,7 @@ END
|
|
426
479
|
[true, false].each do |tty|
|
427
480
|
Oktest::Config.color_enabled = bool
|
428
481
|
_, sout, serr = run("--color", @testfile, tty: tty)
|
429
|
-
assert sout.include?(edit_expected("[<
|
482
|
+
assert sout.include?(edit_expected("[<C>pass</C>]")), "should contain blue string"
|
430
483
|
assert sout.include?(edit_expected("[<R>Fail</R>]")), "should contain red string"
|
431
484
|
assert sout.include?(edit_expected("[<Y>Skip</Y>]")), "should contain yellos string"
|
432
485
|
assert_eq serr, ""
|
@@ -439,7 +492,7 @@ END
|
|
439
492
|
[true, false].each do |tty|
|
440
493
|
Oktest::Config.color_enabled = bool
|
441
494
|
_, sout, serr = run("--color=off", @testfile, tty: tty)
|
442
|
-
assert !sout.include?(edit_expected("[<
|
495
|
+
assert !sout.include?(edit_expected("[<C>pass</C>]")), "should not contain blue string"
|
443
496
|
assert !sout.include?(edit_expected("[<R>Fail</R>]")), "should not contain red string"
|
444
497
|
assert !sout.include?(edit_expected("[<Y>Skip</Y>]")), "should not contain yellos string"
|
445
498
|
assert_eq serr, ""
|
@@ -453,8 +506,8 @@ END
|
|
453
506
|
end
|
454
507
|
end
|
455
508
|
|
456
|
-
it "[!dk8eg] '-
|
457
|
-
ret, sout, serr = run("-
|
509
|
+
it "[!dk8eg] '-S' or '--skeleton' option prints test code skeleton." do
|
510
|
+
ret, sout, serr = run("-S")
|
458
511
|
assert_eq ret, 0
|
459
512
|
assert_eq sout, Oktest::MainApp::SKELETON
|
460
513
|
assert_eq serr, ""
|