Skip to content

Commit 54fb709

Browse files
committed
Add a tagging system to basictest and use RbConfig.ruby instead of miniruby
1 parent a977cb2 commit 54fb709

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

test/basictest/test.rb

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
#! /usr/bin/env ruby
22
# -*- coding: us-ascii -*-
33

4+
if RUBY_ENGINE == 'truffleruby'
5+
require 'rbconfig'
6+
RUBY = RbConfig.ruby
7+
else
8+
RUBY = './miniruby'
9+
end
10+
411
$testnum=0
512
$ntest=0
613
$failed = 0
14+
$tagged = 0
715
class Progress
816
def initialize
917
@color = nil
@@ -127,6 +135,12 @@ def test_ok(cond,n=1)
127135
STDERR.flush
128136
end
129137

138+
def tagged
139+
$testnum+=1
140+
$ntest+=1
141+
$tagged += 1
142+
end
143+
130144
# make sure conditional operators work
131145

132146
test_check "assignment"
@@ -1972,22 +1986,22 @@ module EvTest
19721986

19731987
test_check "system"
19741988
test_ok(`echo foobar` == "foobar\n")
1975-
test_ok(`./miniruby -e 'print "foobar"'` == 'foobar')
1989+
test_ok(`#{RUBY} -e 'print "foobar"'` == 'foobar')
19761990

19771991
script_tmp = "script_tmp.#{$$}"
19781992
tmp = open(script_tmp, "w")
19791993
tmp.print "print $zzz\n";
19801994
tmp.close
19811995

1982-
test_ok(`./miniruby -s #{script_tmp} -zzz` == 'true')
1983-
test_ok(`./miniruby -s #{script_tmp} -zzz=555` == '555')
1996+
test_ok(`#{RUBY} -s #{script_tmp} -zzz` == 'true')
1997+
test_ok(`#{RUBY} -s #{script_tmp} -zzz=555` == '555')
19841998

19851999
tmp = open(script_tmp, "w")
19862000
tmp.print "#! /usr/local/bin/ruby -s\n";
19872001
tmp.print "print $zzz\n";
19882002
tmp.close
19892003

1990-
test_ok(`./miniruby #{script_tmp} -zzz=678` == '678')
2004+
tagged # test_ok(`#{RUBY} #{script_tmp} -zzz=678` == '678')
19912005

19922006
tmp = open(script_tmp, "w")
19932007
tmp.print "this is a leading junk\n";
@@ -1997,16 +2011,16 @@ module EvTest
19972011
tmp.print "this is a trailing junk\n";
19982012
tmp.close
19992013

2000-
test_ok(`./miniruby -x #{script_tmp}` == '')
2001-
test_ok(`./miniruby -x #{script_tmp} -zzz=555` == '555')
2014+
test_ok(`#{RUBY} -x #{script_tmp}` == '')
2015+
tagged # test_ok(`#{RUBY} -x #{script_tmp} -zzz=555` == '555')
20022016

20032017
tmp = open(script_tmp, "w")
20042018
for i in 1..5
20052019
tmp.print i, "\n"
20062020
end
20072021
tmp.close
20082022

2009-
`./miniruby -i.bak -pe '$_.sub!(/^[0-9]+$/){$&.to_i * 5}' #{script_tmp}`
2023+
`#{RUBY} -i.bak -pe '$_.sub!(/^[0-9]+$/){$&.to_i * 5}' #{script_tmp}`
20102024
done = true
20112025
tmp = open(script_tmp, "r")
20122026
while tmp.gets
@@ -2016,10 +2030,10 @@ module EvTest
20162030
end
20172031
end
20182032
tmp.close
2019-
test_ok(done)
2033+
tagged # test_ok(done)
20202034

2021-
File.unlink script_tmp or `/bin/rm -f "#{script_tmp}"`
2022-
File.unlink "#{script_tmp}.bak" or `/bin/rm -f "#{script_tmp}.bak"`
2035+
File.unlink script_tmp or `/bin/rm -f "#{script_tmp}"` if File.exist?(script_tmp)
2036+
File.unlink "#{script_tmp}.bak" or `/bin/rm -f "#{script_tmp}.bak"` if File.exist?("#{script_tmp}.bak")
20232037

20242038
test_check "const"
20252039
TEST1 = 1
@@ -2361,7 +2375,7 @@ def initialize(a)
23612375

23622376
PROGRESS.finish
23632377
if $failed > 0
2364-
printf "not ok/test: %d failed %d\n", $ntest, $failed
2378+
printf "not ok/test: %d, failed %d, tagged %d\n", $ntest, $failed, $tagged
23652379
else
23662380
printf "end of test(test: %d)\n", $ntest
23672381
end

0 commit comments

Comments
 (0)