Description:
fix all_tests.cfg bug
git-svn-id: http://theory.cpe.ku.ac.th/grader/cli/trunk/scripts@16 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
r4:5f97b81f01be - - 2 files changed: 3 inserted, 3 deleted
@@ -1,13 +1,13 | |||||
|
1 | problem do |
|
1 | problem do |
|
2 | num_tests <%= num_testcases %> |
|
2 | num_tests <%= num_testcases %> |
|
3 | full_score <%= num_testcases*10 %> |
|
3 | full_score <%= num_testcases*10 %> |
|
4 | time_limit_each <%= options[:time_limit] %> |
|
4 | time_limit_each <%= options[:time_limit] %> |
|
5 | mem_limit_each <%= options[:mem_limit] %> |
|
5 | mem_limit_each <%= options[:mem_limit] %> |
|
6 | score_each 10 |
|
6 | score_each 10 |
|
7 |
|
7 | ||
|
8 | - <% 1.upto(num_testcase) do |i| %> |
|
8 | + <% 1.upto(num_testcases) do |i| %> |
|
9 | - run <%= i %> |
|
9 | + run <%= i %> do |
|
10 | tests <%= i %> |
|
10 | tests <%= i %> |
|
11 | end |
|
11 | end |
|
12 | <% end %> |
|
12 | <% end %> |
|
13 | end |
|
13 | end |
@@ -1,80 +1,80 | |||||
|
1 | #!/usr/bin/ruby |
|
1 | #!/usr/bin/ruby |
|
2 |
|
2 | ||
|
3 | # import_problem: |
|
3 | # import_problem: |
|
4 | # * creates a directory for a problem in the current directory, |
|
4 | # * creates a directory for a problem in the current directory, |
|
5 | # * copy standard scripts |
|
5 | # * copy standard scripts |
|
6 | # * copy testdata in the old format and create standard testcase config file |
|
6 | # * copy testdata in the old format and create standard testcase config file |
|
7 |
|
7 | ||
|
8 | require 'erb' |
|
8 | require 'erb' |
|
9 |
|
9 | ||
|
10 | def input_filename(dir,i) |
|
10 | def input_filename(dir,i) |
|
11 | "#{dir}/input-#{i}.txt" |
|
11 | "#{dir}/input-#{i}.txt" |
|
12 | end |
|
12 | end |
|
13 |
|
13 | ||
|
14 | def answer_filename(dir,i) |
|
14 | def answer_filename(dir,i) |
|
15 | "#{dir}/answer-#{i}.txt" |
|
15 | "#{dir}/answer-#{i}.txt" |
|
16 | end |
|
16 | end |
|
17 |
|
17 | ||
|
18 | def copy_testcase(importing_test_dir,dir,i) |
|
18 | def copy_testcase(importing_test_dir,dir,i) |
|
19 | system("cp #{importing_test_dir}/#{i}.in #{input_filename(dir,i)}") |
|
19 | system("cp #{importing_test_dir}/#{i}.in #{input_filename(dir,i)}") |
|
20 | system("cp #{importing_test_dir}/#{i}.sol #{answer_filename(dir,i)}") |
|
20 | system("cp #{importing_test_dir}/#{i}.sol #{answer_filename(dir,i)}") |
|
21 | end |
|
21 | end |
|
22 |
|
22 | ||
|
23 | def process_options(options) |
|
23 | def process_options(options) |
|
24 | i = 3 |
|
24 | i = 3 |
|
25 | while i<ARGV.length |
|
25 | while i<ARGV.length |
|
26 | if ARGV[i]=='-t' |
|
26 | if ARGV[i]=='-t' |
|
27 | options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1 |
|
27 | options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1 |
|
28 | i += 1 |
|
28 | i += 1 |
|
29 | end |
|
29 | end |
|
30 | if ARGV[i]=='-m' |
|
30 | if ARGV[i]=='-m' |
|
31 | options[:mem_limit] = ARGV[i+1].to_i if ARGV.length>i+1 |
|
31 | options[:mem_limit] = ARGV[i+1].to_i if ARGV.length>i+1 |
|
32 | i += 1 |
|
32 | i += 1 |
|
33 | end |
|
33 | end |
|
34 | i += 1 |
|
34 | i += 1 |
|
35 | end |
|
35 | end |
|
36 | end |
|
36 | end |
|
37 |
|
37 | ||
|
38 | GRADER_DIR = File.dirname(__FILE__) |
|
38 | GRADER_DIR = File.dirname(__FILE__) |
|
39 |
|
39 | ||
|
40 | # print usage |
|
40 | # print usage |
|
41 | if ARGV.length < 3 |
|
41 | if ARGV.length < 3 |
|
42 | puts "using: import_task problem importing_testcase_dir number_of_testcase [options]" |
|
42 | puts "using: import_task problem importing_testcase_dir number_of_testcase [options]" |
|
43 | exit(127) |
|
43 | exit(127) |
|
44 | end |
|
44 | end |
|
45 |
|
45 | ||
|
46 | # processing arguments |
|
46 | # processing arguments |
|
47 | problem = ARGV[0] |
|
47 | problem = ARGV[0] |
|
48 | testcase_dir = ARGV[1] |
|
48 | testcase_dir = ARGV[1] |
|
49 | num_testcases = ARGV[2].to_i |
|
49 | num_testcases = ARGV[2].to_i |
|
50 |
|
50 | ||
|
51 | options = {:time_limit => 1, :mem_limit => 16} |
|
51 | options = {:time_limit => 1, :mem_limit => 16} |
|
52 | process_options(options) |
|
52 | process_options(options) |
|
53 |
|
53 | ||
|
54 | # start working |
|
54 | # start working |
|
55 | puts "creating directories" |
|
55 | puts "creating directories" |
|
56 |
|
56 | ||
|
57 | system("mkdir #{problem}") |
|
57 | system("mkdir #{problem}") |
|
58 | system("mkdir #{problem}/script") |
|
58 | system("mkdir #{problem}/script") |
|
59 | system("mkdir #{problem}/test_cases") |
|
59 | system("mkdir #{problem}/test_cases") |
|
60 | system("cp #{GRADER_DIR}/std-script/* #{problem}/script") |
|
60 | system("cp #{GRADER_DIR}/std-script/* #{problem}/script") |
|
61 |
|
61 | ||
|
62 | puts "copying testcases" |
|
62 | puts "copying testcases" |
|
63 |
|
63 | ||
|
64 | 1.upto(num_testcases) do |i| |
|
64 | 1.upto(num_testcases) do |i| |
|
65 | system("mkdir #{problem}/test_cases/#{i}") |
|
65 | system("mkdir #{problem}/test_cases/#{i}") |
|
66 | copy_testcase("#{testcase_dir}","#{problem}/test_cases/#{i}",i) |
|
66 | copy_testcase("#{testcase_dir}","#{problem}/test_cases/#{i}",i) |
|
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 = File.open("all_tests.cfg.erb").read |
|
73 | + template = File.open(File.dirname(__FILE__) + "/all_tests.cfg.erb").read |
|
74 | all_test_cfg = ERB.new(template) |
|
74 | all_test_cfg = ERB.new(template) |
|
75 |
|
75 | ||
|
76 | cfg_file = File.open("#{problem}/test_cases/all_tests.cfg","w") |
|
76 | cfg_file = File.open("#{problem}/test_cases/all_tests.cfg","w") |
|
77 | cfg_file.puts all_test_cfg.result |
|
77 | cfg_file.puts all_test_cfg.result |
|
78 | cfg_file.close |
|
78 | cfg_file.close |
|
79 |
|
79 | ||
|
80 | puts "done" |
|
80 | puts "done" |
You need to be logged in to leave comments.
Login now