Description:
[grader] added check_wrapper git-svn-id: http://theory.cpe.ku.ac.th/grader/judge/trunk/scripts@111 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r28:b806077acf3a - - 2 files changed: 61 inserted, 0 deleted

@@ -0,0 +1,45
1 + #!/usr/bin/ruby
2 +
3 + #
4 + # This is a check script wrapper. It read all required information
5 + # and call a real check script call REAL_CHECK_SCRIPT in directory
6 + # [problem_home]/script
7 + #
8 +
9 + REAL_CHECK_SCRIPT = "<%= script_name %>"
10 +
11 + # The REAL_CHECK_SCRIPT is called with:
12 + #
13 + # (script) <lang> <test-num> <in-file> <out-file> <ans-file> <full-score>
14 + #
15 + # and REAL_CHECK_SCRIPT's output to standard out is redirected to
16 + # 'check_result' as required by normal check script.
17 +
18 + problem_home = ENV['PROBLEM_HOME']
19 + require "#{problem_home}/script/test_dsl.rb"
20 +
21 + if ARGV.length < 2
22 + puts "Usage: check <language> <test-number> [<output-file>]"
23 + exit(0)
24 + end
25 +
26 + language = ARGV[0]
27 + test_num = ARGV[1].to_i
28 + if ARGV.length >= 3
29 + output_file_name = ARGV[2]
30 + else
31 + output_file_name = "output.txt"
32 + end
33 +
34 + load "#{problem_home}/test_cases/all_tests.cfg"
35 + problem = Problem.get_instance
36 +
37 + answer_file_name = File.new("#{problem_home}/test_cases/#{test_num}/answer-#{test_num}.txt")
38 + input_file_name = File.new("#{problem_home}/test_cases/#{test_num}/input-#{test_num}.txt")
39 +
40 + score = Problem.get_score(test_num)
41 +
42 + cmd = "#{problem_home}/script/#{REAL_CHECK_SCRIPT} " +
43 + "#{language} #{test_num} #{input_file_name} #{output_file_name} " +
44 + "#{answer_file_name} #{score} > check_result"
45 +
@@ -94,12 +94,28
94 94
95 95
96 96 # copy check script
97 + if res = /^wrapper:(.*)$/.match(check_script)
98 + # wrapper script
99 + check_script_fname = res[1]
100 + script_name = File.basename(check_script_fname)
101 + check_wrapper_template = File.open(SCRIPT_DIR + "/templates/check_wrapper")
102 + check_wrapper = ERB.new(template)
103 +
104 + check_file = File.open("#{problem}/script/check","w")
105 + check_file.puts check_wrapper
106 + check_file.close
107 +
108 + File.chmod(0755,"#{problem}/script/check")
109 +
110 + system("cp #{check_script_fname} #{problem}/script/#{script_name}")
111 + else
97 112 if File.exists?(SCRIPT_DIR + "/templates/check.#{check_script}")
98 113 check_script_fname = SCRIPT_DIR + "/templates/check.#{check_script}"
99 114 else
100 115 check_script_fname = check_script
101 116 end
102 117 system("cp #{check_script_fname} #{problem}/script/check")
118 + end
103 119
104 120 # generating test_request directory
105 121 puts "generating test_request template"
You need to be logged in to leave comments. Login now