Description:
added quick hack on running scripts, and compiler calls
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r111:06c23d391544 - - 4 files changed: 13 inserted, 11 deleted

@@ -114,13 +114,13
114 114 ENV['PROBLEM_HOME'] = problem_home
115 115
116 116 talk grading_dir
117 117 Dir.chdir grading_dir
118 118 cmd = "#{problem_home}/script/judge #{language} #{fname}"
119 119 talk "CMD: #{cmd}"
120 - system(cmd)
120 + system("ruby " + cmd)
121 121 end
122 122
123 123 def get_std_script_dir
124 124 GRADER_ROOT + '/std-script'
125 125 end
126 126
@@ -20,15 +20,15
20 20 fp = File.open(log_fname,"a")
21 21 fp.puts("run: #{Time.new.strftime("%H:%M")} #{str}")
22 22 fp.close
23 23 end
24 24 end
25 25
26 - C_COMPILER = "/usr/bin/gcc"
27 - CPLUSPLUS_COMPILER = "/usr/bin/g++"
28 - PASCAL_COMPILER = "/usr/bin/fpc"
26 + C_COMPILER = "gcc"
27 + CPLUSPLUS_COMPILER = "g++"
28 + PASCAL_COMPILER = "fpc"
29 29
30 30 C_OPTIONS = "-O2 -s -static -std=c99 -DCONTEST -lm -Wall"
31 31 CPLUSPLUS_OPTIONS = "-O2 -s -static -DCONTEST -lm -Wall"
32 32 PASCAL_OPTIONS = "-O1 -XS -dCONTEST"
33 33
34 34 # Check for the correct number of arguments. Otherwise, print usage.
@@ -95,15 +95,17
95 95 begin
96 96 Dir.chdir sandbox_dir
97 97 rescue
98 98 log "ERROR: Cannot change directory to #{sandbox_dir}."
99 99 exit(127)
100 100 end
101 - execute("#{problem_home}/script/compile #{language} #{source_file}", "Compilation error!")
102 - compile_message = open("compiler_message").read
103 - compile_message.strip!
101 + execute("ruby #{problem_home}/script/compile #{language} #{source_file}", "Compilation error!")
102 + open("compiler_message") do |f|
103 + compile_message = f.read
104 + compile_message.strip!
105 + end
104 106 call_and_log("Cannot move the compiler message to #{test_result_dir}.") {
105 107 FileUtils.mv("compiler_message", test_result_dir)
106 108 }
107 109 if !FileTest.exist?("a.out")
108 110 log "Cannot compile the source code. See message in #{test_result_dir}/compile_message"
109 111 exit(127)
@@ -131,13 +133,13
131 133
132 134 log "Test number: #{test_num}"
133 135 call_and_log("Cannot copy the compiled program into #{sandbox_dir}") {
134 136 FileUtils.cp("#{test_result_dir}/a.out", sandbox_dir)
135 137 }
136 138 begin
137 - execute("#{problem_home}/script/run #{language} #{test_num}", "Error occured during execution of the run script")
139 + execute("ruby #{problem_home}/script/run #{language} #{test_num}", "Error occured during execution of the run script")
138 140 rescue
139 141 # do nothing
140 142 end
141 143 call_and_log("Cannot create directory #{test_result_dir}/#{test_num}") {
142 144 FileUtils.mkdir "#{test_result_dir}/#{test_num}"
143 145 }
@@ -163,10 +165,10
163 165 begin
164 166 Dir.chdir test_result_dir
165 167 rescue
166 168 log "ERROR: Cannot change directory to #{test_result_dir}."
167 169 exit(127)
168 170 end
169 - execute("#{problem_home}/script/grade", "An error occured during grading!")
171 + execute("ruby #{problem_home}/script/grade", "An error occured during grading!")
170 172
171 173 log
172 174 log "All done!"
@@ -70,13 +70,13
70 70 mem_limit = problem.get_mem_limit(test_num) * 1024
71 71
72 72 # Copy the input file.
73 73 #`cp #{problem_home}/test_cases/#{test_num}/#{input_file_name} .`
74 74
75 75 # check if box is there, if not, compile it!
76 - if !File.exists?("#{problem_home}/script/box")
76 + if !File.exists?("#{problem_home}/script/box") and !File.exists?("#{problem_home}/script/box.exe")
77 77 log "WARNING: Compiling box: to increase efficiency, it should be compile manually"
78 78 compile_box("#{problem_home}/script/box.cc",
79 79 "#{problem_home}/script/box")
80 80 end
81 81
82 82 # Hide PROBLEM_HOME
@@ -142,13 +142,13
142 142
143 143 # Run 'check' to evaluate the output.
144 144 #puts "There was no runtime error. Proceed to checking the output."
145 145 check_command = "#{problem_home}/script/check #{language} #{test_num}"
146 146 log "Checking the output..."
147 147 log check_command
148 - if not system(check_command)
148 + if not system("ruby " + check_command)
149 149 log "Problem with check script"
150 150 report.call("Incorrect",0,"Check script error.\n")
151 151 exit(127)
152 152 end
153 153
154 154 check_file = File.new("check_result", "r")
You need to be logged in to leave comments. Login now