From ec7c7ee8a4dc90c0fbc02e1c17b0decc110729f7 Mon Sep 17 00:00:00 2001 From: jnasbyupgrade Date: Tue, 15 Sep 2026 17:27:04 -0500 Subject: [PATCH 1/3] Let `make results` seed a new test's first expected output `verify-results` blocked `make results` whenever `regression.diffs` existed at all. A test with no expected output file always lands in `regression.diffs` -- `base.mk` touches an empty `test/expected/.out` for it, because `pg_regress` aborts outright on a missing one -- so seeding that first expected file was structurally impossible no matter how clean the new test's actual output was. `verify-results` now classifies each `regression.diffs` block by its hunk headers: a block whose hunks all read `@@ -0,0 +N,M @@` was diffed against that empty placeholder and is let through; anything else still blocks. A test whose output matched any expected file, `_N.out` alternates included, never appears in `regression.diffs` at all, so nothing here re-derives a pass/fail `pg_regress` already decided. One case is still blocked: an as-yet-unblessed file containing a SQL error. `ON_ERROR_STOP` aborts the script before pgtap emits `not ok` or its plan-mismatch line, so the scan above cannot see it, and blessing it would make the error the new baseline. Fixes #119 Co-Authored-By: Claude Opus 5 (1M context) --- HISTORY.asc | 17 ++++++++- README.asc | 6 ++-- README.html | 8 ++--- verify-results-pgtap.sh | 76 ++++++++++++++++++++++++++++++++++++----- 4 files changed, 90 insertions(+), 17 deletions(-) diff --git a/HISTORY.asc b/HISTORY.asc index da32ce4..e2c3f6a 100644 --- a/HISTORY.asc +++ b/HISTORY.asc @@ -1,5 +1,20 @@ STABLE ------ +== Fix `make results` refusing to create a new test's first expected output +`verify-results` blocked `make results` whenever `regression.diffs` existed +at all, which made seeding the first `test/expected/.out` for a +brand-new test impossible: pgxntool creates an empty placeholder for a test +that has no expected file (pg_regress aborts outright on a missing one), so +pg_regress always reports a difference against it no matter how clean the +new test's actual output is. + +`verify-results` now reads what `regression.diffs` actually says. A test +that differs only from that empty placeholder is allowed through, provided +its own pgtap output is clean and contains no SQL error; a test that differs +from a real expected file still blocks `make results` as before. This +applies to the default `PGXNTOOL_VERIFY_RESULTS_MODE=pgtap`; +`PGXNTOOL_VERIFY_RESULTS_MODE=diffs` still blocks on any `regression.diffs`. + == Add `PGXNTOOL_ENABLE_FS_INSTALL` and `PGXNTOOL_ENABLE_PGXN_INSTALL` `test`/`verify-results` unconditionally filesystem-installed the extension (via PGXS's `install`), and `installcheck` unconditionally auto-installed @@ -43,7 +58,7 @@ None of these are documented anywhere as override points, but if you happened to reference one directly (unsupported, but possible), update to the new name. -Issues fixed in this release: #87, #21, #55, #90 +Issues fixed in this release: #87, #21, #55, #90, #119 2.3.0 ----- diff --git a/README.asc b/README.asc index bf48c80..14d63b6 100644 --- a/README.asc +++ b/README.asc @@ -237,8 +237,8 @@ Never run `make results` without first verifying the test changes are correct. T ==== verify-results safeguard By default, `make results` will refuse to run if your tests are failing, so you can't accidentally promote incorrect output into the new expected results. Which failures it looks for is controlled by `PGXNTOOL_VERIFY_RESULTS_MODE`: -`pgtap` (the default):: Scans `test/results/*.out` for pgTAP `not ok` lines (ignoring `# TODO` items) and plan-count mismatches, then also checks `test/results/regression.diffs` for any output mismatch pgTAP itself wouldn't catch. -`diffs`:: Only checks whether `test/results/regression.diffs` exists. +`pgtap` (the default):: Scans `test/results/*.out` for pgTAP `not ok` lines (ignoring `# TODO` items) and plan-count mismatches, then also checks `test/regression.diffs` for any output mismatch pgTAP itself wouldn't catch. A test that has no expected output file yet is the one exception: it always shows up in `regression.diffs` (pgxntool creates an empty expected file for it, because `pg_regress` aborts on a missing one), so `make results` is allowed to create its first expected output — provided its own pgTAP output is clean and free of SQL errors. +`diffs`:: Only checks whether `test/regression.diffs` exists, so it can't create a new test's first expected output; use `pgtap` mode, or `PGXNTOOL_ENABLE_VERIFY_RESULTS=no` for that one run. If tests are failing, `make results` prints an explanation of what failed and exits without touching `test/expected/`; fix the failures, then re-run `make results`. @@ -729,7 +729,7 @@ Default: `pgtap`. Controls how the <<_verify_results_safeguard,verify-results sa ==== pgtap -Scans `test/results/*.out` for pgTap `not ok` lines and plan mismatches, falling back to checking for `regression.diffs` too. Use this mode when your test suite uses pgTap. +Scans `test/results/*.out` for pgTap `not ok` lines and plan mismatches, falling back to checking `regression.diffs` too — except for a test that has no expected output yet, whose first expected file `make results` is allowed to create. Use this mode when your test suite uses pgTap. ==== diffs diff --git a/README.html b/README.html index c3428cd..449e9d9 100644 --- a/README.html +++ b/README.html @@ -1000,11 +1000,11 @@

pgtap (the default)
-

Scans test/results/*.out for pgTAP not ok lines (ignoring # TODO items) and plan-count mismatches, then also checks test/results/regression.diffs for any output mismatch pgTAP itself wouldn’t catch.

+

Scans test/results/*.out for pgTAP not ok lines (ignoring # TODO items) and plan-count mismatches, then also checks test/regression.diffs for any output mismatch pgTAP itself wouldn’t catch. A test that has no expected output file yet is the one exception: it always shows up in regression.diffs (pgxntool creates an empty expected file for it, because pg_regress aborts on a missing one), so make results is allowed to create its first expected output — provided its own pgTAP output is clean and free of SQL errors.

diffs
-

Only checks whether test/results/regression.diffs exists.

+

Only checks whether test/regression.diffs exists, so it can’t create a new test’s first expected output; use pgtap mode, or PGXNTOOL_ENABLE_VERIFY_RESULTS=no for that one run.

@@ -1980,7 +1980,7 @@

8.8.1. pgtap

-

Scans test/results/*.out for pgTap not ok lines and plan mismatches, falling back to checking for regression.diffs too. Use this mode when your test suite uses pgTap.

+

Scans test/results/*.out for pgTap not ok lines and plan mismatches, falling back to checking regression.diffs too — except for a test that has no expected output yet, whose first expected file make results is allowed to create. Use this mode when your test suite uses pgTap.

@@ -2068,7 +2068,7 @@
+

To select a mode explicitly:

@@ -2068,7 +2071,7 @@