Description:
let import problem clear the testcase folder
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r242:f8ad085b45a7 - - 1 file changed: 5 inserted, 2 deleted
@@ -97,16 +97,18 | |||||
|
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) |
@@ -118,13 +120,14 | |||||
|
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 |
You need to be logged in to leave comments.
Login now