A code autograder for student homework submissions
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

42 行
757 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. exit
  21. end
  22. def comment(text)
  23. puts "comment: #{text}"
  24. IO.new(4).write text + "\n"
  25. end
  26. def shake
  27. ARGV[0]
  28. end
  29. def getpath(filename)
  30. File.join File.dirname($0), filename
  31. end
  32. end
  33. end