Description:
fixed: grader crashes when the problem has no test data
git-svn-id: http://theory.cpe.ku.ac.th/grader/judge/trunk/scripts@431 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
r83:285efa98811f - - 1 file changed: 5 inserted, 1 deleted
@@ -44,67 +44,71 | |||
|
44 | 44 | lang_ext = 'c' |
|
45 | 45 | end |
|
46 | 46 | |
|
47 | 47 | # FIX THIS |
|
48 | 48 | talk 'some hack on language' |
|
49 | 49 | if language == 'cpp' |
|
50 | 50 | language = 'c++' |
|
51 | 51 | end |
|
52 | 52 | |
|
53 | 53 | # COMMENT: should it be only source.ext? |
|
54 | 54 | if problem!=nil |
|
55 | 55 | source_name = "#{problem.name}.#{lang_ext}" |
|
56 | 56 | else |
|
57 | 57 | source_name = "source.#{lang_ext}" |
|
58 | 58 | end |
|
59 | 59 | |
|
60 | 60 | begin |
|
61 | 61 | grading_dir = @room_maker.produce_grading_room(submission) |
|
62 | 62 | @room_maker.save_source(submission,source_name) |
|
63 | 63 | problem_home = @room_maker.find_problem_home(submission) |
|
64 | 64 | |
|
65 | 65 | # puts "GRADING DIR: #{grading_dir}" |
|
66 | 66 | # puts "PROBLEM DIR: #{problem_home}" |
|
67 | 67 | |
|
68 | + if !FileTest.exist?(problem_home) | |
|
69 | + raise "No test data." | |
|
70 | + end | |
|
71 | + | |
|
68 | 72 | dinit = DirInit::Manager.new(problem_home) |
|
69 | 73 | |
|
70 | 74 | dinit.setup do |
|
71 | 75 | copy_log = copy_script(problem_home) |
|
72 | 76 | save_copy_log(problem_home,copy_log) |
|
73 | 77 | end |
|
74 | 78 | |
|
75 | 79 | call_judge(problem_home,language,grading_dir,source_name) |
|
76 | 80 | |
|
77 | 81 | @reporter.report(submission,"#{grading_dir}/test-result") |
|
78 | 82 | |
|
79 | 83 | dinit.teardown do |
|
80 | 84 | copy_log = load_copy_log(problem_home) |
|
81 | 85 | clear_copy_log(problem_home) |
|
82 | 86 | clear_script(copy_log,problem_home) |
|
83 | 87 | end |
|
84 | 88 | |
|
85 | 89 | rescue RuntimeError => msg |
|
86 |
- @reporter.report_error(submission, |
|
|
90 | + @reporter.report_error(submission, msg) | |
|
87 | 91 | |
|
88 | 92 | ensure |
|
89 | 93 | @room_maker.clean_up(submission) |
|
90 | 94 | Dir.chdir(current_dir) # this is really important |
|
91 | 95 | end |
|
92 | 96 | end |
|
93 | 97 | |
|
94 | 98 | protected |
|
95 | 99 | |
|
96 | 100 | def talk(str) |
|
97 | 101 | if @config.talkative |
|
98 | 102 | puts str |
|
99 | 103 | end |
|
100 | 104 | end |
|
101 | 105 | |
|
102 | 106 | def call_judge(problem_home,language,grading_dir,fname) |
|
103 | 107 | ENV['PROBLEM_HOME'] = problem_home |
|
104 | 108 | |
|
105 | 109 | talk grading_dir |
|
106 | 110 | Dir.chdir grading_dir |
|
107 | 111 | cmd = "#{problem_home}/script/judge #{language} #{fname}" |
|
108 | 112 | talk "CMD: #{cmd}" |
|
109 | 113 | system(cmd) |
|
110 | 114 | end |
You need to be logged in to leave comments.
Login now