class Cutest

Constants

CACHE
FILTER
VERSION

Public Class Methods

code(fn, ln) click to toggle source
# File lib/cutest.rb, line 49
def self.code(fn, ln)
  begin
    CACHE[fn][ln.to_i - 1].strip
  rescue
    "(Can't display line)"
  end
end
display_error() click to toggle source
# File lib/cutest.rb, line 57
def self.display_error
  print "\n#{$!.class}: "
  print "#{$!.message}\n"
end
display_trace(line) click to toggle source
# File lib/cutest.rb, line 62
def self.display_trace(line)
  fn, ln = line.split(":")

  puts "  line: #{code(fn, ln)}"
  puts "  file: #{fn} +#{ln}"
end
run(files) click to toggle source
# File lib/cutest.rb, line 8
def self.run(files)
  status = files.all? do |file|
    run_file(file)

    Process.wait2.last.success?
  end

  puts

  status
end
run_file(file) click to toggle source
# File lib/cutest.rb, line 20
def self.run_file(file)
  fork do
    begin
      load(file)

    rescue LoadError, SyntaxError
      display_error
      exit 1

    rescue StandardError
      trace = $!.backtrace
      pivot = trace.index { |line| line.match(file) }

      puts "\n  test: %s" % cutest[:test]

      if pivot
        other = trace[0..pivot].select { |line| line !~ FILTER }
        other.reverse.each { |line| display_trace(line) }
      else
        display_trace(trace.first)
      end

      display_error

      exit 1
    end
  end
end