Skip to content

Fix base.mk recipe loops that ignore a failed iteration - #142

Draft
jnasbyupgrade wants to merge 4 commits into
Postgres-Extensions:masterfrom
jnasbyupgrade:issue-140-pgtle-exit-status
Draft

jnasbyupgrade wants to merge 4 commits into
Postgres-Extensions:masterfrom
jnasbyupgrade:issue-140-pgtle-exit-status

Conversation

@jnasbyupgrade

@jnasbyupgrade jnasbyupgrade commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Five base.mk targets run one command per extension or per file, and a failed command was ignored unless it was the last one, so make exited 0 after a real failure. They now fail as soon as any one command fails.

Target Command run per item Failure that was ignored
pgtle pgtle.sh --extension <ext> any extension but the last
results cp test/results/<name>.out test/expected/<name>.out any file but the last
results-build cp test/build/results/<name>.out test/build/expected/<name>.out any file, including the last: the skipped-file check after the loop discarded the loop's status
print-pgtle cat pg_tle/<version>/<ext>.sql any extension but the last
test/install/schedule (with PGXNTOOL_ENABLE_TEST_INSTALL=yes) echo "test: ../install/<name>" >> test/install/schedule any file but the last, leaving an incomplete schedule

pgtle joined its $(foreach ...) calls with ;. It now runs them in a shell for loop over the extensions, with || exit 1 on each call. make -n pgtle in a two-extension project:

for ext in ext_alpha ext_beta; do \
	pgxntool/pgtle.sh --extension $ext  || exit 1; \
done

PGXNTOOL_PGTLE_VERSION handling is unchanged (--pgtle-version 1.5.0+ is still appended to each call when set).

The other four targets put || exit 1 on the command inside the loop.

Tests

Postgres-Extensions/pgxntool-test#108 adds regression tests for pgtle, results and results-build. Each forces a failure by putting a directory where a file would be written, which fails even when the tests run as root. For results, the failing copy is not the last one.

pgtle was also checked by hand in a scratch two-extension project, replacing one extension's pg_tle/1.5.0+/<ext>.sql output with a directory:

Case Before After
first extension fails exit 0 exit 2
last extension fails exit 2 exit 2
no failure exit 0 exit 0
no failure, PGXNTOOL_PGTLE_VERSION=1.5.0+ - exit 0

print-pgtle and the install schedule have no regression test, because neither failure can be forced portably:

  • print-pgtle already rejects a missing or non-regular file before cat runs. A test would need cat to fail on a regular file, which means a read error. Checked by hand on Linux, in a scratch two-extension project, by symlinking the first extension's pg_tle/1.5.0+/<ext>.sql to /proc/self/mem. That path is a regular file whose read fails with Input/output error. make -o pgtle print-pgtle PGXNTOOL_PGTLE_TARGET_VERSION=1.5.2 exited 0 before this change and exits 2 after it. /proc is Linux-only, so this isn't a committed test.
  • Every append in the schedule loop writes to the file that the line before the loop has just created with >. Anything a test can do to that path also makes that first write fail, and make already stops there. Only a write error partway through the loop, such as a full disk, reaches the ignored case.

Fixes #140

The `pgtle` recipe joined its per-extension `pgtle.sh` calls with `;`, so
the target's exit status was that of the last call only. Chain them with
`&&` (ending in `true`) so a failure for any extension fails the target.

Fixes Postgres-Extensions#140

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 032af818-56aa-46c2-b729-3cfa4745d623

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

`results`, `results-build`, `print-pgtle` and the test/install schedule
rule each run one command per file or extension inside a shell loop. A
loop's status is only its last command's, so a failure partway through
was ignored. `results-build` also discarded the last copy's status,
behind its trailing skipped-file check. Each command now ends in
`|| exit 1`, matching the `make pgtle` fix.

The HISTORY.asc entry for Postgres-Extensions#140 now covers every affected target.
jnasbyupgrade added a commit to jnasbyupgrade/pgxntool-test that referenced this pull request Oct 14, 2026
Add two tests to test/standard/make-test.bats that make a `cp` into the
expected-output directory fail by putting a directory where cp writes,
which fails even as root. The `make results` test makes a copy other
than the last one fail, and runs `make -o verify-results results` so
only the copy loop runs. The `results-build` test runs the real target.
Without the fix, both targets exit 0 after the failed copy.

Covers Postgres-Extensions/pgxntool#140; needs the recipe fix in
Postgres-Extensions/pgxntool#142.
@jnasbyupgrade jnasbyupgrade changed the title Fix make pgtle ignoring failures for all but the last extension Fix base.mk recipe loops that ignore a failed iteration Oct 14, 2026
The lead sentence said a failure of any command but the last was
ignored, but the results-build entry covers the last command too.
`pgtle` now calls `pgtle.sh` once per extension inside a shell `for`
loop, with `|| exit 1` on each call. That is the form the `results`,
`results-build` and test/install schedule loops already use. It still
stops at the first extension that fails. The calls, their arguments
and order, and make's exit status are unchanged.
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.

make pgtle exits 0 when pgtle.sh fails for any extension except the last

1 participant