summaryrefslogtreecommitdiff
path: root/unittests/baseplatformtests.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2024-07-16 11:28:36 -0700
committerEli Schwartz <eschwartz93@gmail.com>2024-08-15 14:15:03 -0400
commite808aa161cec917aa7a6aed94fe89050950b35e1 (patch)
tree37641398b48828606b7faaafb965777fc331a10f /unittests/baseplatformtests.py
parent5eb4d7336b6ab6e6bf1900bc4140783957052bc9 (diff)
downloadmeson-e808aa161cec917aa7a6aed94fe89050950b35e1.tar.gz
unittests: use TestCase.addCleanup for cleaning up builddirs
Diffstat (limited to 'unittests/baseplatformtests.py')
-rw-r--r--unittests/baseplatformtests.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/unittests/baseplatformtests.py b/unittests/baseplatformtests.py
index ae012dada..0886e5190 100644
--- a/unittests/baseplatformtests.py
+++ b/unittests/baseplatformtests.py
@@ -91,7 +91,6 @@ class BasePlatformTests(TestCase):
os.environ['COLUMNS'] = '80'
os.environ['PYTHONIOENCODING'] = 'utf8'
- self.builddirs = []
self.new_builddir()
def change_builddir(self, newdir):
@@ -101,7 +100,10 @@ class BasePlatformTests(TestCase):
self.installdir = os.path.join(self.builddir, 'install')
self.distdir = os.path.join(self.builddir, 'meson-dist')
self.mtest_command = self.meson_command + ['test', '-C', self.builddir]
- self.builddirs.append(self.builddir)
+ if os.path.islink(newdir):
+ self.addCleanup(os.unlink, self.builddir)
+ else:
+ self.addCleanup(windows_proof_rmtree, self.builddir)
def new_builddir(self):
# Keep builddirs inside the source tree so that virus scanners
@@ -141,14 +143,6 @@ class BasePlatformTests(TestCase):
if log:
print(log)
- def tearDown(self):
- for path in self.builddirs:
- try:
- windows_proof_rmtree(path)
- except FileNotFoundError:
- pass
- super().tearDown()
-
def _run(self, command, *, workdir=None, override_envvars: T.Optional[T.Mapping[str, str]] = None, stderr=True):
'''
Run a command while printing the stdout and stderr to stdout,