瀏覽代碼

Safer runtime error handling.

master
Ben Kurtovic 8 年之前
父節點
當前提交
86d3a534ce
共有 2 個檔案被更改,包括 7 行新增2 行删除
  1. +6
    -1
      lib/kgrader/runtime.rb
  2. +1
    -1
      spec/cs241h

+ 6
- 1
lib/kgrader/runtime.rb 查看文件

@@ -7,17 +7,22 @@ module KGrader

def testcase(options)
puts " running test: #{File.basename $0} ".center MAX_COLS, '='

begin
Timeout::timeout options[:alarm] { yield }
rescue Timeout::Error
comment "timeout"
grade 0
end
puts " done ".center MAX_COLS, '-'

puts "no grade received?"
comment "autograde error (no grade reported); please contact staff"
grade 0
end

def grade(score)
IO.new(3).write score
puts " done ".center MAX_COLS, '-'
exit
end



+ 1
- 1
spec/cs241h

@@ -1 +1 @@
Subproject commit 514bd96d25d797ceb17f166f508e3195afb795f1
Subproject commit 22fd6cb688fcce712b4b68235533b59753aeaed7

Loading…
取消
儲存