aboutsummaryrefslogtreecommitdiff
path: root/unittests/allplatformstests.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-11-08 13:11:43 -0800
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2021-11-24 02:23:57 +0530
commit457e2d9812e4514ddea59d67a72a02820e82d65f (patch)
tree04f2e1b12341da96a1e5031af1c0f536c0a72eb5 /unittests/allplatformstests.py
parent905a361ca0c537f496b06576b1ea1c8824b6d487 (diff)
downloadmeson-457e2d9812e4514ddea59d67a72a02820e82d65f.zip
meson-457e2d9812e4514ddea59d67a72a02820e82d65f.tar.gz
meson-457e2d9812e4514ddea59d67a72a02820e82d65f.tar.bz2
unittests: use UnitTest.addCleanup a bit
Diffstat (limited to 'unittests/allplatformstests.py')
-rw-r--r--unittests/allplatformstests.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index ea5ab8e..d0a1632 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -1499,19 +1499,22 @@ class AllPlatformTests(BasePlatformTests):
else:
shlibfile = os.path.join(tdir, 'libalexandria.' + shared_suffix)
self.build_shared_lib(cc, source, objectfile, shlibfile, impfile)
- # Run the test
- try:
- self.init(tdir)
- self.build()
- self.run_tests()
- finally:
- os.unlink(shlibfile)
- if is_windows():
- # Clean up all the garbage MSVC writes in the
- # source tree.
+
+ if is_windows():
+ def cleanup() -> None:
+ """Clean up all the garbage MSVC writes in the source tree."""
+
for fname in glob(os.path.join(tdir, 'alexandria.*')):
- if os.path.splitext(fname)[1] not in ['.c', '.h']:
+ if os.path.splitext(fname)[1] not in {'.c', '.h'}:
os.unlink(fname)
+ self.addCleanup(cleanup)
+ else:
+ self.addCleanup(os.unlink, shlibfile)
+
+ # Run the test
+ self.init(tdir)
+ self.build()
+ self.run_tests()
@skipIfNoPkgconfig
def test_pkgconfig_static(self):