Description:
fix bugs: paths, check compilation error, all_tests.cfg.erb
git-svn-id: http://theory.cpe.ku.ac.th/grader/cli/trunk/scripts@15 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r3:4a517b89268a - - 4 files changed: 24 inserted, 18 deleted
@@ -0,0 +1,13 | |||||
|
|
1 | + problem do | ||
|
|
2 | + num_tests <%= num_testcases %> | ||
|
|
3 | + full_score <%= num_testcases*10 %> | ||
|
|
4 | + time_limit_each <%= options[:time_limit] %> | ||
|
|
5 | + mem_limit_each <%= options[:mem_limit] %> | ||
|
|
6 | + score_each 10 | ||
|
|
7 | + | ||
|
|
8 | + <% 1.upto(num_testcase) do |i| %> | ||
|
|
9 | + run <%= i %> | ||
|
|
10 | + tests <%= i %> | ||
|
|
11 | + end | ||
|
|
12 | + <% end %> | ||
|
|
13 | + end |
@@ -95,15 +95,17 | |||||
|
95 | RAILS_ENV = 'development' |
|
95 | RAILS_ENV = 'development' |
|
96 | require RAILS_APP_DIR + '/config/environment' |
|
96 | require RAILS_APP_DIR + '/config/environment' |
|
97 |
|
97 | ||
|
98 | current_dir = `pwd` |
|
98 | current_dir = `pwd` |
|
99 |
|
99 | ||
|
100 | talk 'Grader queue' |
|
100 | talk 'Grader queue' |
|
101 | - task = Task.find(:first, :order => 'created_at') |
|
101 | + while true |
|
102 | - if task!=nil |
|
102 | + task = Task.find(:first, :order => 'created_at') |
|
103 | - grade(task.submission_id) |
|
103 | + if task!=nil |
|
104 | - task.destroy |
|
104 | + grade(task.submission_id) |
|
105 | - else |
|
105 | + task.destroy |
|
106 | - puts "No job" |
|
106 | + else |
|
|
107 | + sleep(1) | ||
|
|
108 | + end | ||
|
107 | end |
|
109 | end |
|
108 |
|
110 | ||
|
109 |
|
111 |
@@ -67,23 +67,14 | |||||
|
67 | end |
|
67 | end |
|
68 |
|
68 | ||
|
69 |
|
69 | ||
|
70 | # generating all_tests.cfg |
|
70 | # generating all_tests.cfg |
|
71 | puts "generating testcase config file" |
|
71 | puts "generating testcase config file" |
|
72 |
|
72 | ||
|
73 | - template = %q{ |
|
73 | + template = File.open("all_tests.cfg.erb").readlines |
|
74 | - problem do |
|
||
|
75 | - num_tests <%= num_testcases %> |
|
||
|
76 | - full_score <%= num_testcases*10 %> |
|
||
|
77 | - time_limit_each <%= options[:time_limit] %> |
|
||
|
78 | - mem_limit_each <%= options[:mem_limit] %> |
|
||
|
79 | - score_each 10 |
|
||
|
80 | - end |
|
||
|
81 | - } |
|
||
|
82 | - |
|
||
|
83 | all_test_cfg = ERB.new(template) |
|
74 | all_test_cfg = ERB.new(template) |
|
84 |
|
75 | ||
|
85 | - cfg_file = File.open("#{problem}/test_cases/all_test.cfg","w") |
|
76 | + cfg_file = File.open("#{problem}/test_cases/all_tests.cfg","w") |
|
86 | cfg_file.puts all_test_cfg.result |
|
77 | cfg_file.puts all_test_cfg.result |
|
87 | cfg_file.close |
|
78 | cfg_file.close |
|
88 |
|
79 | ||
|
89 | puts "done" |
|
80 | puts "done" |
@@ -68,13 +68,13 | |||||
|
68 | exit(127) |
|
68 | exit(127) |
|
69 | end |
|
69 | end |
|
70 | execute("#{problem_home}/script/compile #{language} #{source_file}", "Compilation error!") |
|
70 | execute("#{problem_home}/script/compile #{language} #{source_file}", "Compilation error!") |
|
71 | compile_message = `cat compiler_message` |
|
71 | compile_message = `cat compiler_message` |
|
72 | compile_message.strip! |
|
72 | compile_message.strip! |
|
73 | execute("mv compiler_message #{test_result_dir}", "Cannot move the compiler message to #{test_result_dir}.") |
|
73 | execute("mv compiler_message #{test_result_dir}", "Cannot move the compiler message to #{test_result_dir}.") |
|
74 | - if compile_message != "" |
|
74 | + if !FileTest.exist?("a.out") |
|
75 | puts "Cannot compile the source code. See message in #{test_result_dir}/compile_message" |
|
75 | puts "Cannot compile the source code. See message in #{test_result_dir}/compile_message" |
|
76 | exit(127) |
|
76 | exit(127) |
|
77 | else |
|
77 | else |
|
78 | execute("mv a.out #{test_result_dir}", "Cannot move the compiled program to #{test_result_dir}") |
|
78 | execute("mv a.out #{test_result_dir}", "Cannot move the compiled program to #{test_result_dir}") |
|
79 | system("rm -Rf #{sandbox_dir}/*") |
|
79 | system("rm -Rf #{sandbox_dir}/*") |
|
80 | end |
|
80 | end |
You need to be logged in to leave comments.
Login now