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

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

codspeed 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

github-actions Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes 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

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

Comment thread util/run-gnu-test.sh Outdated
Copilot AI review requested due to automatic review settings August 28, 2026 09:36

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sylvestre
sylvestre enabled auto-merge (rebase) August 28, 2026 09:44
Comment thread util/run-gnu-test.sh Outdated
Comment on lines +32 to +42
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
fi
JOBS=$("${NPROC_COMMAND}")
case "${JOBS}" in
'' | 0 | *[!0-9]*)
echo "Error: '${NPROC_COMMAND}' returned an invalid job count: '${JOBS}'" >&2
exit 1
;;
esac

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.

Suggested change
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
fi
JOBS=$("${NPROC_COMMAND}")
case "${JOBS}" in
'' | 0 | *[!0-9]*)
echo "Error: '${NPROC_COMMAND}' returned an invalid job count: '${JOBS}'" >&2
exit 1
;;
esac

Assume that echo 2 always exist since it is builtin.

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 || echo 2)

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.

Suggested change
NPROC_COMMAND=$(command -v "${path_GNU}/src/nproc" || command -v nproc || echo 2)
NPROC_COMMAND=$(command -v "${path_GNU}/src/nproc" || command -v nproc || echo "echo 2")

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.

Actually, we only need to define $JOBS.

auto-merge was automatically disabled August 29, 2026 05:19

Head branch was pushed to by a user without write access

Copilot AI review requested due to automatic review settings August 29, 2026 05:19
@kevinburke
kevinburke force-pushed the ci-limit-gnu-test-jobs branch from 7326357 to b8774c1 Compare August 29, 2026 05:19

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 2 comments.

Comment thread util/run-gnu-test.sh Outdated
Comment on lines +31 to +35
NPROC_COMMAND=$(command -v "${path_GNU}/src/nproc" || command -v nproc || echo 2)
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
fi
Comment thread util/run-gnu-test.sh
Comment on lines +43 to +45
MAKEFLAGS="${MAKEFLAGS:+${MAKEFLAGS} }-j${JOBS}"
export MAKEFLAGS
echo "GNU test make job count: ${JOBS}"
@kevinburke
kevinburke force-pushed the ci-limit-gnu-test-jobs branch from b8774c1 to 8281bef Compare August 29, 2026 06:14
Copilot AI review requested due to automatic review settings August 29, 2026 06:14

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 1 comment.

Suppressed comments (1)

util/run-gnu-test.sh:44

  • This change fixes incorrect MAKEFLAGS construction and introduces new validation/error behavior, but the PR description also calls for an end-to-end regression test of the effective MAKEFLAGS/-j handling. There doesn’t appear to be any test added in this PR for this behavior; per AGENTS.md, bug fixes/new behavior should come with a Rust test to prevent regression.
MAKEFLAGS="${MAKEFLAGS:+${MAKEFLAGS} }-j${JOBS}"
export MAKEFLAGS
echo "GNU test make job count: ${JOBS}"

Comment thread util/run-gnu-test.sh
Comment on lines +31 to +35
if NPROC_COMMAND=$(command -v "${path_GNU}/src/nproc" || command -v nproc); then
JOBS=$("${NPROC_COMMAND}")
else
JOBS=2
fi
Comment thread util/run-gnu-test.sh
# Use GNU nproc for *BSD
NPROC=$(command -v ${path_GNU}/src/nproc||command -v nproc)
MAKEFLAGS="${MAKEFLAGS} -j ${NPROC}"
if NPROC_COMMAND=$(command -v "${path_GNU}/src/nproc" || command -v nproc); then

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.

We don't need to assume missing nproc binary as we use GNU's one.

Comment thread util/run-gnu-test.sh
else
JOBS=2
fi
case "${JOBS}" in

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.

Believe existing nproc and remove this if block.

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, fall back to two jobs if it is unavailable, reject
invalid output, and attach the resulting count to -j.
@sylvestre
sylvestre force-pushed the ci-limit-gnu-test-jobs branch from 8281bef to cfcd890 Compare September 19, 2026 21:27
Copilot AI review requested due to automatic review settings September 19, 2026 21:27

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.

Comment thread util/run-gnu-test.sh
exit 1
;;
esac
MAKEFLAGS="${MAKEFLAGS:+${MAKEFLAGS} }-j${JOBS}"

This branch has not been deployed

No deployments
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