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.

33 lines
559 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. puts " done ".center MAX_COLS, '-'
  15. end
  16. def grade(score)
  17. IO.new(3).write score
  18. exit
  19. end
  20. def comment(text)
  21. IO.new(4).write text + "\n"
  22. end
  23. def shake
  24. ARGV[0]
  25. end
  26. end
  27. end