diff --git a/regtest.py b/regtest.py index 9cf313e..edb824b 100755 --- a/regtest.py +++ b/regtest.py @@ -1222,6 +1222,20 @@ def test_suite(argv): suite.log.log("creating problem test report ...") report.report_single_test(suite, test, test_list) + #---------------------------------------------------------------------- + # if test ran and passed, remove test directory if requested + #---------------------------------------------------------------------- + test_successful = (test.return_code == 0 and test.analysis_successful and test.compare_successful) + if (test.ignore_return_code == 1 or test_successful): + if args.clean_testdir: + suite.log.log("removing subdirectories from test directory...") + for file_name in os.listdir(output_dir): + file_path = os.path.join(output_dir, file_name) + if os.path.isdir(file_path): + shutil.rmtree(file_path) + # switch to the full test directory + os.chdir(suite.full_test_dir) + #-------------------------------------------------------------------------- # Clean Cmake build and install directories if needed #-------------------------------------------------------------------------- diff --git a/test_util.py b/test_util.py index c57904f..d0ba0ab 100644 --- a/test_util.py +++ b/test_util.py @@ -390,6 +390,8 @@ def get_args(arg_string=None): help="complete report generation from a crashed test suite run named testdir") suite_options.add_argument("--log_file", type=str, default=None, metavar="logfile", help="log file to write output to (in addition to stdout") + suite_options.add_argument("--clean_testdir", action="store_true", + help="remove individual test directory after each passed test") comp_options = parser.add_argument_group("comparison options", "options that control how the comparisons are done")