diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2023-03-28 08:59:51 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2023-03-30 17:10:53 -0400 |
commit | 9c526974dcfad0191d77550bd636f242bbfa8367 (patch) | |
tree | 6ef9c5bd19af420874c9f2d0a9d40eaf308ae7d3 /unittests | |
parent | 0418a40e68704e2ad36148eb72e92a1206de72dd (diff) | |
download | meson-9c526974dcfad0191d77550bd636f242bbfa8367.zip meson-9c526974dcfad0191d77550bd636f242bbfa8367.tar.gz meson-9c526974dcfad0191d77550bd636f242bbfa8367.tar.bz2 |
msetup: Allow (re)configure of not empty builddir
Also prevent from using a parent directory as builddir by mistake.
Co-authored-by: Volker Weißmann <volker.weissmann@gmx.de>
Co-authored-by: Charles Brunet <charles.brunet@optelgroup.com>
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/allplatformstests.py | 1 | ||||
-rw-r--r-- | unittests/platformagnostictests.py | 35 |
2 files changed, 36 insertions, 0 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index ea9d795..0581caf 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -2046,6 +2046,7 @@ class AllPlatformTests(BasePlatformTests): self.assertFalse(os.path.isfile(promoted_wrap)) subprocess.check_call(self.wrap_command + ['promote', 'athing'], cwd=workdir) self.assertTrue(os.path.isfile(promoted_wrap)) + self.new_builddir() # Ensure builddir is not parent or workdir self.init(workdir) self.build() diff --git a/unittests/platformagnostictests.py b/unittests/platformagnostictests.py index 9fb24f3..1dc8eb0 100644 --- a/unittests/platformagnostictests.py +++ b/unittests/platformagnostictests.py @@ -163,3 +163,38 @@ class PlatformAgnosticTests(BasePlatformTests): # Wipe with a different backend is allowed self.init(testdir, extra_args=['--wipe', '--backend=none']) + + def test_validate_dirs(self): + testdir = os.path.join(self.common_test_dir, '1 trivial') + + # Using parent as builddir should fail + self.builddir = os.path.dirname(self.builddir) + with self.assertRaises(subprocess.CalledProcessError) as cm: + self.init(testdir) + self.assertIn('cannot be a parent of source directory', cm.exception.stdout) + + # Reconfigure of empty builddir should work + self.new_builddir() + self.init(testdir, extra_args=['--reconfigure']) + + # Reconfigure of not empty builddir should work + self.new_builddir() + Path(self.builddir, 'dummy').touch() + self.init(testdir, extra_args=['--reconfigure']) + + # Wipe of empty builddir should work + self.new_builddir() + self.init(testdir, extra_args=['--wipe']) + + # Wipe of partial builddir should work + self.new_builddir() + Path(self.builddir, 'meson-private').mkdir() + Path(self.builddir, 'dummy').touch() + self.init(testdir, extra_args=['--wipe']) + + # Wipe of not empty builddir should fail + self.new_builddir() + Path(self.builddir, 'dummy').touch() + with self.assertRaises(subprocess.CalledProcessError) as cm: + self.init(testdir, extra_args=['--wipe']) + self.assertIn('Directory is not empty', cm.exception.stdout) |