sample/test.rb: refine output

* sample/test.rb (PROGRESS): refine output.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-05-07 18:51:26 +00:00
parent 9c4fc91c6b
commit 8da4634bc3
2 changed files with 53 additions and 2 deletions

View File

@ -1,3 +1,7 @@
Tue May 8 03:51:19 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sample/test.rb (PROGRESS): refine output.
Tue May 8 02:34:26 2012 NARUSE, Yui <naruse@ruby-lang.org>
* lib/minitest/unit.rb (assert_match): refix of r35563.

View File

@ -4,9 +4,55 @@
$testnum=0
$ntest=0
$failed = 0
PROGRESS = Object.new
PROGRESS.instance_eval do
@count = 0
@rotator = %w[- \\ | /]
@bs = "\b" * @rotator[0].size
@tty = STDERR.tty?
if @tty and /mswin|mingw/ !~ RUBY_PLATFORM and /dumb/ !~ ENV["TERM"]
@passed = "\e[32m"
@failed = "\e[31m"
@reset = "\e[m"
else
@passed = @failed = @reset = ""
end
if @tty
def self.pass
STDERR.print "#{@bs}#{@rotator[(@count += 1) % @rotator.size]}"
end
def self.fail
@ok = false
STDERR.print "#{@bs}#{@failed}F#{@reset}#{@rotator[@count % @rotator.size]}"
end
def self.init
@ok = true
STDERR.print " "
end
def self.finish
STDERR.print "#{@bs}#{' ' * @bs.size}#{@bs}#{@passed}#{@ok ? 'OK' : ''} #{$testnum}#{@reset}"
end
else
def self.pass
STDERR.print "."
end
def self.fail
STDERR.print "F"
end
def self.init
end
def self.finish
end
end
end
def test_check(what)
unless $ntest.zero?
PROGRESS.finish
end
STDERR.print "\nsample/test.rb:#{what} "
PROGRESS.init
$what = what
$testnum = 0
end
@ -16,10 +62,10 @@ def test_ok(cond,n=1)
$ntest+=1
where = (st = caller(n)) ? st[0] : "caller error! (n=#{n}, trace=#{caller(0).join(', ')}"
if cond
STDERR.print "."
PROGRESS.pass
printf "ok %d (%s)\n", $testnum, where
else
STDERR.print "F"
PROGRESS.fail
printf "not ok %s %d -- %s\n", $what, $testnum, where
$failed+=1
end
@ -2259,6 +2305,7 @@ ObjectSpace.each_object{|o|
test_ok true # reach here or dumps core
PROGRESS.finish
if $failed > 0
printf "not ok/test: %d failed %d\n", $ntest, $failed
else