You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix test/install to use schedule files; add test-build, verify-results, docs
Replace broken separate-invocation test-install with schedule-based approach:
install files now run in the same pg_regress invocation as regular tests via
an auto-generated schedule file with ../install/ relative paths. State created
by install files persists into the main test suite.
- Add `test-build` feature for pre-test SQL validation via `test/build/`
- Add `verify-results` safeguard preventing `make results` when tests fail
- Add `.asc` to recognized asciidoc extensions
- Document test-build, test/install, and verify-results in README
- Update `_.gitignore` for auto-generated `test/install/schedule`
- Remove `.claude/` directory (moved to pgxntool-test)
Related changes in pgxntool-test:
- Add install persistence test validating state survives across test phases
- Rework `test-test-install.bats` for schedule-based approach
- Add template marker files for install persistence validation
Co-Authored-By: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: HISTORY.asc
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,14 @@
1
1
1.0.0
2
2
-----
3
+
== Add test-build for pre-test validation
4
+
New optional feature validates extension SQL syntax before running the full test suite. Place SQL files in `test/build/` to catch syntax errors early with better error messages than `CREATE EXTENSION` failures. Auto-detects based on file presence.
5
+
6
+
== Add test/install for one-time test setup
7
+
New optional feature runs `test/install/` SQL files before the main test suite via a schedule file, all within a single `pg_regress` invocation. State created by install files (tables, extensions, etc.) persists into regular tests. Auto-detects based on file presence.
8
+
9
+
== Add verify-results safeguard for make results
10
+
`make results` now refuses to run when tests are failing (detected via `regression.diffs`). Prevents accidentally updating expected files with incorrect output. Enabled by default; disable with `PGXNTOOL_ENABLE_VERIFY_RESULTS=no`.
11
+
3
12
== Fix broken multi-extension support
4
13
Prior to this fix, distributions with multiple extensions or extensions with versions different from the PGXN distribution version were completely broken. Extension versions are now correctly read from each `.control` file's `default_version` instead of using META.json's distribution version.
Copy file name to clipboardExpand all lines: README.asc
+132-1Lines changed: 132 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,6 +47,119 @@ Runs unit tests via the PGXS `installcheck` target. Unlike a simple `make instal
47
47
48
48
NOTE: While you can still run `make installcheck` or any other valid PGXS make target directly, it's recommended to use `make test` when using pgxntool. The `test` target ensures clean builds, proper test isolation, and correct dependency installation.
49
49
50
+
=== test-build
51
+
Validates that extension SQL files are syntactically correct before running the full test suite. This feature runs SQL files from `test/build/` through `pg_regress`, providing better error messages than `CREATE EXTENSION` failures when there are syntax errors in your extension code.
52
+
53
+
**How it works:**
54
+
55
+
1. Place SQL files in `test/build/*.sql` (or `test/build/input/*.source` for source-processed files)
56
+
2. Place expected output in `test/build/expected/*.out`
57
+
3. These files run through `pg_regress` before `make test` runs the main test suite
58
+
4. If any build test fails, the test run stops immediately with clear error messages
59
+
60
+
**Directory structure:**
61
+
62
+
----
63
+
test/build/
64
+
├── *.sql # SQL test files (checked in)
65
+
├── input/ # Optional: .source files for pg_regress processing
└── *.sql # Copied from *.sql above; generated from input/*.source
71
+
----
72
+
73
+
The `sql/` subdirectory is generated automatically by `make test-build`. It is listed in `.gitignore` and removed by `make clean`. Do not place files directly in `test/build/sql/`.
74
+
75
+
**Configuration:**
76
+
77
+
The feature auto-detects based on whether `test/build/*.sql` or `test/build/input/*.source` files exist:
78
+
79
+
- Files present → feature enabled automatically
80
+
- No files → feature disabled (no impact on existing projects)
81
+
82
+
You can override auto-detection by setting `PGXNTOOL_ENABLE_TEST_BUILD`:
83
+
----
84
+
# In your Makefile
85
+
PGXNTOOL_ENABLE_TEST_BUILD = yes # or no
86
+
----
87
+
88
+
**Example: Validate extension SQL compiles**
89
+
90
+
Create `test/build/build.sql` to run your extension's SQL directly:
91
+
92
+
----
93
+
\set ECHO none
94
+
\i test/pgxntool/psql.sql
95
+
\t
96
+
97
+
BEGIN;
98
+
SET client_min_messages = WARNING;
99
+
100
+
-- Install dependencies your extension requires
101
+
CREATE EXTENSION IF NOT EXISTS pgtap CASCADE;
102
+
CREATE EXTENSION IF NOT EXISTS some_dependency CASCADE;
103
+
104
+
-- Clean slate
105
+
DROP EXTENSION IF EXISTS myext;
106
+
DROP SCHEMA IF EXISTS myext;
107
+
CREATE SCHEMA myext;
108
+
109
+
-- Run the actual extension SQL (not CREATE EXTENSION)
110
+
\i sql/myext.sql
111
+
112
+
\echo # BUILD TEST SUCCEEDED
113
+
ROLLBACK;
114
+
----
115
+
116
+
This approach catches SQL syntax errors *before* running `CREATE EXTENSION`, giving clearer error messages with line numbers. The `ROLLBACK` ensures nothing persists—this is purely validation.
117
+
118
+
**Why use `\i` instead of `CREATE EXTENSION`?**
119
+
120
+
When `CREATE EXTENSION` fails, PostgreSQL shows only "syntax error" with limited context. Running the SQL directly via `\i` shows the exact line and position of errors, making debugging much faster.
121
+
122
+
=== test/install
123
+
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.
124
+
125
+
**How it works:**
126
+
127
+
1. Place SQL files in `test/install/*.sql`
128
+
2. Place expected output alongside as `test/install/*.out`
129
+
3. A schedule file is auto-generated that lists install files with `../install/` relative paths
130
+
4. `pg_regress` processes the install schedule first, then runs regular test files — all in one invocation, so database state persists
131
+
132
+
**Directory structure:**
133
+
134
+
----
135
+
test/install/
136
+
├── *.sql # SQL setup files (checked in)
137
+
├── *.out # Expected output (checked in, alongside .sql)
The `schedule` file is generated automatically and listed in `.gitignore`. Do not edit it.
143
+
144
+
**Configuration:**
145
+
146
+
The feature auto-detects based on whether `test/install/*.sql` files exist:
147
+
148
+
- Files present → feature enabled automatically
149
+
- No files → feature disabled (no impact on existing projects)
150
+
151
+
You can override auto-detection by setting `PGXNTOOL_ENABLE_TEST_INSTALL`:
152
+
----
153
+
# In your Makefile
154
+
PGXNTOOL_ENABLE_TEST_INSTALL = yes # or no
155
+
----
156
+
157
+
**Why this is useful:**
158
+
159
+
Without `test/install`, each test file typically needs to run `CREATE EXTENSION` in its setup, which adds overhead and doesn't allow validating the installation step separately. With `test/install`, setup runs once before all tests, and any state it creates (tables, extensions, etc.) is available to every subsequent test file.
160
+
161
+
**Key detail:** Install files and regular tests run in a single `pg_regress` invocation. This means the database is NOT dropped between install and test phases — state created by install files persists into the main test suite.
162
+
50
163
=== testdeps
51
164
This rule allows you to ensure certain actions have taken place before running tests. By default it has a single prerequisite, `pgtap`, which will attempt to install http://pgtap.org[pgtap] from PGXN. This depneds on having the pgxn client installed.
52
165
@@ -78,6 +191,24 @@ IMPORTANT: *`make results` requires manual verification first*. The correct work
78
191
79
192
Never run `make results` without first verifying the test changes are correct. The `results` target copies files from `test/results/` to `test/expected/`, so running it blindly will make incorrect output become the new expected behavior.
80
193
194
+
==== verify-results safeguard
195
+
By default, `make results` will refuse to run if `test/results/regression.diffs` exists (indicating failing tests). This prevents accidentally updating expected files with incorrect output.
196
+
197
+
If tests are failing, you'll see:
198
+
----
199
+
ERROR: Tests are failing. Cannot run 'make results'.
200
+
Fix test failures first, then run 'make results'.
201
+
----
202
+
203
+
To disable this safeguard (not recommended):
204
+
----
205
+
# In your Makefile
206
+
PGXNTOOL_ENABLE_VERIFY_RESULTS = no
207
+
208
+
# Or on the command line
209
+
make PGXNTOOL_ENABLE_VERIFY_RESULTS=no results
210
+
----
211
+
81
212
=== tag
82
213
`make tag` will create a git branch for the current version of your extension, as determined by the META.json file. The reason to do this is so you can always refer to the exact code that went into a released version.
83
214
@@ -223,7 +354,7 @@ Location of `asciidoc` or equivalent executable.
223
354
If not set PGXNtool will search for first `asciidoctor`, then `asciidoc`.
224
355
ASCIIDOC_EXTS::
225
356
File extensions to consider as Asciidoc.
226
-
Defined as `+= adoc asciidoc`.
357
+
Defined as `+= adoc asciidoc asc`.
227
358
ASCIIDOC_FILES::
228
359
Asciidoc input files.
229
360
PGXNtool searches each `$(DOC_DIRS)` directory, looking for files with any `$(ASCIIDOC_EXTS)` extension.
0 commit comments