diff options
| author | Marek Pikuła <m.pikula@partner.samsung.com> | 2024-08-27 02:12:46 +0200 |
|---|---|---|
| committer | Jussi Pakkanen <jpakkane@gmail.com> | 2024-08-30 02:09:51 +0300 |
| commit | 1794a1e63c8a890aa924b3594946b23fcefcbc9f (patch) | |
| tree | c1cd9e0d31104b92560dfceb18a44c32b4382da4 | |
| parent | 3c0de471228420c333bb98be35a28705d0ec063d (diff) | |
| download | meson-1794a1e63c8a890aa924b3594946b23fcefcbc9f.tar.gz | |
Extend MESON_TESTTHREADS usage
Previously, setting `MESON_TESTTHREADS` to a number lower than 1
resulted in unexpected behavior. This commit introduces test for
negative value (with fallback to 1), and fallback to core count in case
it is set to 0.
It improves experience in job-matrix type of CI workflows, where some
jobs within the matrix require single job execution, whereas others can
default to taking core count as the job count.
Signed-off-by: Marek Pikuła <m.pikula@partner.samsung.com>
| -rw-r--r-- | docs/markdown/Unit-tests.md | 4 | ||||
| -rw-r--r-- | mesonbuild/mtest.py | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/docs/markdown/Unit-tests.md b/docs/markdown/Unit-tests.md index b5d3a1b81..898366095 100644 --- a/docs/markdown/Unit-tests.md +++ b/docs/markdown/Unit-tests.md @@ -89,6 +89,10 @@ variable `MESON_TESTTHREADS` like this. $ MESON_TESTTHREADS=5 meson test ``` +Setting `MESON_TESTTHREADS` to 0 enables the default behavior (core +count), whereas setting an invalid value results in setting the job +count to 1. + ## Priorities *(added in version 0.52.0)* diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 9975afa22..c417bc0b3 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -99,13 +99,17 @@ def uniwidth(s: str) -> int: def determine_worker_count() -> int: varname = 'MESON_TESTTHREADS' + num_workers = 0 if varname in os.environ: try: num_workers = int(os.environ[varname]) + if num_workers < 0: + raise ValueError except ValueError: print(f'Invalid value in {varname}, using 1 thread.') num_workers = 1 - else: + + if num_workers == 0: try: # Fails in some weird environments such as Debian # reproducible build. |
