Skip to content

pgTAP-aware results validator, tolerant of suffixed/prefixed role names in assertion descriptions #106

Open

Description

@jnasbyupgrade

A pgTAP-aware results validator would let projects run pgTAP against environments where object names vary per run.

Some CI setups run against a single shared database server, so concurrent builds give test-harness role names a per-build prefix or suffix. That changes pgTAP assertion description text (it embeds the role name), so the committed, unsuffixed test/expected/*.out can never byte-match via ordinary pg_regress/verify-results diffing, even when every assertion passes.

Rather than every extension writing its own script to scan test/results/*.out for "not ok" lines, plan-line presence and plan mismatches while ignoring description-text diffs, pgxntool could offer a pgTAP-aware validator as an alternative to base pg_regress diffing: one that understands pgTAP's TAP output (plan lines, ok/not ok, TODO/SKIP directives) well enough to verify correctness independent of description text.

Any extension using pgTAP against a test environment without fixed identities (per-build suffixed role or object names, or similar) would benefit.

Related gaps in the current pass/fail checks

These matter independently of the suffix case, and a validator should cover them.

make test fails only on regression.diffs. The pgTAP scan (verify-results-pgtap.sh) runs only as part of make results, before blessing. A not ok line that has already been blessed into an expected file still passes make test, since the actual output matches it byte for byte.

No plan-line check. The pgTAP verifier looks for not ok lines and for "Looks like you planned" messages, but does not require a 1..N plan line. A failure that stops the run before any not ok line is printed can therefore pass undetected.

test/install/*.sql content cannot fail make test. Output from test/install is never compared against anything, because actual and expected resolve to the same file. Only a hard SQL error with ON_ERROR_STOP set (which pgxntool statically checks for) makes the build fail; a not ok result or any other output difference in those files cannot. A validator should scan those results too.

Not scoped yet. Happy to discuss what the validator's pass/fail contract should look like.

Activity

  1. jnasbyupgrade commented on Oct 12, 2026

    @jnasbyupgrade
    ContributorAuthor

    🤖 (Claude)

    Suggestion: run the test command through a small wrapper that fails on either a non-zero exit status or a failure-looking line in the output. make test alone is not enough, because the pgxntool test target only fails on a non-empty regression.diffs and does not scan pgTAP output.

    The wrapper takes any command (not only make test), captures its combined stdout and stderr, and fails the overall run in two cases:

    1. The command exits non-zero. The wrapper passes the command's own status through unchanged; it does not replace it with 1 or any other value, and no one should force the exit code to 1.
    2. The captured output contains a line matching a failure pattern: not ok, FAILED, Looks like you planned, an N of M tests failed style summary, or the database error current transaction is aborted.

    Both checks are needed. The exit code catches hard failures. The output scan catches TAP-style failures that a command can still exit 0 on.

    Sketch:

    # bash; usage: run-and-scan <command> [args...]
    out=$(mktemp)
    "$@" 2>&1 | tee "$out"
    status=${PIPESTATUS[0]}
    if grep -E -q 'not ok|FAILED|Looks like you planned|[0-9]+ of [0-9]+ tests? failed|current transaction is aborted' "$out"; then
      echo "failure pattern found in output" >&2
      [ "$status" -ne 0 ] || status=1   # only when the command itself exited 0
    fi
    rm -f "$out"
    exit "$status"
  2. added 4 commits that reference this issue on Oct 14, 2026
    15e558b
    09cf607
    7eec927
    9e63c06
  3. jnasbyupgrade commented on Oct 15, 2026

    @jnasbyupgrade
    ContributorAuthor

    🤖 (Claude)

    Update on the motivating case for this issue: we no longer need output that varies per run.

    The case was role names that get a per-build prefix or suffix and show up in pgTAP test descriptions. We removed it by replacing the real names in descriptions with fixed placeholders, so the expected output is byte-identical on every run. A content-tolerant validator is not needed for that case, and we have decided against using one as a general mechanism because it would also hide real changes in diagnostic text.

    What still seems worth pgxntool's attention from this issue, and does not depend on the naming case:

    1. A not ok line that gets accepted into an expected file still passes plain make test. Scanning the raw output for failure markers (not ok, FAILED, current transaction is aborted, and similar) catches this. We do that in a wrapper outside pgxntool.
    2. Nothing requires a 1..N plan line in the result file. A test that dies before planning can look like a pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions