Make test portlock logic work with meson
authorAndres Freund <[email protected]>
Fri, 21 Feb 2025 16:16:57 +0000 (11:16 -0500)
committerAndres Freund <[email protected]>
Fri, 21 Feb 2025 16:26:33 +0000 (11:26 -0500)
Previously the portlock logic, added in 9b4eafcaf41, didn't actually work
properly when the tests were run via meson. 9b4eafcaf41 used the
MESON_BUILD_ROOT environment variable to determine the directory for the port
lock directory, but that's never set for running the tests.  That meant that
each test used its own portlock dir, unless the PG_TEST_PORT_DIR environment
variable was set.

Fix the problem by setting top_builddir for the environment. That's also used
for the autoconf/make build.

Backpatch back to 16, where meson support was added.

Reported-by: Zharkov Roman <[email protected]>
Reviewed-by: Andrew Dunstan <[email protected]>
Backpatch-through: 16

meson.build
src/test/perl/PostgreSQL/Test/Cluster.pm

index be532d1cc7909fb32bf0d881a151da658659af09..2a6e45b79a7ee7205e6136cb8b63eeff27c98852 100644 (file)
@@ -3247,6 +3247,8 @@ test_env = environment()
 test_initdb_template = meson.build_root() / 'tmp_install' / 'initdb-template'
 test_env.set('PG_REGRESS', pg_regress.full_path())
 test_env.set('REGRESS_SHLIB', regress_module.full_path())
+# for Cluster.pm's portlock logic
+test_env.set('top_builddir', meson.build_root())
 
 # Test suites that are not safe by default but can be run if selected
 # by the user via the whitespace-separated list in variable PG_TEST_EXTRA.
index 9c210682c798ff630f40c94a1c0c6f671cb34ca1..6cd32adbf7412d2047cebfa6557032b4c2d08ab0 100644 (file)
@@ -169,9 +169,7 @@ INIT
    $portdir = $ENV{PG_TEST_PORT_DIR};
    # Otherwise, try to use a directory at the top of the build tree
    # or as a last resort use the tmp_check directory
-   my $build_dir =
-        $ENV{MESON_BUILD_ROOT}
-     || $ENV{top_builddir}
+   my $build_dir = $ENV{top_builddir}
      || $PostgreSQL::Test::Utils::tmp_check;
    $portdir ||= "$build_dir/portlock";
    $portdir =~ s!\\!/!g;