Skip to content

Commit 83cf430

Browse files
committed
Add a tagging system to bootstraptest
1 parent 80c9083 commit 83cf430

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

test/bootstraptest/runner.rb

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ def erase(e = true)
186186
def exec_test(pathes)
187187
@count = 0
188188
@error = 0
189+
@tagged = 0
189190
@errbuf = []
190191
@location = nil
191192
@columns = 0
@@ -198,14 +199,15 @@ def exec_test(pathes)
198199
$stderr.puts if @verbose
199200
count = @count
200201
error = @error
202+
tagged = @tagged
201203
load File.expand_path(path)
202204
if @tty
203205
if @error == error
204-
msg = "PASS #{@count-count}"
206+
msg = "PASS #{(@count-count)-(@tagged-tagged)} (#{@tagged-tagged} tagged)"
205207
@columns += msg.size - 1
206208
$stderr.print "#{@progress_bs}#{@passed}#{msg}#{@reset}"
207209
else
208-
msg = "FAIL #{@error-error}/#{@count-count}"
210+
msg = "FAIL #{@error-error}/#{(@count-count)-(@tagged-tagged)} (#{@tagged-tagged} tagged)"
209211
$stderr.print "#{@progress_bs}#{@failed}#{msg}#{@reset}"
210212
@columns = 0
211213
end
@@ -217,14 +219,14 @@ def exec_test(pathes)
217219
if @count == 0
218220
$stderr.puts "No tests, no problem"
219221
else
220-
$stderr.puts "#{@passed}PASS#{@reset} all #{@count} tests"
222+
$stderr.puts "#{@passed}PASS#{@reset} all #{@count-@tagged} tests (#{@tagged} tagged)"
221223
end
222224
exit true
223225
else
224226
@errbuf.each do |msg|
225227
$stderr.puts msg
226228
end
227-
$stderr.puts "#{@failed}FAIL#{@reset} #{@error}/#{@count} tests failed"
229+
$stderr.puts "#{@failed}FAIL#{@reset} #{@error}/#{@count-@tagged} tests failed (#{@tagged} tagged)"
228230
exit false
229231
end
230232
end
@@ -269,6 +271,11 @@ def show_progress(message = '')
269271
end
270272

271273
def assert_check(testsrc, message = '', opt = '', **argh)
274+
if argh[:tagged]
275+
argh.delete :tagged
276+
@tagged += 1
277+
return
278+
end
272279
show_progress(message) {
273280
result = get_result_string(testsrc, opt, **argh)
274281
check_coredump
@@ -288,9 +295,9 @@ def assert_equal(expected, testsrc, message = '', opt = '', **argh)
288295
}
289296
end
290297

291-
def assert_match(expected_pattern, testsrc, message = '')
298+
def assert_match(expected_pattern, testsrc, message = '', **argh)
292299
newtest
293-
assert_check(testsrc, message) {|result|
300+
assert_check(testsrc, message, **argh) {|result|
294301
if expected_pattern =~ result
295302
nil
296303
else
@@ -300,9 +307,9 @@ def assert_match(expected_pattern, testsrc, message = '')
300307
}
301308
end
302309

303-
def assert_not_match(unexpected_pattern, testsrc, message = '')
310+
def assert_not_match(unexpected_pattern, testsrc, message = '', **argh)
304311
newtest
305-
assert_check(testsrc, message) {|result|
312+
assert_check(testsrc, message, **argh) {|result|
306313
if unexpected_pattern !~ result
307314
nil
308315
else
@@ -321,6 +328,11 @@ def assert_valid_syntax(testsrc, message = '')
321328

322329
def assert_normal_exit(testsrc, *rest, timeout: nil, **opt)
323330
newtest
331+
if opt[:tagged]
332+
opt.delete :tagged
333+
@tagged += 1
334+
return
335+
end
324336
message, ignore_signals = rest
325337
message ||= ''
326338
show_progress(message) {
@@ -371,9 +383,14 @@ def assert_normal_exit(testsrc, *rest, timeout: nil, **opt)
371383
}
372384
end
373385

374-
def assert_finish(timeout_seconds, testsrc, message = '')
386+
def assert_finish(timeout_seconds, testsrc, message = '', **argh)
375387
timeout_seconds *= 3 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # for --jit-wait
376388
newtest
389+
if argh[:tagged]
390+
argh.delete :tagged
391+
@tagged += 1
392+
return
393+
end
377394
show_progress(message) {
378395
faildesc = nil
379396
filename = make_srcfile(testsrc)

test/bootstraptest/test_insns.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,18 @@ class String; def =~ other; true; end; end
410410
[ 'opt_call_c_function', 'Struct.new(:x).new.x = true', ],
411411
]
412412

413+
def opts(a)
414+
opts = {}
415+
opts[a.pop] = true if a.last == :tagged
416+
opts.merge! a.pop if a.last.is_a?(Hash)
417+
[*a, opts]
418+
end
419+
413420
# normal path
414-
tests.compact.each {|(insn, expr, *a)| assert_equal 'true', expr, insn, *a }
421+
tests.compact.each {|(insn, expr, *a)| assert_equal 'true', expr, insn, *opts(a) }
415422

416423
# with trace
417424
tests.compact.each {|(insn, expr, *a)|
418425
progn = "set_trace_func(proc{})\n" + expr
419-
assert_equal 'true', progn, insn, *a
426+
assert_equal 'true', progn, insn, *opts(a)
420427
}

0 commit comments

Comments
 (0)