From 2b047a69023c0ddcad59abc0d8859a731d24d572 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni Date: Wed, 7 Aug 2024 15:52:17 -0700 Subject: [PATCH 1/3] Add `rm_testdir` option --- regtest.py | 17 +++++++++++++++++ test_util.py | 2 ++ 2 files changed, 19 insertions(+) diff --git a/regtest.py b/regtest.py index 9cf313e..a5acf26 100755 --- a/regtest.py +++ b/regtest.py @@ -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 #-------------------------------------------------------------------------- diff --git a/test_util.py b/test_util.py index c57904f..69256d9 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("--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") From 5bd6a57c8d485a618190c7a4baffba8b2fd1c270 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni Date: Thu, 8 Aug 2024 11:34:23 -0700 Subject: [PATCH 2/3] Check test run, analysis, and comparison --- regtest.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/regtest.py b/regtest.py index a5acf26..b1a629b 100755 --- a/regtest.py +++ b/regtest.py @@ -1225,15 +1225,12 @@ def test_suite(argv): #---------------------------------------------------------------------- # if test ran and passed, remove test directory if requested #---------------------------------------------------------------------- - if (test.ignore_return_code == 1 or test.return_code == 0): + 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.rm_testdir: - suite.log.log("removing subdirectories in test directory...") + 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.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 From 715ea85009f9a685b7255d9a831d3280aaef9df0 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni Date: Mon, 12 Aug 2024 13:50:05 -0700 Subject: [PATCH 3/3] Rename option `rm_testdir` to `clean_testdir` --- regtest.py | 2 +- test_util.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/regtest.py b/regtest.py index b1a629b..edb824b 100755 --- a/regtest.py +++ b/regtest.py @@ -1227,7 +1227,7 @@ def test_suite(argv): #---------------------------------------------------------------------- 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.rm_testdir: + 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) diff --git a/test_util.py b/test_util.py index 69256d9..d0ba0ab 100644 --- a/test_util.py +++ b/test_util.py @@ -390,7 +390,7 @@ 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", + 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",