diff --git a/import_problem b/import_problem --- a/import_problem +++ b/import_problem @@ -102,11 +102,11 @@ # wrapper script check_script_fname = res[1] script_name = File.basename(check_script_fname) - check_wrapper_template = File.open(SCRIPT_DIR + "/templates/check_wrapper") - check_wrapper = ERB.new(template) + check_wrapper_template = File.open(SCRIPT_DIR + "/templates/check_wrapper").read + check_wrapper = ERB.new(check_wrapper_template) check_file = File.open("#{problem}/script/check","w") - check_file.puts check_wrapper + check_file.puts check_wrapper.result check_file.close File.chmod(0755,"#{problem}/script/check") diff --git a/std-script/grade b/std-script/grade --- a/std-script/grade +++ b/std-script/grade @@ -1,5 +1,10 @@ #!/usr/bin/ruby +CORRECT_MARK = 'P' +INCORRECT_MARK = '-' +TIMEOUT_MARK = 'T' +RUN_ERROR_MARK = 'x' + def log(str='') if ENV['TALKATIVE']!=nil puts str @@ -14,13 +19,13 @@ def char_comment(comment) if comment =~ /[iI]ncorrect/ - '-' + INCORRECT_MARK elsif comment =~ /[Cc]orrect/ - 'P' + CORRECT_MARK elsif comment =~ /[Tt]ime/ - 'T' + TIMEOUT_MARK else - 'x' # these are run time errors + RUN_ERROR_MARK # these are run time errors end end @@ -46,7 +51,7 @@ result_file_name = "#{test_num}/result" if not File.exists?(result_file_name) run_comment += "result file for test #{test_num} not found\n" - run_comment_short += 'x' + run_comment_short += RUN_ERROR_MARK log "Cannot find the file #{test_num}/result!" else result_file = File.new(result_file_name, "r") diff --git a/std-script/judge b/std-script/judge --- a/std-script/judge +++ b/std-script/judge @@ -16,9 +16,9 @@ def execute(command, error_message="") if not system(command) - log "ERROR: #{error_message}" - puts "ERROR: #{error_message}" - exit(127) + msg = "ERROR: #{error_message}" + log msg + raise msg end end @@ -105,7 +105,11 @@ (1..(problem.num_tests)).each do |test_num| log "Test number: #{test_num}" execute("cp #{test_result_dir}/a.out #{sandbox_dir}", "Cannot copy the compiled program into #{sandbox_dir}") - execute("#{problem_home}/script/run #{language} #{test_num}", "Error occured during execution of the run script") + begin + execute("#{problem_home}/script/run #{language} #{test_num}", "Error occured during execution of the run script") + rescue + # do nothing + end execute("mkdir #{test_result_dir}/#{test_num}", "Cannot create directory #{test_result_dir}/#{test_num}") execute("mv #{sandbox_dir}/result #{test_result_dir}/#{test_num}", "Cannot copy the result file into #{test_result_dir}/#{test_num}") execute("mv #{sandbox_dir}/comment #{test_result_dir}/#{test_num}", "Cannot copy the comment file into #{test_result_dir}/#{test_num}") diff --git a/std-script/run b/std-script/run --- a/std-script/run +++ b/std-script/run @@ -133,6 +133,7 @@ log check_command if not system(check_command) log "Problem with check script" + report.call("Incorrect",0,"Check script error.\n") exit(127) end diff --git a/templates/check_wrapper b/templates/check_wrapper --- a/templates/check_wrapper +++ b/templates/check_wrapper @@ -34,12 +34,15 @@ load "#{problem_home}/test_cases/all_tests.cfg" problem = Problem.get_instance -answer_file_name = File.new("#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt") -input_file_name = File.new("#{problem_home}/test_cases/#{test_num}/input-#{test_num}.txt") +answer_file_name = "#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt" +input_file_name = "#{problem_home}/test_cases/#{test_num}/input-#{test_num}.txt" -score = Problem.get_score(test_num) +score = problem.get_score(test_num) cmd = "#{problem_home}/script/#{REAL_CHECK_SCRIPT} " + "#{language} #{test_num} #{input_file_name} #{output_file_name} " + "#{answer_file_name} #{score} > check_result" +#puts "wrapper-CMD: #{cmd}" + +system(cmd)