diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2020-11-20 15:37:15 +0100 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-11-23 09:26:41 -0800 |
commit | 58640bdff900e463956cc2bb8366bc57a622c977 (patch) | |
tree | f81276d057334d11b958b5ec797e6e29eac932bf /run_project_tests.py | |
parent | edbcb2bfc8e6628d61cdb52d97d359e1cd78a17c (diff) | |
download | meson-58640bdff900e463956cc2bb8366bc57a622c977.zip meson-58640bdff900e463956cc2bb8366bc57a622c977.tar.gz meson-58640bdff900e463956cc2bb8366bc57a622c977.tar.bz2 |
Remove AutoDeletedDir
Replace the only usage with a simple try/finally and remove the class.
Diffstat (limited to 'run_project_tests.py')
-rwxr-xr-x | run_project_tests.py | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/run_project_tests.py b/run_project_tests.py index a88e5cc..1dff386 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -224,21 +224,6 @@ class TestDef: return (s_id, self.path, self.name or '') < (o_id, other.path, other.name or '') return NotImplemented -class AutoDeletedDir: - def __init__(self, d): - self.dir = d - - def __enter__(self): - os.makedirs(self.dir, exist_ok=True) - return self.dir - - def __exit__(self, _type, value, traceback): - # We don't use tempfile.TemporaryDirectory, but wrap the - # deletion in the AutoDeletedDir class because - # it fails on Windows due antivirus programs - # holding files open. - mesonlib.windows_proof_rmtree(self.dir) - failing_logs = [] print_debug = 'MESON_PRINT_TEST_OUTPUT' in os.environ under_ci = 'CI' in os.environ @@ -519,7 +504,8 @@ def detect_parameter_files(test: TestDef, test_build_dir: str) -> (Path, Path): def run_test(test: TestDef, extra_args, compiler, backend, flags, commands, should_fail, use_tmp: bool): if test.skip: return None - with AutoDeletedDir(create_deterministic_builddir(test, use_tmp)) as build_dir: + build_dir = create_deterministic_builddir(test, use_tmp) + try: with TemporaryDirectoryWinProof(prefix='i ', dir=None if use_tmp else os.getcwd()) as install_dir: try: return _run_test(test, build_dir, install_dir, extra_args, compiler, backend, flags, commands, should_fail) @@ -527,6 +513,8 @@ def run_test(test: TestDef, extra_args, compiler, backend, flags, commands, shou return r finally: mlog.shutdown() # Close the log file because otherwise Windows wets itself. + finally: + mesonlib.windows_proof_rmtree(build_dir) def _run_test(test: TestDef, test_build_dir: str, install_dir: str, extra_args, compiler, backend, flags, commands, should_fail): compile_commands, clean_commands, install_commands, uninstall_commands = commands |