Skip to content

Phase 2: TEST_SCHEMA switching in test/install + schema-invariant assertions - #28

Open
jnasbyupgrade wants to merge 1 commit into
phase1-test-installfrom
phase2-schema-switching
Open

Phase 2: TEST_SCHEMA switching in test/install + schema-invariant assertions#28
jnasbyupgrade wants to merge 1 commit into
phase1-test-installfrom
phase2-schema-switching

Conversation

@jnasbyupgrade

Copy link
Copy Markdown
Contributor

Stacked on #27 (phase 1: test/install adoption). Adds the schema-targeting axis that #27 deliberately deferred.

What changed

  • `test/install/load.sql` reads a new `count_nulls.test_schema` GUC (`TEST_SCHEMA` make var, same PGOPTIONS-propagation mechanism as before) to decide whether to `CREATE SCHEMA`/`SET search_path` before installing. Empty (default): no targeting at all. Non-empty: explicit target, including a name requiring SQL identifier quoting (`TEST_SCHEMA=Quoted`).
  • `test/core/functions.sql`'s pgTAP assertions now pass an explicit, schema-free description to every call, instead of letting pgTAP's own auto-generated descriptions (which embed the real schema via `%I`) through. The SQL actually executed still goes through `ncs()` and is always correct regardless of where count_nulls landed - only the visible description text stops varying.
  • Result: `test/expected/extension_tests.out` stays a single file both the empty and `Quoted` `TEST_SCHEMA` legs pass against. Verified directly: diffed a real `TEST_SCHEMA=Quoted` run against the empty-schema baseline - identical except one line.
  • That one line is a genuine, correct behavioral difference, not an artifact: `test__shutdown__drop_all` drops the schema `TEST_SCHEMA` created, which only exists to drop when `TEST_SCHEMA` is non-empty. Handled via `pg_regress`'s native numbered-alternate mechanism - `test/expected/extension_tests_1.out`, captured from a real run (never hand-authored) - documented in `test/README.md`.
  • Crossed the `test` CI job with `TEST_SCHEMA={"", Quoted}`.

Why this matters for what's next

This is the piece that makes crossing update/upgrade testing WITH schema scenarios (a later phase) free - no additional expected-output files needed there either, since the invariance holds regardless of how count_nulls got installed, not just for a fresh install.

Verification

`make verify-results` passes for both the default and `TEST_SCHEMA=Quoted` legs against this container's live PG17.

…ertions

test/install/load.sql now reads the count_nulls.test_schema GUC (set via
the Makefile's TEST_SCHEMA var, same PGOPTIONS-propagation mechanism as
before) to decide whether to CREATE SCHEMA/SET search_path before
installing - empty means no targeting at all, non-empty explicitly targets
that schema, matching TEST_SCHEMA=Quoted locally.

The harder part: test/core/functions.sql's pgTAP assertions build the SQL
they execute via %I-qualification through ncs() (always correct regardless
of where count_nulls actually landed), but now pass an EXPLICIT, schema-free
description to every call, overriding pgTAP's own auto-generated
descriptions (which embed the schema). This keeps
test/expected/extension_tests.out a single file both the empty and Quoted
TEST_SCHEMA legs pass against, instead of needing one file per schema
value - confirmed by diffing a real Quoted run against the empty-schema
baseline: identical except one line.

That one line is a genuine, unavoidable exception, not an artifact:
test__shutdown__drop_all drops the schema TEST_SCHEMA created, which is
real, different, correct behavior between "there's a schema to clean up"
and "there isn't" (nothing to drop when TEST_SCHEMA is empty). Handled via
pg_regress's native numbered-alternate mechanism -
test/expected/extension_tests_1.out, captured from a real
TEST_SCHEMA=Quoted run - documented in test/README.md's scenario writeup.

Crossed the `test` CI job with TEST_SCHEMA={"", Quoted}.

Verified: make verify-results passes for both the default and
TEST_SCHEMA=Quoted legs against PG17.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 1, 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: Pro Plus

Run ID: 5bd1abb4-d906-482c-a98e-bfbae2495635

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.

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