packages/meson/0002-tests-Avoid-modifying-test-dirs-in-allplatformtests.patch
2024-12-23 08:59:33 +01:00

54 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
Date: Mon, 9 Dec 2024 16:18:50 +0100
Subject: [PATCH] tests: Avoid modifying test dirs in allplatformtests
Tests can tread on each other's toes when parallelism is high enough.
For a concrete case, `test_prebuilt_shared_lib` creates an object file
in the `17 prebuilt shared` test dir.
`test_prebuilt_shared_lib_rpath_same_prefix` uses `shutil.copytree` to
copy that same test dir to a temporary location.
If the former test cleans up its object file while `copytree` is
running, the copy can fail with a fatal ENOENT `shutil.Error`.
Use `copy_srcdir` in all tests that modify the testdir (that I spotted)
to prevent this from happening.
---
unittests/allplatformstests.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index cadbc40e9680..69bdb12d3f4a 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -1732,7 +1732,7 @@ class AllPlatformTests(BasePlatformTests):
def test_prebuilt_static_lib(self):
(cc, stlinker, object_suffix, _) = self.detect_prebuild_env()
- tdir = os.path.join(self.unit_test_dir, '16 prebuilt static')
+ tdir = self.copy_srcdir(os.path.join(self.unit_test_dir, '16 prebuilt static'))
source = os.path.join(tdir, 'libdir/best.c')
objectfile = os.path.join(tdir, 'libdir/best.' + object_suffix)
stlibfile = os.path.join(tdir, 'libdir/libbest.a')
@@ -1766,7 +1766,7 @@ class AllPlatformTests(BasePlatformTests):
def test_prebuilt_shared_lib(self):
(cc, _, object_suffix, shared_suffix) = self.detect_prebuild_env()
- tdir = os.path.join(self.unit_test_dir, '17 prebuilt shared')
+ tdir = self.copy_srcdir(os.path.join(self.unit_test_dir, '17 prebuilt shared'))
source = os.path.join(tdir, 'alexandria.c')
objectfile = os.path.join(tdir, 'alexandria.' + object_suffix)
impfile = os.path.join(tdir, 'alexandria.lib')
@@ -1981,7 +1981,7 @@ class AllPlatformTests(BasePlatformTests):
https://github.com/mesonbuild/meson/issues/2785
'''
(cc, stlinker, objext, shext) = self.detect_prebuild_env()
- testdir = os.path.join(self.unit_test_dir, '18 pkgconfig static')
+ testdir = self.copy_srcdir(os.path.join(self.unit_test_dir, '18 pkgconfig static'))
source = os.path.join(testdir, 'foo.c')
objectfile = os.path.join(testdir, 'foo.' + objext)
stlibfile = os.path.join(testdir, 'libfoo.a')