diff --git a/std-script/judge b/std-script/judge --- a/std-script/judge +++ b/std-script/judge @@ -28,7 +28,7 @@ begin yield rescue - msg = "ERROR: #{error_message}" + msg = "JUDGE: ERROR: #{error_message}" log msg raise msg end @@ -54,18 +54,18 @@ language = ARGV[0] if language != "c" && language != "c++" && language != "pas" && language != "java" && language != "ruby" && language != "python" && language != "php" && language != "haskell" - log "You specified a language that is not supported: #{language}." + log "JUDGE: You specified a language that is not supported: #{language}." exit(127) end source_file = ARGV[1] ENV['SOURCE_NAME'] = source_file if File.exist?(source_file) == false - log "The source file does not exist." + log "JUDGE: The source file does not exist." exit(127) end -log "Making test result and sandbox directories..." +log "JUDGE: Making test result and sandbox directories..." current_dir = FileUtils.pwd current_dir.strip! @@ -76,7 +76,7 @@ test_result_dir = "#{current_dir}/test-result" end -log "Test result directory: #{test_result_dir}" +log "JUDGE: Test result directory: #{test_result_dir}" clear_and_create_empty_dir(test_result_dir) if ARGV.length >= 4 @@ -84,19 +84,21 @@ else sandbox_dir = "#{current_dir}/sandbox" end -log "Sandbox directory: #{sandbox_dir}" +log "JUDGE: Sandbox directory: #{sandbox_dir}" clear_and_create_empty_dir(sandbox_dir) +# ------------------------------ # Compile +# ------------------------------ +log "JUDGE: Compiling..." log -log "Compiling..." call_and_log("Cannot copy the source file to #{sandbox_dir}") { FileUtils.cp(source_file, sandbox_dir) } begin Dir.chdir sandbox_dir rescue - log "ERROR: Cannot change directory to #{sandbox_dir}." + log "JUDGE: ERROR: Cannot change directory to #{sandbox_dir}." exit(127) end execute("#{problem_home}/script/compile #{language} #{source_file}", "Compilation error!") @@ -106,7 +108,7 @@ FileUtils.mv("compiler_message", test_result_dir) } if !FileTest.exist?("a.out") - log "Cannot compile the source code. See message in #{test_result_dir}/compile_message" + log "JUDGE: EROOR: Cannot compile the source code. See message in #{test_result_dir}/compile_message" exit(127) else call_and_log("Cannot move the compiled program to #{test_result_dir}") { @@ -117,6 +119,10 @@ FileUtils.rm_rf("#{sandbox_dir}/.") end + +#----------------------------------------------- +# run +#----------------------------------------------- require "#{problem_home}/script/test_dsl.rb" load "#{problem_home}/test_cases/all_tests.cfg" problem = Problem.get_instance @@ -127,13 +133,13 @@ end # Doing the testing. +log +log "JUDGE: Running each test case..." (1..(problem.num_tests)).each do |test_num| $stdout.print "[#{test_num}]" $stdout.flush - log "Test number: #{test_num}" - call_and_log("Cannot copy the compiled program into #{sandbox_dir}") { FileUtils.cp("#{test_result_dir}/a.out", sandbox_dir, :preserve => true) if language == "java" then Dir["#{test_result_dir}/*.class"].each { |file| FileUtils.cp(file,sandbox_dir)} end @@ -173,7 +179,7 @@ # Grade log -log "Grading..." +log "JUDGE: Grading..." begin Dir.chdir test_result_dir rescue