Skip to content

Commit 4789924

Browse files
authored
Merge pull request #146 from EZoni/EZoni_rm_testdir
Add option to clean up each test dir
2 parents 21c052c + 715ea85 commit 4789924

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

regtest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,20 @@ def test_suite(argv):
12221222
suite.log.log("creating problem test report ...")
12231223
report.report_single_test(suite, test, test_list)
12241224

1225+
#----------------------------------------------------------------------
1226+
# if test ran and passed, remove test directory if requested
1227+
#----------------------------------------------------------------------
1228+
test_successful = (test.return_code == 0 and test.analysis_successful and test.compare_successful)
1229+
if (test.ignore_return_code == 1 or test_successful):
1230+
if args.clean_testdir:
1231+
suite.log.log("removing subdirectories from test directory...")
1232+
for file_name in os.listdir(output_dir):
1233+
file_path = os.path.join(output_dir, file_name)
1234+
if os.path.isdir(file_path):
1235+
shutil.rmtree(file_path)
1236+
# switch to the full test directory
1237+
os.chdir(suite.full_test_dir)
1238+
12251239
#--------------------------------------------------------------------------
12261240
# Clean Cmake build and install directories if needed
12271241
#--------------------------------------------------------------------------

test_util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ def get_args(arg_string=None):
390390
help="complete report generation from a crashed test suite run named testdir")
391391
suite_options.add_argument("--log_file", type=str, default=None, metavar="logfile",
392392
help="log file to write output to (in addition to stdout")
393+
suite_options.add_argument("--clean_testdir", action="store_true",
394+
help="remove individual test directory after each passed test")
393395

394396
comp_options = parser.add_argument_group("comparison options",
395397
"options that control how the comparisons are done")

0 commit comments

Comments
 (0)