Description:
merge
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r243:b409073698a0 - - 1 file changed: 5 inserted, 2 deleted
@@ -79,70 +79,73 | |||||
|
79 |
|
79 | ||
|
80 | puts" |
|
80 | puts" |
|
81 | For each environment, the script |
|
81 | For each environment, the script |
|
82 | * creates a directory for a problem in ev dir of that environment, |
|
82 | * creates a directory for a problem in ev dir of that environment, |
|
83 | * copies testdata in the old format and create standard testcase config file |
|
83 | * copies testdata in the old format and create standard testcase config file |
|
84 | * copies a check script for grading |
|
84 | * copies a check script for grading |
|
85 | * creates a test_request template in the ev dir + '/test_request' |
|
85 | * creates a test_request template in the ev dir + '/test_request' |
|
86 |
|
86 | ||
|
87 | For wrapped checked script see comment in templates/check_wrapper for |
|
87 | For wrapped checked script see comment in templates/check_wrapper for |
|
88 | information." |
|
88 | information." |
|
89 | end |
|
89 | end |
|
90 |
|
90 | ||
|
91 | def count_testruns(testcase_dir, raw_prefix) |
|
91 | def count_testruns(testcase_dir, raw_prefix) |
|
92 | n = 0 |
|
92 | n = 0 |
|
93 | begin |
|
93 | begin |
|
94 | # check for test case n+1 |
|
94 | # check for test case n+1 |
|
95 | if ((Dir["#{testcase_dir}/#{raw_prefix}#{n+1}.in"].length==0) and |
|
95 | if ((Dir["#{testcase_dir}/#{raw_prefix}#{n+1}.in"].length==0) and |
|
96 | (Dir["#{testcase_dir}/#{raw_prefix}#{n+1}[a-z].in"].length==0)) |
|
96 | (Dir["#{testcase_dir}/#{raw_prefix}#{n+1}[a-z].in"].length==0)) |
|
97 | return n |
|
97 | return n |
|
98 | end |
|
98 | end |
|
99 | n += 1 |
|
99 | n += 1 |
|
100 | end while true |
|
100 | end while true |
|
101 | end |
|
101 | end |
|
102 |
|
102 | ||
|
103 | - def create_dir_if_not_exists(dir) |
|
103 | + def create_dir_if_not_exists(dir, options = {} ) |
|
104 | if ! FileTest.exists? dir |
|
104 | if ! FileTest.exists? dir |
|
105 | FileUtils.mkdir(dir) |
|
105 | FileUtils.mkdir(dir) |
|
106 | end |
|
106 | end |
|
|
107 | + | ||
|
|
108 | + FileUtils.rm_rf(Dir.glob("#{dir}/*")) if options[:clear] | ||
|
107 | end |
|
109 | end |
|
108 |
|
110 | ||
|
109 | def import_problem(ev_dir, problem, testcase_dir, num_testruns, raw_prefix, check_script, options) |
|
111 | def import_problem(ev_dir, problem, testcase_dir, num_testruns, raw_prefix, check_script, options) |
|
110 | testrun_info = build_testrun_info_from_dir(num_testruns, testcase_dir, raw_prefix) |
|
112 | testrun_info = build_testrun_info_from_dir(num_testruns, testcase_dir, raw_prefix) |
|
111 |
|
113 | ||
|
112 | if !(FileTest.exists? ev_dir) |
|
114 | if !(FileTest.exists? ev_dir) |
|
113 | puts "Testdata dir (#{ev_dir}) not found." |
|
115 | puts "Testdata dir (#{ev_dir}) not found." |
|
114 | return |
|
116 | return |
|
115 | end |
|
117 | end |
|
116 |
|
118 | ||
|
117 | problem_dir = "#{ev_dir}/#{problem}" |
|
119 | problem_dir = "#{ev_dir}/#{problem}" |
|
118 |
|
120 | ||
|
119 | # start working |
|
121 | # start working |
|
120 | puts "creating directories" |
|
122 | puts "creating directories" |
|
121 |
|
123 | ||
|
122 | create_dir_if_not_exists("#{problem_dir}") |
|
124 | create_dir_if_not_exists("#{problem_dir}") |
|
123 | create_dir_if_not_exists("#{problem_dir}/script") |
|
125 | create_dir_if_not_exists("#{problem_dir}/script") |
|
124 | - create_dir_if_not_exists("#{problem_dir}/test_cases") |
|
126 | + create_dir_if_not_exists("#{problem_dir}/test_cases",clear: true) |
|
|
127 | + # clear test cases directory | ||
|
125 |
|
128 | ||
|
126 | puts "copying testcases" |
|
129 | puts "copying testcases" |
|
127 |
|
130 | ||
|
128 | tr_num = 0 |
|
131 | tr_num = 0 |
|
129 |
|
132 | ||
|
130 | num_testcases = 0 |
|
133 | num_testcases = 0 |
|
131 |
|
134 | ||
|
132 | testrun_info.each do |testrun| |
|
135 | testrun_info.each do |testrun| |
|
133 | tr_num += 1 |
|
136 | tr_num += 1 |
|
134 | puts "testrun: #{tr_num}" |
|
137 | puts "testrun: #{tr_num}" |
|
135 |
|
138 | ||
|
136 | testrun.each do |testcase_info| |
|
139 | testrun.each do |testcase_info| |
|
137 | testcase_num, testcase_fname = testcase_info |
|
140 | testcase_num, testcase_fname = testcase_info |
|
138 |
|
141 | ||
|
139 | puts "copy #{testcase_fname} to #{testcase_num}" |
|
142 | puts "copy #{testcase_fname} to #{testcase_num}" |
|
140 |
|
143 | ||
|
141 | create_dir_if_not_exists("#{problem_dir}/test_cases/#{testcase_num}") |
|
144 | create_dir_if_not_exists("#{problem_dir}/test_cases/#{testcase_num}") |
|
142 | copy_testcase("#{testcase_dir}",testcase_fname,"#{problem_dir}/test_cases/#{testcase_num}",testcase_num) |
|
145 | copy_testcase("#{testcase_dir}",testcase_fname,"#{problem_dir}/test_cases/#{testcase_num}",testcase_num) |
|
143 |
|
146 | ||
|
144 | num_testcases += 1 |
|
147 | num_testcases += 1 |
|
145 | end |
|
148 | end |
|
146 | end |
|
149 | end |
|
147 |
|
150 | ||
|
148 | #also include any .txt files |
|
151 | #also include any .txt files |
You need to be logged in to leave comments.
Login now