Bug 279316 - Mk/Uses/cmake.mk: Make parallel level adjustable for tests
Summary: Mk/Uses/cmake.mk: Make parallel level adjustable for tests
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-kde (group)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-26 08:47 UTC by Daniel Engberg
Modified: 2024-06-06 19:08 UTC (History)
4 users (show)

See Also:


Attachments
Patch for cmake.mk (1.03 KB, patch)
2024-05-26 08:47 UTC, Daniel Engberg
no flags Details | Diff
Patch for cmake.mk v2 (973 bytes, patch)
2024-05-26 08:48 UTC, Daniel Engberg
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Engberg freebsd_committer freebsd_triage 2024-05-26 08:47:37 UTC
Created attachment 250976 [details]
Patch for cmake.mk

Some projects don't support running tests in parallel (example chinese/libchewing) and currently there's no way of disabling it.

Add CMAKE_TESTING_PARALLEL_LEVEL and default to MAKE_JOBS_NUMBER
Switch to MAKE_JOBS_NUMBER as _MAKE_JOBS_NUMBER is unset if MAKE_JOBS_UNSAFE is defined.

Reference:
https://git.alpinelinux.org/aports/tree/community/libchewing/APKBUILD#n44
Comment 1 Daniel Engberg freebsd_committer freebsd_triage 2024-05-26 08:48:45 UTC
Created attachment 250977 [details]
Patch for cmake.mk v2

Remove stray blank line
Comment 2 Gleb Popov freebsd_committer freebsd_triage 2024-05-27 19:13:00 UTC
Why not append ${CMAKE_TESTING_PARALLEL_LEVEL} to TEST_ENV rather than adding it verbatim into do-test?
Comment 3 Daniel Engberg freebsd_committer freebsd_triage 2024-05-27 20:47:39 UTC
It overwrites TEST_ENV

Without appending to TEST_ENV
make test -V TEST_ENV
NINJA_STATUS="[%p %s/%t] " XDG_DATA_HOME=/usr/ports/textproc/libxml2/work  XDG_CONFIG_HOME=/usr/ports/textproc/libxml2/work  XDG_CACHE_HOME=/usr/ports/textproc/libxml2/work/.cache  HOME=/usr/ports/textproc/libxml2/work PATH=/usr/ports/textproc/libxml2/work/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin PKG_CONFIG_LIBDIR=/usr/ports/textproc/libxml2/work/.pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/share/pkgconfig:/usr/libdata/pkgconfig MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES DESTDIR=/usr/ports/textproc/libxml2/work/stage PREFIX=/usr/local  LOCALBASE=/usr/local  CC="cc" CFLAGS="-O2 -pipe -march=tigerlake  -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing "  CPP="cpp" CPPFLAGS="-DLIBICONV_PLUG -isystem /usr/local/include"  LDFLAGS=" -Wl,--undefined-version -fstack-protector-strong -L/usr/local/lib " LIBS=""  CXX="c++" CXXFLAGS="-O2 -pipe -march=tigerlake -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -DLIBICONV_PLUG -isystem /usr/local/include " BSD_INSTALL_PROGRAM="install  -s -m 555"  BSD_INSTALL_LIB="install  -s -m 0644"  BSD_INSTALL_SCRIPT="install  -m 555"  BSD_INSTALL_DATA="install  -m 0644"  BSD_INSTALL_MAN="install  -m 444"

Appending (TEST_ENV+= .... in cmake.mk)
make test -V TEST_ENV
CTEST_PARALLEL_LEVEL=6
Comment 4 Po-Chuan Hsieh freebsd_committer freebsd_triage 2024-05-28 13:41:03 UTC
We could use more straightforward (and simpler) knob such as CMAKE_TESTING_JOBS or CMAKE_TESTING_JOBS_NUMBER rather than CMAKE_TESTING_PARALLEL_LEVEL. We don't have to follow upstream (cmake) naming here.
Comment 5 Matthias Andree freebsd_committer freebsd_triage 2024-05-28 23:14:15 UTC
Thank you, Daniel, for the initiative.

(In reply to Po-Chuan Hsieh from comment #4)
I find that proposal for consistency useful, but should we make this a generic "use different test concurrency level" knob and omit the CMAKE_ from the feature's name in as far as our framework exposes it, and only use it in the implementation?

I am thinking that the cmake-independent approach could be like:

TEST_JOBS_NUMBER?=${MAKE_JOBS_NUMBER}

or possibly blank or 1 if we find TEST_JOBS_UNSAFE defined or == "yes".

...and then cmake.mk can derive CMAKE_TESTING_PARALLEL_LEVEL from that ${TEST_JOBS_NUMBER}.
Comment 6 Daniel Engberg freebsd_committer freebsd_triage 2024-06-01 18:00:12 UTC
I think there's value to keep it separate as it doesn't apply to MAKE_JOBS_NUMBER to highlight the difference, setting 0 is allowed whereas (g)make will barf doing so for example.
Comment 7 Daniel Engberg freebsd_committer freebsd_triage 2024-06-05 18:36:03 UTC
Is this fine as is or what needs to be done to get it moving?
Comment 8 Gleb Popov freebsd_committer freebsd_triage 2024-06-05 18:57:50 UTC
LGTM
Comment 9 commit-hook freebsd_committer freebsd_triage 2024-06-06 19:08:46 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3522562bd1443ced62a674a22fec1877277b1b3b

commit 3522562bd1443ced62a674a22fec1877277b1b3b
Author:     Daniel Engberg <diizzy@FreeBSD.org>
AuthorDate: 2024-06-05 21:44:44 +0000
Commit:     Daniel Engberg <diizzy@FreeBSD.org>
CommitDate: 2024-06-06 19:05:47 +0000

    Mk/Uses/cmake.mk: Make parallel level adjustable for tests

    Some projects don't support running tests in parallel
    (for example chinese/libchewing) and currently there's no way of
    disabling it.

    Add CMAKE_TESTING_PARALLEL_LEVEL and default to MAKE_JOBS_NUMBER
    Switch to MAKE_JOBS_NUMBER as _MAKE_JOBS_NUMBER is unset if
    MAKE_JOBS_UNSAFE is defined.

    PR:             279316
    Approved by:    portmgr (arrowd)

 Mk/Uses/cmake.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)