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
@@ -46,41 +46,57 | |||
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | protected |
|
49 | 49 | def read_result(test_result_dir) |
|
50 | 50 | cmp_msg_fname = "#{test_result_dir}/compiler_message" |
|
51 | 51 | cmp_file = File.open(cmp_msg_fname) |
|
52 | 52 | cmp_msg = cmp_file.read |
|
53 | 53 | cmp_file.close |
|
54 | 54 | |
|
55 | 55 | result_fname = "#{test_result_dir}/result" |
|
56 | 56 | comment_fname = "#{test_result_dir}/comment" |
|
57 | 57 | if FileTest.exist?(result_fname) |
|
58 | + comment = "" | |
|
59 | + begin | |
|
58 | 60 | result_file = File.open(result_fname) |
|
59 | 61 | result = result_file.readline.to_i |
|
60 | 62 | result_file.close |
|
63 | + rescue | |
|
64 | + result = 0 | |
|
65 | + comment = "error reading result file." | |
|
66 | + end | |
|
61 | 67 | |
|
68 | + begin | |
|
62 | 69 | comment_file = File.open(comment_fname) |
|
63 | - comment = comment_file.readline.chomp | |
|
70 | + comment += comment_file.readline.chomp | |
|
64 | 71 | comment_file.close |
|
72 | + rescue | |
|
73 | + comment += "" | |
|
74 | + end | |
|
65 | 75 | |
|
66 | 76 | return {:points => result, |
|
67 | 77 | :comment => comment, |
|
68 | 78 | :cmp_msg => cmp_msg} |
|
69 | 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 | 85 | return {:points => 0, |
|
71 | 86 | :comment => 'compile error', |
|
72 | 87 | :cmp_msg => cmp_msg} |
|
73 | 88 | end |
|
74 | 89 | end |
|
90 | + end | |
|
75 | 91 | |
|
76 | 92 | def save_result(submission,result) |
|
77 | 93 | problem = submission.problem |
|
78 | 94 | submission.graded_at = Time.now |
|
79 | 95 | points = result[:points] |
|
80 | 96 | submission.points = points |
|
81 | 97 | comment = @config.report_comment(result[:comment]) |
|
82 | 98 | if problem == nil |
|
83 | 99 | submission.grader_comment = 'PASSED: ' + comment + '(problem is nil)' |
|
84 | 100 | elsif points == problem.full_score |
|
85 | 101 | submission.grader_comment = 'PASSED: ' + comment |
|
86 | 102 | else |
@@ -36,35 +36,36 | |||
|
36 | 36 | |
|
37 | 37 | all_score = 0 |
|
38 | 38 | all_comment = '' |
|
39 | 39 | (1..(problem.runs.length-1)).each do |k| |
|
40 | 40 | log "grade run #{k}" |
|
41 | 41 | run = problem.runs[k] |
|
42 | 42 | run_score = 0 |
|
43 | 43 | run_comment = '' |
|
44 | 44 | run_comment_short = '' |
|
45 | 45 | run.tests.each do |test_num| |
|
46 | 46 | result_file_name = "#{test_num}/result" |
|
47 | 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 | 50 | log "Cannot find the file #{test_num}/result!" |
|
49 | - exit(127) | |
|
50 | - end | |
|
51 | - | |
|
51 | + else | |
|
52 | 52 | result_file = File.new(result_file_name, "r") |
|
53 | 53 | result_file_lines = result_file.readlines |
|
54 | 54 | run_score = run_score + result_file_lines[1].to_i |
|
55 | 55 | run_comment += result_file_lines[0] |
|
56 | 56 | run_comment_short += char_comment(result_file_lines[0]) |
|
57 | 57 | result_file.close |
|
58 | 58 | end |
|
59 | + end | |
|
59 | 60 | |
|
60 | 61 | run_result_file = File.new("result-#{k}", "w") |
|
61 | 62 | run_result_file.write run_score |
|
62 | 63 | run_result_file.write "\n" |
|
63 | 64 | run_result_file.close |
|
64 | 65 | |
|
65 | 66 | run_comment_file = File.new("comment-#{k}", "w") |
|
66 | 67 | run_comment_file.write "#{run_comment}\n" |
|
67 | 68 | run_comment_file.close |
|
68 | 69 | |
|
69 | 70 | all_score = all_score + run_score |
|
70 | 71 | all_comment += run_comment_short |
@@ -7,24 +7,25 | |||
|
7 | 7 | if ENV['GRADER_LOGGING']!=nil |
|
8 | 8 | log_fname = ENV['GRADER_LOGGING'] |
|
9 | 9 | fp = File.open(log_fname,"a") |
|
10 | 10 | fp.puts("judge: #{Time.new.strftime("%H:%M")} #{str}") |
|
11 | 11 | fp.close |
|
12 | 12 | end |
|
13 | 13 | end |
|
14 | 14 | |
|
15 | 15 | problem_home = ENV['PROBLEM_HOME'] |
|
16 | 16 | |
|
17 | 17 | def execute(command, error_message="") |
|
18 | 18 | if not system(command) |
|
19 | + log "ERROR: #{error_message}" | |
|
19 | 20 | puts "ERROR: #{error_message}" |
|
20 | 21 | exit(127) |
|
21 | 22 | end |
|
22 | 23 | end |
|
23 | 24 | |
|
24 | 25 | # ARGV[0] --- language |
|
25 | 26 | # ARGV[1] --- program source file |
|
26 | 27 | # ARGV[2] --- test result directory |
|
27 | 28 | # ARGV[3] --- sandbox directory |
|
28 | 29 | |
|
29 | 30 | if ARGV.length < 2 || ARGV.length > 4 |
|
30 | 31 | puts "Usage: judge <language> <program-source> [<test-result-directory>] [<sandbox-directory>]" |
@@ -123,19 +123,20 | |||
|
123 | 123 | |
|
124 | 124 | if running_time[:user].to_f + running_time[:sys].to_f > time_limit |
|
125 | 125 | log "Time limit exceeded." |
|
126 | 126 | report.call("Time limit exceeded", 0, "No comment.\n") |
|
127 | 127 | end |
|
128 | 128 | |
|
129 | 129 | # Run 'check' to evaluate the output. |
|
130 | 130 | #puts "There was no runtime error. Proceed to checking the output." |
|
131 | 131 | check_command = "#{problem_home}/script/check #{language} #{test_num}" |
|
132 | 132 | log "Checking the output..." |
|
133 | 133 | log check_command |
|
134 | 134 | if not system(check_command) |
|
135 | + log "Problem with check script" | |
|
135 | 136 | exit(127) |
|
136 | 137 | end |
|
137 | 138 | |
|
138 | 139 | check_file = File.new("check_result", "r") |
|
139 | 140 | check_file_lines = check_file.readlines |
|
140 | 141 | |
|
141 | 142 | report.call(check_file_lines[0], check_file_lines[1], "No comment.\n") |
You need to be logged in to leave comments.
Login now