Sha256: 52d108804a6034d687842b06f15e106c1f8615baf87059aa71df957e2be66e98
Contents?: true
Size: 1.86 KB
Versions: 3
Compression:
Stored size: 1.86 KB
Contents
mydir = File.dirname(__FILE__) $:.unshift mydir + '/../lib/' $VERBOSE = true require 'test/unit' include Test::Unit class CodeRaySuite < TestCase def self.dir &block @dir ||= File.dirname(__FILE__) if block Dir.chdir @dir, &block end @dir end def dir &block self.class.dir(&block) end def test_ALL dir do for input in Dir["demo_*.rb"] - %w(demo_server.rb demo_stream.rb) puts "[ testing #{input}... ]" name = File.basename(input, ".rb") output = name + '.out' code = File.open(input, 'rb') { |f| break f.read } result = `ruby -wI../lib #{input}` if File.exist? output expected = File.read output ok = expected == result computed = output.sub('.out', '.computed') unless ok File.open(computed, 'w') { |f| f.write result } print `gvimdiff #{output} #{computed}` if $DEBUG end assert(ok, "Output error: #{computed} != #{output}") unless $DEBUG else File.open(output, 'w') do |f| f.write result end puts "New test: #{output}" end end end end end require 'test/unit/testsuite' $suite = TestSuite.new 'CodeRay Demos Test' $suite << CodeRaySuite.suite def load_suite name begin require name + '/suite.rb' rescue LoadError $stderr.puts <<-ERR !! Folder #{File.split(__FILE__).first + '/' + name} not found ERR false end end if subsuite = ARGV.find { |a| break $1 if a[/^([^-].*)/] } load_suite(subsuite) or exit else Dir[mydir + '/*/'].each { |suite| load_suite suite } end if ARGV.include? '-f' require 'test/unit/ui/fox/testrunner' UI::Fox::TestRunner.run $suite else require 'test/unit/ui/console/testrunner' UI::Console::TestRunner.run $suite end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
coderay-0.7.2.165 | ./demo/suite.rb |
coderay-0.7.2.168 | ./demo/suite.rb |
coderay-0.7.2.176 | ./demo/suite.rb |