Skip to content

Cover verify-results-pgtap.sh's regression.diffs classification - #85

Open
jnasbyupgrade wants to merge 5 commits into
Postgres-Extensions:masterfrom
jnasbyupgrade:issue-119-verify-results
Open

jnasbyupgrade wants to merge 5 commits into
Postgres-Extensions:masterfrom
jnasbyupgrade:issue-119-verify-results

Conversation

@jnasbyupgrade

@jnasbyupgrade jnasbyupgrade commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Test coverage for pgxntool PR Postgres-Extensions/pgxntool#121, which lets make results seed the first expected output for a brand-new test (pgxntool issue #119).

New test/standard/verify-results-pgtap-script.bats owns verify-results-pgtap.sh's decision logic, invoking the script directly against a scratch directory with no Make, no foundation environment and no PostgreSQL — the layering CLAUDE.md prescribes, modeled on check-stale-expected-script.bats. It covers:

  • a brand-new test with no baseline (a single @@ -0,0 hunk) now passing
  • a real mismatch against an existing baseline still blocking, including when a brand-new test sits in the same regression.diffs
  • an unblessed file whose output holds a SQL error still blocking, in both of psql's real renderings: column 0 (the test file itself, which pg_regress feeds psql on stdin) and the psql:<file>:<line>: prefix an \i'd file produces — a column-anchored match would miss the second, which is what setup.sql/finish.sql generate
  • a passing test whose pgtap description merely mentions ERROR: being blessed rather than permanently refused
  • an empty-but-existing regression.diffs blocking (pg_regress bailed before comparing anything; test/results/ holds a stale run)
  • blocks that aren't a clean no-baseline shape: a header with no hunks, and one with only some @@ -0,0 hunks
  • unrecognized content after an otherwise-blessable block blocking the whole file — while diff's own \ No newline at end of file marker still doesn't
  • classification driven by unprefixed diff /@@ headers, not by diffed content that looks like a header (both directions: a +@@ ... line inside added content, and a deleted -- comment rendering as --- comment)
  • the pre-existing not ok / # TODO / plan-mismatch scan

make-test.bats keeps only what genuinely needs a real pg_regress run: an end-to-end test that make results seeds a brand-new test's first expected output — asserting the no expected output yet message, so it can't pass on a file that appeared some other way — and one wiring test that make verify-results invokes the script and surfaces its failure. Its TODO and plan-mismatch cases moved into the script-level file rather than paying for a full make verify-results run each to re-test logic decided entirely inside the script.

Test plan

  • test/standard/verify-results-pgtap-script.bats: 16/16 pass.
  • Full test-all against a local pgxntool with pgxntool PR #109 merged in: 273/273 pass, 0 failed, 0 skipped, including every test added or changed here.
  • Each new fail-closed test verified to actually discriminate, by running its fixture against the pre-fix script too: the empty-regression.diffs and junk-after-a-block fixtures exit 0 there (fail-open) and 1 now; the ERROR:-in-a-description fixture exits 1 there (false positive) and 0 now.
  • Full test-all against pgxntool master as it stands today: 14 failures, 0 skipped. All 14 are pre-existing and unrelated to this PR, and CI reproduces exactly the same 14 — they are the tests merged in Cover test-build ordering, build-results, and test/install ON_ERROR_STOP #79 for pgxntool PR #109 (check-test-install-error-stop.sh, build-results, test-build ordering, the dist manifest entry for that script, and test/install marker state). That PR is still open, so the script and targets those tests exercise don't exist in pgxntool master yet; the script-level ones fail with exit 127, "No such file or directory". CI here cannot go green until #109 lands, independently of this PR.

Paired with pgxntool commit ec7c7ee, which lets `make results` seed the
first expected output for a brand-new test (pgxntool issue #119).

New `test/standard/verify-results-pgtap-script.bats` owns the script's
decision logic, invoked directly against a scratch directory with no
Make, foundation environment or PostgreSQL: the no-baseline exemption,
a real mismatch still blocking, an unblessed file holding a SQL error
still blocking, unrecognized `regression.diffs` content failing closed,
classification driven by unprefixed `diff `/`@@ ` headers rather than
diffed content, and the pre-existing `not ok`/TODO/plan-mismatch scan.

`make-test.bats` keeps only what needs a real `pg_regress` run: that
`make results` really does seed a new test's first expected output
end-to-end, and that `make verify-results` invokes the script and
propagates its failure. Its TODO and plan-mismatch cases moved to the
script-level file rather than paying for a full `make verify-results`
run each to re-test logic decided entirely inside the script.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 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: 3d2fd50c-3cec-4019-8a78-1f97743a4b44

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

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.

jnasbyupgrade and others added 4 commits September 15, 2026 17:32
`make results` blesses every `test/results/*.out` into `test/expected/`,
so a leftover `results/brand_new.out` would reappear as an orphaned
expected file for `check-stale-expected` the next time any test in this
environment runs `make results`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Paired with pgxntool commit 93aa10f. The script's fail-closed claims were
asserted in the PR body but only partly tested, and two of them weren't
true: an empty `regression.diffs` and junk following a valid block both
passed.

Adds script-level coverage for an empty `regression.diffs`, a block with
no hunks (also what a pre-12 context diff degrades to) and one with only
some `@@ -0,0` hunks, unrecognized content after a valid block, and both
of psql's real error renderings -- column 0 and the `psql:<file>:<line>:`
prefix an \i'd file produces -- plus the passing test whose description
merely mentions `ERROR:`, which used to be blocked.

The end-to-end `make results` test now asserts the "no expected output
yet" message, so it can't pass on a file that appeared some other way.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`\ No newline at end of file` is part of the diff format, so the new
unrecognized-content check must not read it as junk -- doing so would
block the first bless of any test whose output lacks a trailing newline.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diff body lines with no `diff ` header before them produce no
classification rather than an unrecognized one, so they reach a separate
guard from the junk case above it. Both have to block; only one was
tested.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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