PKGBUILDs/extra/meson/0003-Limit-unittests-workers.patch
2024-02-12 02:39:10 +00:00

40 lines
1.5 KiB
Diff

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!