summarylogtreecommitdiffstats
path: root/0002-Limit-unittests-workers.patch
blob: a2510b442a42ec2daa7b0a3ec7a8c9275bbf4ae6 (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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
Date: Mon, 12 Feb 2024 02:51:51 +0100
Subject: [PATCH] Limit unittests workers

On our new 48-core/96-thread build server, the
`test_install_log_content` test fails, apparently because it runs in
parallel with `test_install_subdir_symlinks`, which modifies the
`59 install subdir` source directory.
---
 run_unittests.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/run_unittests.py b/run_unittests.py
index 7a2502a6e886..f43497b5f5e2 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -22,6 +22,7 @@ import time
 import subprocess
 import os
 import unittest
+import multiprocessing
 
 import mesonbuild.mlog
 import mesonbuild.depfile
@@ -130,7 +131,13 @@ def main():
             # Don't use pytest-xdist when running single unit tests since it wastes
             # time spawning a lot of processes to distribute tests to in that case.
             if not running_single_tests(sys.argv, cases):
-                pytest_args += ['-n', 'auto']
+                try:
+                    num_workers = multiprocessing.cpu_count()
+                except Exception as e:
+                    num_workers = 2
+                if num_workers > 64:
+                    num_workers = 64
+                pytest_args += ['-n', str(num_workers)]
         except ImportError:
             print('pytest-xdist not found, tests will not be distributed across CPU cores')
         # Let there be colors!