A code autograder for student homework submissions
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

43 righe
768 B

  1. require 'fileutils'
  2. require 'timeout'
  3. module KGrader
  4. module Runtime
  5. MAX_COLS = 79
  6. def testcase(options)
  7. puts " running test: #{File.basename $0} ".center MAX_COLS, '='
  8. begin
  9. Timeout::timeout options[:alarm] { yield }
  10. rescue Timeout::Error
  11. comment "timeout"
  12. grade 0
  13. end
  14. comment "autograde error (no grade reported); please contact staff"
  15. grade 0
  16. end
  17. def grade(score)
  18. IO.new(3).write score
  19. puts " done ".center MAX_COLS, '-'
  20. puts
  21. exit
  22. end
  23. def comment(text)
  24. puts "comment: #{text}"
  25. IO.new(4).write text + "\n"
  26. end
  27. def shake
  28. ARGV[0]
  29. end
  30. def getpath(filename)
  31. File.join File.dirname($0), filename
  32. end
  33. end
  34. end