Description:
fix reimport bug when creating existing dirs
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r100:384e1befe70e - - 1 file changed: 18 inserted, 13 deleted
@@ -1,7 +1,6 | |||||
|
1 | #!/usr/bin/ruby |
|
1 | #!/usr/bin/ruby |
|
2 |
|
2 | ||
|
3 | require 'erb' |
|
3 | require 'erb' |
|
4 | - require 'ftools' |
|
||
|
5 | require 'fileutils' |
|
4 | require 'fileutils' |
|
6 | require File.join(File.dirname(__FILE__),'lib/import_helper') |
|
5 | require File.join(File.dirname(__FILE__),'lib/import_helper') |
|
7 |
|
6 | ||
@@ -33,8 +32,8 | |||||
|
33 | end |
|
32 | end |
|
34 |
|
33 | ||
|
35 | def copy_testcase(importing_test_dir,fname,dir,i) |
|
34 | def copy_testcase(importing_test_dir,fname,dir,i) |
|
36 |
- File.c |
|
35 | + FileUtils.cp("#{importing_test_dir}/#{fname}.in", "#{input_filename(dir,i)}") |
|
37 |
- File.c |
|
36 | + FileUtils.cp("#{importing_test_dir}/#{fname}.sol", "#{answer_filename(dir,i)}") |
|
38 | end |
|
37 | end |
|
39 |
|
38 | ||
|
40 | def process_options(options) |
|
39 | def process_options(options) |
@@ -101,6 +100,12 | |||||
|
101 | end while true |
|
100 | end while true |
|
102 | end |
|
101 | end |
|
103 |
|
102 | ||
|
|
103 | + def create_dir_if_not_exists(dir) | ||
|
|
104 | + if ! FileTest.exists? dir | ||
|
|
105 | + FileUtils.mkdir(dir) | ||
|
|
106 | + end | ||
|
|
107 | + end | ||
|
|
108 | + | ||
|
104 | def import_problem(ev_dir, problem, testcase_dir, num_testruns, raw_prefix, check_script, options) |
|
109 | def import_problem(ev_dir, problem, testcase_dir, num_testruns, raw_prefix, check_script, options) |
|
105 | testrun_info = build_testrun_info_from_dir(num_testruns, testcase_dir, raw_prefix) |
|
110 | testrun_info = build_testrun_info_from_dir(num_testruns, testcase_dir, raw_prefix) |
|
106 |
|
111 | ||
@@ -114,9 +119,9 | |||||
|
114 | # start working |
|
119 | # start working |
|
115 | puts "creating directories" |
|
120 | puts "creating directories" |
|
116 |
|
121 | ||
|
117 |
- |
|
122 | + create_dir_if_not_exists("#{problem_dir}") |
|
118 |
- |
|
123 | + create_dir_if_not_exists("#{problem_dir}/script") |
|
119 |
- |
|
124 | + create_dir_if_not_exists("#{problem_dir}/test_cases") |
|
120 |
|
125 | ||
|
121 | puts "copying testcases" |
|
126 | puts "copying testcases" |
|
122 |
|
127 | ||
@@ -133,7 +138,7 | |||||
|
133 |
|
138 | ||
|
134 | puts "copy #{testcase_fname} to #{testcase_num}" |
|
139 | puts "copy #{testcase_fname} to #{testcase_num}" |
|
135 |
|
140 | ||
|
136 |
- |
|
141 | + create_dir_if_not_exists("#{problem_dir}/test_cases/#{testcase_num}") |
|
137 | copy_testcase("#{testcase_dir}",testcase_fname,"#{problem_dir}/test_cases/#{testcase_num}",testcase_num) |
|
142 | copy_testcase("#{testcase_dir}",testcase_fname,"#{problem_dir}/test_cases/#{testcase_num}",testcase_num) |
|
138 |
|
143 | ||
|
139 | num_testcases += 1 |
|
144 | num_testcases += 1 |
@@ -164,14 +169,14 | |||||
|
164 |
|
169 | ||
|
165 | File.chmod(0755,"#{problem_dir}/script/check") |
|
170 | File.chmod(0755,"#{problem_dir}/script/check") |
|
166 |
|
171 | ||
|
167 |
- File.c |
|
172 | + FileUtils.cp("#{check_script_fname}", "#{problem_dir}/script/#{script_name}") |
|
168 | else |
|
173 | else |
|
169 | if File.exists?(SCRIPT_DIR + "/templates/check.#{check_script}") |
|
174 | if File.exists?(SCRIPT_DIR + "/templates/check.#{check_script}") |
|
170 | check_script_fname = SCRIPT_DIR + "/templates/check.#{check_script}" |
|
175 | check_script_fname = SCRIPT_DIR + "/templates/check.#{check_script}" |
|
171 | else |
|
176 | else |
|
172 | check_script_fname = check_script |
|
177 | check_script_fname = check_script |
|
173 | end |
|
178 | end |
|
174 |
- File.c |
|
179 | + FileUtils.cp("#{check_script_fname}", "#{problem_dir}/script/check") |
|
175 | end |
|
180 | end |
|
176 |
|
181 | ||
|
177 | # generating test_request directory |
|
182 | # generating test_request directory |
@@ -186,10 +191,10 | |||||
|
186 | cfg_file.puts test_request_all_test_cfg.result |
|
191 | cfg_file.puts test_request_all_test_cfg.result |
|
187 | cfg_file.close |
|
192 | cfg_file.close |
|
188 |
|
193 | ||
|
189 |
- File.c |
|
194 | + FileUtils.cp("#{SCRIPT_DIR}/templates/check_empty", |
|
190 | - "#{ev_dir}/test_request/#{problem}/script/check") |
|
195 | + "#{ev_dir}/test_request/#{problem}/script/check") |
|
191 |
- File.c |
|
196 | + FileUtils.cp("#{SCRIPT_DIR}/templates/answer-1.txt", |
|
192 | - "#{ev_dir}/test_request/#{problem}/test_cases/1") |
|
197 | + "#{ev_dir}/test_request/#{problem}/test_cases/1") |
|
193 |
|
198 | ||
|
194 | puts "done" |
|
199 | puts "done" |
|
195 | end |
|
200 | end |
You need to be logged in to leave comments.
Login now