From aa125cdba98e23f2414933eb910d661f793b2a4d Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 8 Jan 2026 22:09:24 -0800 Subject: [PATCH] Add test for pg_regress_path() returning existing executable (#2237) This test verifies that pg_regress_path() returns a path to an existing pg_regress executable for all configured PostgreSQL versions. Currently fails on Windows with PostgreSQL 13-16 because EnterpriseDB precompiled binaries place pg_regress in /bin/ rather than /lib/pgxs/src/test/regress/. PostgreSQL 17+ uses Meson which installs to /lib/pgxs/src/test/regress/. This commit adds: - Test in pgrx-pg-config that checks all configured PG versions - CI step to run this test on Windows after cargo pgrx init --- .github/workflows/tests.yml | 3 +++ pgrx-pg-config/src/lib.rs | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4284cd55e9..d4bb290b1f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/pgrx-pg-config/src/lib.rs b/pgrx-pg-config/src/lib.rs index 1f09f7b2d2..46cb6abd73 100644 --- a/pgrx-pg-config/src/lib.rs +++ b/pgrx-pg-config/src/lib.rs @@ -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 = 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 { "" }); + + 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(()) +}