From 58156ef7cfd56ddcbd230c510f363f49a2c172fd Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 18 Mar 2018 20:13:00 +0200 Subject: Grab a file lock on the build dir during modifications. --- run_unittests.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'run_unittests.py') diff --git a/run_unittests.py b/run_unittests.py index 3ea0412..b6367c1 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -37,6 +37,7 @@ from mesonbuild.interpreter import ObjectHolder from mesonbuild.mesonlib import ( is_windows, is_osx, is_cygwin, is_dragonflybsd, windows_proof_rmtree, python_command, meson_command, version_compare, + BuildDirLock ) from mesonbuild.environment import Environment, detect_ninja from mesonbuild.mesonlib import MesonException, EnvironmentException @@ -1882,6 +1883,18 @@ int main(int argc, char **argv) { self.init(testdir, extra_args=['--layout=flat']) self.build() + def test_flock(self): + exception_raised = False + with tempfile.TemporaryDirectory() as tdir: + os.mkdir(os.path.join(tdir, 'meson-private')) + with BuildDirLock(tdir): + try: + with BuildDirLock(tdir): + pass + except MesonException: + exception_raised = True + self.assertTrue(exception_raised, 'Double locking did not raise exception.') + class FailureTests(BasePlatformTests): ''' -- cgit v1.1