summarylogtreecommitdiffstats
path: root/0003-tests-Fix-unit-tests-with-high-parallelism.patch
blob: 397cca441dfed5e715e7fbc592c55ab603ee02f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
Date: Tue, 5 Mar 2024 19:33:33 +0100
Subject: [PATCH] tests: Fix unit tests with high parallelism

On Arch's shiny new 48-core/96-thread build server, the
`test_install_log_content` test fails because of an unexpected
`invalid-symlink.txt` file. Apparently the test runs in parallel with
`test_install_subdir_symlinks`, which modifies the `59 install subdir`
source directory.

To fix this, make `install_subdir_invalid_symlinks` copy the entire test
into a tmpdir before modifying it.
---
 unittests/linuxliketests.py | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py
index f66dc9769a8f..ce4d36fe024c 100644
--- a/unittests/linuxliketests.py
+++ b/unittests/linuxliketests.py
@@ -1413,25 +1413,22 @@ class LinuxlikeTests(BasePlatformTests):
         Test that installation of broken symlinks works fine.
         https://github.com/mesonbuild/meson/issues/3914
         '''
-        testdir = os.path.join(self.common_test_dir, testdir)
+        testdir = self.copy_srcdir(os.path.join(self.common_test_dir, testdir))
         subdir = os.path.join(testdir, subdir_path)
         with chdir(subdir):
             # Can't distribute broken symlinks in the source tree because it breaks
             # the creation of zipapps. Create it dynamically and run the test by
             # hand.
             src = '../../nonexistent.txt'
             os.symlink(src, 'invalid-symlink.txt')
-            try:
-                self.init(testdir)
-                self.build()
-                self.install()
-                install_path = subdir_path.split(os.path.sep)[-1]
-                link = os.path.join(self.installdir, 'usr', 'share', install_path, 'invalid-symlink.txt')
-                self.assertTrue(os.path.islink(link), msg=link)
-                self.assertEqual(src, os.readlink(link))
-                self.assertFalse(os.path.isfile(link), msg=link)
-            finally:
-                os.remove(os.path.join(subdir, 'invalid-symlink.txt'))
+            self.init(testdir)
+            self.build()
+            self.install()
+            install_path = subdir_path.split(os.path.sep)[-1]
+            link = os.path.join(self.installdir, 'usr', 'share', install_path, 'invalid-symlink.txt')
+            self.assertTrue(os.path.islink(link), msg=link)
+            self.assertEqual(src, os.readlink(link))
+            self.assertFalse(os.path.isfile(link), msg=link)
 
     def test_install_subdir_symlinks(self):
         self.install_subdir_invalid_symlinks('59 install subdir', os.path.join('sub', 'sub1'))