diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-08-19 09:17:57 -0700 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-08-20 21:22:55 +0300 |
commit | e0ab7290f0c75e485876c24a795925ae8462a1ce (patch) | |
tree | a44c64dbb7cc506483d83bd6af04cea2d84586d2 | |
parent | 3d98d54fc5bd20cfb18ad21edc9733d321c028a4 (diff) | |
download | meson-e0ab7290f0c75e485876c24a795925ae8462a1ce.zip meson-e0ab7290f0c75e485876c24a795925ae8462a1ce.tar.gz meson-e0ab7290f0c75e485876c24a795925ae8462a1ce.tar.bz2 |
unittests: Ensure that symlink is removed after tests complete
using `TestCase.addCleanup` is both neat and tidy, and also ensures that
the cleanup will be done, even if the test fails.
-rw-r--r-- | unittests/linuxliketests.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py index a86c3dc..2bcf5c9 100644 --- a/unittests/linuxliketests.py +++ b/unittests/linuxliketests.py @@ -264,14 +264,18 @@ class LinuxlikeTests(BasePlatformTests): pcfile = f.read() self.assertFalse('blub_blob_blib' in pcfile) - def test_symlink_builddir(self): + def test_symlink_builddir(self) -> None: ''' Test using a symlink as either the builddir for "setup" or the argument for "-C". ''' testdir = os.path.join(self.common_test_dir, '1 trivial') - os.symlink(self.builddir, self.builddir + '-symlink') - self.change_builddir(self.builddir + '-symlink') + + symdir = f'{self.builddir}-symlink' + os.symlink(self.builddir, symdir) + self.addCleanup(os.unlink, symdir) + self.change_builddir(symdir) + self.init(testdir) self.build() self._run(self.mtest_command) |