A code autograder for student homework submissions
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
525 B

  1. require 'timeout'
  2. module KGrader
  3. module Runtime
  4. MAX_COLS = 79
  5. def testcase(options)
  6. puts " running test: #{$0} ".center MAX_COLS, '='
  7. begin
  8. Timeout::timeout options[:alarm] { yield }
  9. rescue Timeout::Error
  10. comment "timeout"
  11. grade 0
  12. end
  13. puts " done ".center MAX_COLS, '-'
  14. end
  15. def grade(score)
  16. IO.new(3).write score
  17. exit
  18. end
  19. def comment(text)
  20. IO.new(4).write text + "\n"
  21. end
  22. def shake
  23. ARGV[0]
  24. end
  25. end
  26. end