Skip to content

initial support for pg_regress-based tests#2058

Merged
eeeebbbbrrrr merged 10 commits intopgcentralfoundation:developfrom
eeeebbbbrrrr:pg_regress
May 7, 2025
Merged

initial support for pg_regress-based tests#2058
eeeebbbbrrrr merged 10 commits intopgcentralfoundation:developfrom
eeeebbbbrrrr:pg_regress

Conversation

@eeeebbbbrrrr
Copy link
Contributor

This adds a new cargo pgrx regress subcommand that knows how to manage/run sql-based tests compatible with Postgres' pg_regress tool (which this uses).

I'd expect there to be some UX issues here that will need to be addressed in future commits/releases, but this feature needs to start somewhere.

@eeeebbbbrrrr eeeebbbbrrrr requested a review from Copilot May 7, 2025 17:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces initial support for pg_regress-based regression tests by adding a new cargo subcommand along with accompanying templates and configuration changes. Key changes include:

  • New functions in PgConfig for locating pg_regress assets and additional database operations (e.g. dropdb).
  • Updates to the cargo-pgrx commands (start, run, connect, pgrx) to support runtime PostgreSQL configuration and regression testing.
  • Extended documentation in the README and new file templates for regression testing.

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pgrx-pg-config/src/lib.rs Introduces new methods (pg_regress_path and pgxs_path) and updates dropdb output formatting.
pgrx-examples/range/... Adds SQL test scripts and expected outputs for regression tests.
cargo-pgrx/src/command/* Updates commands to accept and pass through runtime PostgreSQL configuration, and adds the new regress subcommand.
cargo-pgrx/src/templates/* Adds new templates for setup_sql and setup_out.
cargo-pgrx/README.md Enhances documentation with detailed regression testing instructions.
Cargo.toml Adds a dependency on "which".

@eeeebbbbrrrr
Copy link
Contributor Author

Worth noting that there's 3 new entries existing extensions will want to add to their .gitignore file if they adopt regression tests.
Screenshot 2025-05-07 at 2 23 25 PM

Our cargo pgrx new ... command will do this for new extensions. I didn't want to teach cargo pgrx upgrade how to do this because many folks are real fussy about how their .gitignore is organized.

accept the output from new tests and also copy over the output from
failed tests to become the new expected output.

other little bugfixes an UI cleanups
@eeeebbbbrrrr
Copy link
Contributor Author

CI is red because I cancelled the jobs.

I'm going to merge this through and then start a new release.

@eeeebbbbrrrr eeeebbbbrrrr merged commit a903aad into pgcentralfoundation:develop May 7, 2025
4 of 15 checks passed
eeeebbbbrrrr added a commit that referenced this pull request May 7, 2025
Welcome to pgrx v0.14.2. This is a minor release that fixes a few bugs
and also adds a big new feature: support for `pg_regress`-based
regression tests.

As always, please update with `cargo install cargo-pgrx --version 0.14.2
--locked` and update your extension `Cargo.toml` files with `cargo pgrx
upgrade`.

For the `pg_regress` regression test support, there's a new `cargo pgrx
regress` subcommand, and it's documented in [cargo-pgrx's
readme](https://github.com/pgcentralfoundation/pgrx/blob/develop/cargo-pgrx/README.md#testing-with-regression-tests).


## What's Changed

* Remove the `$libdir/` prefix from module_pathname by @theory in
#2051

This will help with the upcoming Postgres v18 and generally makes
pgrx-based extensions less restrictive with regard to how they're
installed.

* initial support for `pg_regress`-based tests by @eeeebbbbrrrr in
#2058

(editor's node: I full expect users to uncover UX nits with this and am
more than happy to entertain any ideas that help to improve workflows,
either locally during development or in CI. Feel free to open issues
about it.)

### More Bindings

* Include `pg_statistic_ext` catalog by @ArArgon in
#2053

### Bug Fixes

* check `tgnargs` in `extra_args` by @usamoi in
#2046

### Code Cleanup

* Added absolute path to call `<Self as ::pgrx::datum::FromDatum>::` by
@LucaCappelletti94 in
#2050
* Removed duplicate ok check by @YohDeadfall in
#2044

## New Contributors
* @LucaCappelletti94 made their first contribution in
#2050
* @ArArgon made their first contribution in
#2053

## Thanks

Shoutout to @philippemnoel of @paradedb for paying me to implement the
`pg_regress` support. ❤️

**Full Changelog**:
v0.14.1...v0.14.2
KenjiBrown pushed a commit to SoftwareLibreMx/pgrx that referenced this pull request May 27, 2025
This adds a new `cargo pgrx regress` subcommand that knows how to
manage/run sql-based tests compatible with Postgres' `pg_regress` tool
(which this uses).
KenjiBrown pushed a commit to SoftwareLibreMx/pgrx that referenced this pull request May 27, 2025
Welcome to pgrx v0.14.2. This is a minor release that fixes a few bugs
and also adds a big new feature: support for `pg_regress`-based
regression tests.

As always, please update with `cargo install cargo-pgrx --version 0.14.2
--locked` and update your extension `Cargo.toml` files with `cargo pgrx
upgrade`.

For the `pg_regress` regression test support, there's a new `cargo pgrx
regress` subcommand, and it's documented in [cargo-pgrx's
readme](https://github.com/pgcentralfoundation/pgrx/blob/develop/cargo-pgrx/README.md#testing-with-regression-tests).


## What's Changed

* Remove the `$libdir/` prefix from module_pathname by @theory in
pgcentralfoundation#2051

This will help with the upcoming Postgres v18 and generally makes
pgrx-based extensions less restrictive with regard to how they're
installed.

* initial support for `pg_regress`-based tests by @eeeebbbbrrrr in
pgcentralfoundation#2058

(editor's node: I full expect users to uncover UX nits with this and am
more than happy to entertain any ideas that help to improve workflows,
either locally during development or in CI. Feel free to open issues
about it.)

### More Bindings

* Include `pg_statistic_ext` catalog by @ArArgon in
pgcentralfoundation#2053

### Bug Fixes

* check `tgnargs` in `extra_args` by @usamoi in
pgcentralfoundation#2046

### Code Cleanup

* Added absolute path to call `<Self as ::pgrx::datum::FromDatum>::` by
@LucaCappelletti94 in
pgcentralfoundation#2050
* Removed duplicate ok check by @YohDeadfall in
pgcentralfoundation#2044

## New Contributors
* @LucaCappelletti94 made their first contribution in
pgcentralfoundation#2050
* @ArArgon made their first contribution in
pgcentralfoundation#2053

## Thanks

Shoutout to @philippemnoel of @paradedb for paying me to implement the
`pg_regress` support. ❤️

**Full Changelog**:
pgcentralfoundation/pgrx@v0.14.1...v0.14.2
daamien pushed a commit to daamien/pgrx that referenced this pull request Dec 15, 2025
This adds a new `cargo pgrx regress` subcommand that knows how to
manage/run sql-based tests compatible with Postgres' `pg_regress` tool
(which this uses).
daamien pushed a commit to daamien/pgrx that referenced this pull request Dec 15, 2025
Welcome to pgrx v0.14.2. This is a minor release that fixes a few bugs
and also adds a big new feature: support for `pg_regress`-based
regression tests.

As always, please update with `cargo install cargo-pgrx --version 0.14.2
--locked` and update your extension `Cargo.toml` files with `cargo pgrx
upgrade`.

For the `pg_regress` regression test support, there's a new `cargo pgrx
regress` subcommand, and it's documented in [cargo-pgrx's
readme](https://github.com/pgcentralfoundation/pgrx/blob/develop/cargo-pgrx/README.md#testing-with-regression-tests).


## What's Changed

* Remove the `$libdir/` prefix from module_pathname by @theory in
pgcentralfoundation#2051

This will help with the upcoming Postgres v18 and generally makes
pgrx-based extensions less restrictive with regard to how they're
installed.

* initial support for `pg_regress`-based tests by @eeeebbbbrrrr in
pgcentralfoundation#2058

(editor's node: I full expect users to uncover UX nits with this and am
more than happy to entertain any ideas that help to improve workflows,
either locally during development or in CI. Feel free to open issues
about it.)

### More Bindings

* Include `pg_statistic_ext` catalog by @ArArgon in
pgcentralfoundation#2053

### Bug Fixes

* check `tgnargs` in `extra_args` by @usamoi in
pgcentralfoundation#2046

### Code Cleanup

* Added absolute path to call `<Self as ::pgrx::datum::FromDatum>::` by
@LucaCappelletti94 in
pgcentralfoundation#2050
* Removed duplicate ok check by @YohDeadfall in
pgcentralfoundation#2044

## New Contributors
* @LucaCappelletti94 made their first contribution in
pgcentralfoundation#2050
* @ArArgon made their first contribution in
pgcentralfoundation#2053

## Thanks

Shoutout to @philippemnoel of @paradedb for paying me to implement the
`pg_regress` support. ❤️

**Full Changelog**:
pgcentralfoundation/pgrx@v0.14.1...v0.14.2
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.

2 participants