Description:
[grader] report error when the check script crashed (i.e., when the result file is not found, while the compilation is okay)
git-svn-id: http://theory.cpe.ku.ac.th/grader/judge/trunk/scripts@117 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r30:8c0d78da1958 - - 4 files changed: 23 inserted, 4 deleted
@@ -55,23 +55,39 | |||||
|
55 | result_fname = "#{test_result_dir}/result" |
|
55 | result_fname = "#{test_result_dir}/result" |
|
56 | comment_fname = "#{test_result_dir}/comment" |
|
56 | comment_fname = "#{test_result_dir}/comment" |
|
57 | if FileTest.exist?(result_fname) |
|
57 | if FileTest.exist?(result_fname) |
|
|
58 | + comment = "" | ||
|
|
59 | + begin | ||
|
58 | result_file = File.open(result_fname) |
|
60 | result_file = File.open(result_fname) |
|
59 | result = result_file.readline.to_i |
|
61 | result = result_file.readline.to_i |
|
60 | result_file.close |
|
62 | result_file.close |
|
|
63 | + rescue | ||
|
|
64 | + result = 0 | ||
|
|
65 | + comment = "error reading result file." | ||
|
|
66 | + end | ||
|
61 |
|
67 | ||
|
|
68 | + begin | ||
|
62 | comment_file = File.open(comment_fname) |
|
69 | comment_file = File.open(comment_fname) |
|
63 | - comment = comment_file.readline.chomp |
|
70 | + comment += comment_file.readline.chomp |
|
64 | comment_file.close |
|
71 | comment_file.close |
|
|
72 | + rescue | ||
|
|
73 | + comment += "" | ||
|
|
74 | + end | ||
|
65 |
|
75 | ||
|
66 | return {:points => result, |
|
76 | return {:points => result, |
|
67 | :comment => comment, |
|
77 | :comment => comment, |
|
68 | :cmp_msg => cmp_msg} |
|
78 | :cmp_msg => cmp_msg} |
|
69 | else |
|
79 | else |
|
|
80 | + if FileTest.exist?("#{test_result_dir}/a.out") | ||
|
|
81 | + return {:points => 0, | ||
|
|
82 | + :comment => 'error during grading', | ||
|
|
83 | + :cmp_msg => cmp_msg} | ||
|
|
84 | + else | ||
|
70 | return {:points => 0, |
|
85 | return {:points => 0, |
|
71 | :comment => 'compile error', |
|
86 | :comment => 'compile error', |
|
72 | :cmp_msg => cmp_msg} |
|
87 | :cmp_msg => cmp_msg} |
|
73 | end |
|
88 | end |
|
74 | end |
|
89 | end |
|
|
90 | + end | ||
|
75 |
|
91 | ||
|
76 | def save_result(submission,result) |
|
92 | def save_result(submission,result) |
|
77 | problem = submission.problem |
|
93 | problem = submission.problem |
@@ -45,10 +45,10 | |||||
|
45 | run.tests.each do |test_num| |
|
45 | run.tests.each do |test_num| |
|
46 | result_file_name = "#{test_num}/result" |
|
46 | result_file_name = "#{test_num}/result" |
|
47 | if not File.exists?(result_file_name) |
|
47 | if not File.exists?(result_file_name) |
|
|
48 | + run_comment += "result file for test #{test_num} not found\n" | ||
|
|
49 | + run_comment_short += 'x' | ||
|
48 | log "Cannot find the file #{test_num}/result!" |
|
50 | log "Cannot find the file #{test_num}/result!" |
|
49 | - exit(127) |
|
51 | + else |
|
50 | - end |
|
||
|
51 | - |
|
||
|
52 | result_file = File.new(result_file_name, "r") |
|
52 | result_file = File.new(result_file_name, "r") |
|
53 | result_file_lines = result_file.readlines |
|
53 | result_file_lines = result_file.readlines |
|
54 | run_score = run_score + result_file_lines[1].to_i |
|
54 | run_score = run_score + result_file_lines[1].to_i |
@@ -56,6 +56,7 | |||||
|
56 | run_comment_short += char_comment(result_file_lines[0]) |
|
56 | run_comment_short += char_comment(result_file_lines[0]) |
|
57 | result_file.close |
|
57 | result_file.close |
|
58 | end |
|
58 | end |
|
|
59 | + end | ||
|
59 |
|
60 | ||
|
60 | run_result_file = File.new("result-#{k}", "w") |
|
61 | run_result_file = File.new("result-#{k}", "w") |
|
61 | run_result_file.write run_score |
|
62 | run_result_file.write run_score |
You need to be logged in to leave comments.
Login now