Skip to content

gnu tests: limit make jobs to nproc output - #13991

Open
kevinburke wants to merge 1 commit into
uutils:mainfrom
kevinburke:ci-limit-gnu-test-jobs
Open

gnu tests: limit make jobs to nproc output#13991
kevinburke wants to merge 1 commit into
uutils:mainfrom
kevinburke:ci-limit-gnu-test-jobs

Conversation

@kevinburke

Copy link
Copy Markdown
Contributor

run-gnu-test.sh passed the nproc executable path after a bare -j,
which enabled unlimited make parallelism and treated the path as a target.

Execute nproc, validate its output, and pass the count as an attached -j
argument. Add an end-to-end regression test for the effective MAKEFLAGS.

Copilot AI lite review requested due to automatic review settings August 17, 2026 17:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR fixes run-gnu-test.sh to correctly limit make parallelism by executing nproc, validating its output, and passing the job count via -j<N>. It also adds a regression test and updates CI to run all Python tests under util/.

Changes:

  • Execute nproc, validate numeric output, and append -j<JOBS> to MAKEFLAGS in util/run-gnu-test.sh.
  • Add an end-to-end Python unittest that asserts the effective MAKEFLAGS contains -j<N> and rejects invalid nproc output.
  • Update GitHub Actions to discover and run all util/test_*.py Python unit tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
util/test_run_gnu_test.py Adds an end-to-end regression test covering MAKEFLAGS and invalid nproc output behavior.
util/run-gnu-test.sh Fixes job count handling by executing nproc, validating the result, and forming -j<N> correctly.
.github/workflows/code-quality.yml Expands CI to run all Python unit tests in util/ via unittest discovery.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread util/run-gnu-test.sh Outdated
# Use GNU nproc for *BSD
NPROC=$(command -v ${path_GNU}/src/nproc||command -v nproc)
MAKEFLAGS="${MAKEFLAGS} -j ${NPROC}"
NPROC_COMMAND=$(command -v "${path_GNU}/src/nproc" || command -v nproc)
Comment thread util/test_run_gnu_test.py Outdated
Comment on lines +51 to +57
return subprocess.run(
["bash", str(RUN_GNU_TEST)],
cwd=REPO_ROOT,
env=env,
capture_output=True,
text=True,
timeout=10,
Comment thread util/test_run_gnu_test.py Outdated

def run_script(self, nproc_output):
nproc = self.gnu_dir / "src" / "nproc"
nproc.write_text(f"#!/bin/sh\nprintf '%s\\n' '{nproc_output}'\n")
Copilot AI review requested due to automatic review settings August 17, 2026 18:05
@kevinburke
kevinburke force-pushed the ci-limit-gnu-test-jobs branch from faf2d37 to 9a825e3 Compare August 17, 2026 18:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (1)

util/run-gnu-test.sh:38

  • With set -e, the script can exit without a clear error message when neither ${path_GNU}/src/nproc is executable nor nproc exists on PATH (and likewise if invoking nproc itself fails). Consider explicitly selecting an executable path (using -x for the in-tree binary), handling the “not found” case, and checking the nproc exit status so failures are reported deterministically.
NPROC_COMMAND=$(command -v "${path_GNU}/src/nproc" || command -v nproc)
JOBS=$("${NPROC_COMMAND}")

@kevinburke
kevinburke force-pushed the ci-limit-gnu-test-jobs branch from 9a825e3 to a7d375f Compare August 17, 2026 18:11
Copilot AI review requested due to automatic review settings August 17, 2026 18:11
@codspeed-hq

codspeed-hq Bot commented Aug 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 350 untouched benchmarks
⏩ 53 skipped benchmarks1


Comparing kevinburke:ci-limit-gnu-test-jobs (e7ba126) with main (dc784af)

Open in CodSpeed

Footnotes

  1. 53 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread util/run-gnu-test.sh Outdated
Comment on lines +31 to +39
NPROC_COMMAND=$(command -v "${path_GNU}/src/nproc" || command -v nproc)
JOBS=$("${NPROC_COMMAND}")
case "${JOBS}" in
'' | 0 | *[!0-9]*)
echo "Error: '${NPROC_COMMAND}' returned an invalid job count: '${JOBS}'" >&2
exit 1
;;
esac
MAKEFLAGS="${MAKEFLAGS:+${MAKEFLAGS} }-j${JOBS}"
Copilot AI review requested due to automatic review settings August 17, 2026 18:25
@kevinburke
kevinburke force-pushed the ci-limit-gnu-test-jobs branch from a7d375f to 0bb859b Compare August 17, 2026 18:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (1)

util/run-gnu-test.sh:42

  • The job-count validation rejects 0 but still accepts values like 00/000 (these are effectively zero and would re-enable unlimited make parallelism). Since the intent is to require a positive integer, tighten the check to only allow 1.. and digits.
JOBS=$("${NPROC_COMMAND}")
case "${JOBS}" in
    '' | 0 | *[!0-9]*)
        echo "Error: '${NPROC_COMMAND}' returned an invalid job count: '${JOBS}'" >&2
        exit 1
        ;;
esac

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)

@oech3

oech3 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

I don't think it is worth to have 100+ lines just for this. How about removing regression test which is unrelated with actual production?

@sylvestre

Copy link
Copy Markdown
Contributor

+1, please make this shorter

run-gnu-test.sh put the nproc executable path after a bare -j. GNU make
treated -j as unlimited parallelism and the path as another target,
oversubscribing the test runner.

Resolve and execute nproc, reject a missing command or invalid output, and
attach the resulting count to -j.
Copilot AI review requested due to automatic review settings August 17, 2026 20:56
@kevinburke
kevinburke force-pushed the ci-limit-gnu-test-jobs branch from 0bb859b to e7ba126 Compare August 17, 2026 20:56
@kevinburke

Copy link
Copy Markdown
Contributor Author

OK - @oech3 @sylvestre I agree, removed all of the Python tests, there wasn't a good, short way to write them.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (2)

util/run-gnu-test.sh:35

  • util/build-gnu.sh falls back to gnproc on platforms where GNU coreutils are prefixed (e.g., macOS/Homebrew). This updated lookup only checks nproc, so run-gnu-test.sh can now hard-fail in environments that previously had a usable gnproc in PATH.
NPROC_COMMAND=$(command -v "${path_GNU}/src/nproc" || command -v nproc || :)
if [ -z "${NPROC_COMMAND}" ] || [ ! -x "${NPROC_COMMAND}" ]; then
    echo "Error: unable to find an executable nproc command at '${path_GNU}/src/nproc' or in PATH" >&2
    exit 1

util/run-gnu-test.sh:45

  • The PR description says an end-to-end regression test was added for the effective MAKEFLAGS, but this PR only changes run-gnu-test.sh and there is no test coverage protecting the new -j$(nproc) behavior from regressing (e.g., back to -j <path-to-nproc> or bare -j). Please add an integration test that runs util/run-gnu-test.sh against a minimal fake GNU tree + fake make, and asserts the MAKEFLAGS seen by make includes -j<N> where <N> is the mocked nproc output.
MAKEFLAGS="${MAKEFLAGS:+${MAKEFLAGS} }-j${JOBS}"
export MAKEFLAGS
echo "GNU test make job count: ${JOBS}"

@sylvestre

Copy link
Copy Markdown
Contributor

@kevinburke thanks
please double check in the future before submitting the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants