Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,9 @@ jobs:
- name: Run tests
run: cargo test --all --no-default-features --features "pg$env:PG_VER pg_test cshim proptest" --all-targets

- name: Test pg_regress_path returns existing executable
run: cargo test --package pgrx-pg-config pg_regress_path_exists -- --ignored

- name: Print sccache stats
run: sccache --show-stats

Expand Down
37 changes: 37 additions & 0 deletions pgrx-pg-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,3 +953,40 @@ fn from_empty_env() -> eyre::Result<()> {
assert!(pg_config.sharedir().is_err());
Ok(())
}

/// Test that pg_regress_path() returns an existing executable for all configured PostgreSQL versions.
///
/// This test is ignored by default because it requires `cargo pgrx init` to have been run.
/// Run with: cargo test --package pgrx-pg-config pg_regress_path_exists -- --ignored --nocapture
///
/// Known issue: On Windows with PostgreSQL 13-16 (EnterpriseDB precompiled binaries),
/// pg_regress.exe is located in /bin/ rather than /lib/pgxs/src/test/regress/.
/// PostgreSQL 17+ (using Meson build system) installs to /lib/pgxs/src/test/regress/.
#[test]
#[ignore]
fn pg_regress_path_exists() -> eyre::Result<()> {
let pgrx = Pgrx::from_config()?;

let mut failures: Vec<String> = Vec::new();

for pg_config_result in pgrx.iter(PgConfigSelector::All) {
let pg_config = pg_config_result?;
let version = pg_config.major_version()?;

let pg_regress_path = pg_config.pg_regress_path()?;
// Add executable suffix for Windows
let pg_regress_exe = pg_regress_path.with_extension(if cfg!(windows) { "exe" } else { "" });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Methods like initdb_path and pg_ctl_path already append the suffix. I suspect pg_regress_path should do the same.


if pg_regress_exe.exists() {
println!("pg{version}: OK - {}", pg_regress_exe.display());
} else {
let msg = format!("pg{version}: MISSING - {}", pg_regress_exe.display());
println!("{msg}");
failures.push(msg);
}
}

assert!(failures.is_empty(), "pg_regress not found:\n{}", failures.join("\n"));

Ok(())
}