Description:
[grader] fixed the case when result file is ill-formatted git-svn-id: http://theory.cpe.ku.ac.th/grader/judge/trunk/scripts@130 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r34:4907486f53b2 - - 2 files changed: 16 inserted, 6 deleted

@@ -45,15 +45,19
45 :comment => "Grading error: #{msg}" })
45 :comment => "Grading error: #{msg}" })
46 end
46 end
47
47
48 protected
48 protected
49 def read_result(test_result_dir)
49 def read_result(test_result_dir)
50 cmp_msg_fname = "#{test_result_dir}/compiler_message"
50 cmp_msg_fname = "#{test_result_dir}/compiler_message"
51 - cmp_file = File.open(cmp_msg_fname)
51 + if FileTest.exist?(cmp_msg_fname)
52 - cmp_msg = cmp_file.read
52 + cmp_file = File.open(cmp_msg_fname)
53 - cmp_file.close
53 + cmp_msg = cmp_file.read
54 + cmp_file.close
55 + else
56 + cmp_msg = ""
57 + end
54
58
55 result_fname = "#{test_result_dir}/result"
59 result_fname = "#{test_result_dir}/result"
56 comment_fname = "#{test_result_dir}/comment"
60 comment_fname = "#{test_result_dir}/comment"
57 if FileTest.exist?(result_fname)
61 if FileTest.exist?(result_fname)
58 comment = ""
62 comment = ""
59 begin
63 begin
@@ -53,15 +53,21
53 run_comment += "result file for test #{test_num} not found\n"
53 run_comment += "result file for test #{test_num} not found\n"
54 run_comment_short += RUN_ERROR_MARK
54 run_comment_short += RUN_ERROR_MARK
55 log "Cannot find the file #{test_num}/result!"
55 log "Cannot find the file #{test_num}/result!"
56 else
56 else
57 result_file = File.new(result_file_name, "r")
57 result_file = File.new(result_file_name, "r")
58 result_file_lines = result_file.readlines
58 result_file_lines = result_file.readlines
59 - run_score = run_score + result_file_lines[1].to_i
59 + if result_file_lines.length>=2
60 - run_comment += result_file_lines[0]
60 + run_score = run_score + result_file_lines[1].to_i
61 - run_comment_short += char_comment(result_file_lines[0])
61 + run_comment += result_file_lines[0]
62 + run_comment_short += char_comment(result_file_lines[0])
63 + else
64 + run_comment += "result file for test #{test_num} error\n"
65 + run_comment_short += RUN_ERROR_MARK
66 + log "Error in #{test_num}/result!"
67 + end
62 result_file.close
68 result_file.close
63 end
69 end
64 end
70 end
65
71
66 # find total score for this run
72 # find total score for this run
67 run_total_score = 0
73 run_total_score = 0
You need to be logged in to leave comments. Login now