Skip to content

Clarify that test/install only prepares the test environment - #144

Open
jnasbyupgrade wants to merge 2 commits into
Postgres-Extensions:masterfrom
jnasbyupgrade:docs-test-install-intent
Open

jnasbyupgrade wants to merge 2 commits into
Postgres-Extensions:masterfrom
jnasbyupgrade:docs-test-install-intent

Conversation

@jnasbyupgrade

@jnasbyupgrade jnasbyupgrade commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

test/install exists only to set up the environment for the real tests; its output is not a test result (not compared against expected output, not validated as TAP). A failure in it must abort the run, which relies on ON_ERROR_STOP: the static check requires each test/install/*.sql file to include test/pgxntool/psql.sql or set/unset ON_ERROR_STOP itself.

Docs only: README.asc (+ regenerated README.html) and CLAUDE.md. No behavior change, so no HISTORY.asc entry.

test/install output is not a test result: it is not compared against
expected output or validated as TAP. A failure in it must abort the run,
which relies on ON_ERROR_STOP (the static check requires each file to
include test/pgxntool/psql.sql or set/unset ON_ERROR_STOP itself).
@coderabbitai

coderabbitai Bot commented Oct 15, 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: 97327ddd-895e-4127-88d4-774ac29defb1

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.

Comment thread README.asc
Comment on lines 168 to +170
=== test/install
Runs setup files before the main test suite within the same `pg_regress` invocation. This allows expensive one-time operations (like extension installation) to set up state that persists into the regular test files.
`test/install` only prepares the environment for your real tests; its output is not a test result. If a file in it fails, the run aborts, but short of a failure nothing about its output is checked: it is not compared against expected output and not validated as TAP, so don't write tests there (put them in `test/sql`).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Overstated claim: "If a file in it fails, the run aborts"

This reads as unconditional, but abort-on-failure only happens when ON_ERROR_STOP is explicitly turned on. Per the project's own static check (and the unchanged WARNING a few lines down), a file that does \unset ON_ERROR_STOP or \set ON_ERROR_STOP off still passes the check — in that case psql prints the error, keeps going, and the file "passes" regardless:

pgxntool/README.asc

Lines 212 to 214 in d2e9236

WARNING: **`+test/install/*.out+` is not a test result and is never compared against anything.** Unlike every other test type pgxntool supports, the `test/install` directory's actual output is written to the exact same file as its expected output, so there is no diff — a wrong or changed result will never fail the build, no matter how much it changes. The *only* thing that still fails the build is a hard SQL error, and only if the file sets `ON_ERROR_STOP` (directly, or via `\i test/pgxntool/psql.sql`) — without it, psql prints the error, keeps going, and the file "passes" regardless. pgxntool enforces this by default (`_check-test-install-error-stop`, see `PGXNTOOL_ENABLE_TEST_INSTALL_ERROR_STOP_CHECK` to disable), but that only guarantees errors are caught — it does not give you real output validation. If you need actual output comparison, put that logic in `test/sql` instead (or use pgTap assertions from within the install file itself).

So this new sentence contradicts the existing WARNING in the same section. Consider something like "If a file in it fails and has ON_ERROR_STOP on, the run aborts," or otherwise clarify that the check only requires an explicit, deliberate choice — which could be to turn it off.

The identical overstatement was also introduced in this PR's CLAUDE.md edit, immediately followed by the correct qualifier ("...whatever the value"):

pgxntool/CLAUDE.md

Lines 209 to 211 in d2e9236

- **test-build** runs first, in its own separate `pg_regress` pass over `test/build/*.sql`, and gates the main suite: if it fails, `test/install`/`test/sql` never run at all. It does compare actual vs expected normally (`test/build/results/` vs `test/build/expected/`) -- use `make results-build` to refresh its expected output, not `make results`.
- **test/install** only sets up the environment for the real tests; its output is not a test result (not compared against expected output, not validated as TAP), but a failure in it must abort the run. It does NOT get a real diff at all: its actual output is written to the exact same file as its expected output, so a content difference can never fail the build, no matter what changed. The only thing that still fails the build is a hard SQL error, and only if the file has `ON_ERROR_STOP` set (directly, or via `\i test/pgxntool/psql.sql`) -- pgxntool checks for this by default, passing any file that includes `psql.sql` or has its own `\set`/`\unset ON_ERROR_STOP`, whatever the value. If a `test/install/*.sql` file is misbehaving, don't go looking for a diff; check whether it errored, and don't assume a stale-looking `.out` for it means anything.

Comment thread README.asc
Comment on lines 168 to +170
=== test/install
Runs setup files before the main test suite within the same `pg_regress` invocation. This allows expensive one-time operations (like extension installation) to set up state that persists into the regular test files.
`test/install` only prepares the environment for your real tests; its output is not a test result. If a file in it fails, the run aborts, but short of a failure nothing about its output is checked: it is not compared against expected output and not validated as TAP, so don't write tests there (put them in `test/sql`).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

New guidance conflicts with the existing WARNING's suggestion

This sentence says "don't write tests there (put them in test/sql)", but the unchanged WARNING later in this same section still offers writing pgTap assertions inside the install file as a sanctioned alternative:

pgxntool/README.asc

Lines 212 to 214 in d2e9236

WARNING: **`+test/install/*.out+` is not a test result and is never compared against anything.** Unlike every other test type pgxntool supports, the `test/install` directory's actual output is written to the exact same file as its expected output, so there is no diff — a wrong or changed result will never fail the build, no matter how much it changes. The *only* thing that still fails the build is a hard SQL error, and only if the file sets `ON_ERROR_STOP` (directly, or via `\i test/pgxntool/psql.sql`) — without it, psql prints the error, keeps going, and the file "passes" regardless. pgxntool enforces this by default (`_check-test-install-error-stop`, see `PGXNTOOL_ENABLE_TEST_INSTALL_ERROR_STOP_CHECK` to disable), but that only guarantees errors are caught — it does not give you real output validation. If you need actual output comparison, put that logic in `test/sql` instead (or use pgTap assertions from within the install file itself).

("...If you need actual output comparison, put that logic in test/sql instead (or use pgTap assertions from within the install file itself).")

Read together, the doc now gives contradictory guidance about whether pgTap assertions belong in test/install files. Worth reconciling — either drop the WARNING's parenthetical, or soften the new sentence (e.g. "don't rely on output comparison there" rather than a blanket "don't write tests there").

Comment thread CLAUDE.md
Comment on lines 209 to 211
- **test-build** runs first, in its own separate `pg_regress` pass over `test/build/*.sql`, and gates the main suite: if it fails, `test/install`/`test/sql` never run at all. It does compare actual vs expected normally (`test/build/results/` vs `test/build/expected/`) -- use `make results-build` to refresh its expected output, not `make results`.
- **test/install** does NOT get a real diff at all: its actual output is written to the exact same file as its expected output, so a content difference can never fail the build, no matter what changed. The only thing that still fails the build is a hard SQL error, and only if the file has `ON_ERROR_STOP` set (directly, or via `\i test/pgxntool/psql.sql`) -- pgxntool checks for this by default, passing any file that includes `psql.sql` or has its own `\set`/`\unset ON_ERROR_STOP`, whatever the value. If a `test/install/*.sql` file is misbehaving, don't go looking for a diff; check whether it errored, and don't assume a stale-looking `.out` for it means anything.
- **test/install** only sets up the environment for the real tests; its output is not a test result (not compared against expected output, not validated as TAP), but a failure in it must abort the run. It does NOT get a real diff at all: its actual output is written to the exact same file as its expected output, so a content difference can never fail the build, no matter what changed. The only thing that still fails the build is a hard SQL error, and only if the file has `ON_ERROR_STOP` set (directly, or via `\i test/pgxntool/psql.sql`) -- pgxntool checks for this by default, passing any file that includes `psql.sql` or has its own `\set`/`\unset ON_ERROR_STOP`, whatever the value. If a `test/install/*.sql` file is misbehaving, don't go looking for a diff; check whether it errored, and don't assume a stale-looking `.out` for it means anything.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same overstatement as in the README.asc edit

"but a failure in it must abort the run" is stated unconditionally, but the very next clause (unchanged by this PR) says the check accepts a file with \set/\unset ON_ERROR_STOP "whatever the value" — i.e. explicitly turning it off also passes the check, and in that case a failure would not abort the run. Same issue as the README.asc edit in this PR:

pgxntool/README.asc

Lines 168 to 170 in d2e9236

=== test/install
`test/install` only prepares the environment for your real tests; its output is not a test result. If a file in it fails, the run aborts, but short of a failure nothing about its output is checked: it is not compared against expected output and not validated as TAP, so don't write tests there (put them in `test/sql`).

Consider qualifying this, e.g. "...but a failure in it must abort the run if ON_ERROR_STOP is on."

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.

1 participant