diff --git a/lib/engine.rb b/lib/engine.rb --- a/lib/engine.rb +++ b/lib/engine.rb @@ -78,6 +78,7 @@ end talk "ENGINE: grading dir at #{grading_dir} is created" + talk "ENGINE: located problem home at #{problem_home} is created" # copy the source script, using lock dinit = DirInit::Manager.new(problem_home) diff --git a/std-script/judge b/std-script/judge --- a/std-script/judge +++ b/std-script/judge @@ -158,6 +158,8 @@ # do nothing end + + #copy the output of run script to each test-result folder call_and_log("Cannot create directory #{test_result_dir}/#{test_num}") { FileUtils.mkdir "#{test_result_dir}/#{test_num}" } diff --git a/std-script/run b/std-script/run --- a/std-script/run +++ b/std-script/run @@ -1,5 +1,19 @@ #!/usr/bin/env ruby +## +# This program should be run in the sandbox dir containing the compiled file +# (or source file for script language). It will call the sandbox program with +# the given input and process the output of the sandbox +# +# If sandbox exit normally, this program will call the "check" script to do +# scoring. Otherwise, it would record the error accordingly +# +# This program produces several file +# * result - the result from check script +# * comment - comment from sandbox +# * output - output of the program +# + require 'fileutils' def log(str='') @@ -29,6 +43,11 @@ system("g++ #{source} -o #{bin}") end +#------------------------------------------ +# MAIN +#------------------------------------------ + +#parse parameter if ARGV.length < 2 || ARGV.length > 3 puts "Usage: run []" exit(127) @@ -51,13 +70,13 @@ sandbox_dir = Dir.getwd if problem.well_formed? == false - log "RUN: The problem specification is not well formed." + log "RUN: ERROR: The problem specification is not well formed." exit(127) end # Check if the test number is okay. if test_num <= 0 || test_num > problem.num_tests - log "RUN: You have specified a wrong test number." + log "RUN: ERROR: You have specified a wrong test number." exit(127) end