Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 19b5d7bb47
Fetching contributors…

Cannot retrieve contributors at this time

executable file 57 lines (47 sloc) 1.17 kb
#!/usr/bin/env ruby
require "fileutils"
class TestRunner
include FileUtils
def initialize(pattern, dir)
@total = 0
@failures = []
@pattern = pattern
@dir = dir
end
def run
cd @dir do
Dir[@pattern].each do |file|
expected = File.read(file).split("\n").map { |l| l[/^# => (.*)$/, 1] }.compact.join("\n")
actual = tinyrb(file)
if expected == actual
pass(file)
else
fail(file, expected, actual)
end
end
puts
@failures.each do |file, expected, actual|
puts "[%s]" % file
puts " expected #{expected.inspect}"
puts " got #{actual.inspect}"
puts
end
puts "#{@total} tests, #{@failures.size} failures"
end
end
protected
def tinyrb(*args)
cmd = "./tinyrb #{args * ' '}"
`#{cmd}`.chomp
end
def pass(file)
@total += 1
print "."
end
def fail(file, expected, actual)
@total += 1
@failures << [file, expected, actual]
print "F"
end
end
TestRunner.new("test/*.rb", File.dirname(__FILE__) + "/..").run
Jump to Line
Something went wrong with that request. Please try again.