Skip to content

Commit

Permalink
Add rm_testdir option
Browse files Browse the repository at this point in the history
  • Loading branch information
EZoni committed Aug 8, 2024
1 parent 21c052c commit 2b047a6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions regtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,23 @@ 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
#----------------------------------------------------------------------
if (test.ignore_return_code == 1 or test.return_code == 0):
if args.rm_testdir:
suite.log.log("removing subdirectories in test directory...")
for file_name in os.listdir(output_dir):
file_path = os.path.join(output_dir, file_name)
#if os.path.isfile(file_path) or os.path.islink(file_path):
# os.unlink(file_path)
#elif os.path.isdir(file_path):
# shutil.rmtree(file_path)
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
#--------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("--rm_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")
Expand Down

0 comments on commit 2b047a6

Please sign in to comment.