Hello,
We running TAP tests which operates with a lot of instances. And some of
these tests randomly fail due "address already in use". It turned out
that the meson does not set environment variable MESON_BUILD_ROOT when
running the test() function [0]. As a result each test uses its own
"portlock" directory [1]. The small TAP test 001_portlock_env_test.pl
shows the test environment variables. As we can see MESON_BUILD_ROOT is
really undefined.
Can we explicitly set the MESON_BUILD_ROOT environment variable when
running a test? With included patch for the src/tools/testwrap file,
each instance gets an unique TCP port.
Thanks!
Best regards, Roman Zharkov
[0] https://mesonbuild.com/Reference-manual_functions.html#test
[1]
https://github.com/postgres/postgres/blob/7202d72787d3b93b692feae62ee963238580c877/src/test/perl/PostgreSQL/Test/Cluster.pm#L172
diff --git a/src/tools/testwrap b/src/tools/testwrap
index 8ae8fb79ba7..21c489a5beb 100755
--- a/src/tools/testwrap
+++ b/src/tools/testwrap
@@ -39,6 +39,7 @@ os.chdir(args.srcdir)
open(os.path.join(testdir, 'test.start'), 'x')
env_dict = {**os.environ,
+ 'MESON_BUILD_ROOT': args.basedir,
'TESTDATADIR': os.path.join(testdir, 'data'),
'TESTLOGDIR': os.path.join(testdir, 'log')}
use strict;
use warnings FATAL => 'all';
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More;
use Data::Dumper;
diag("ENV:\t" . Dumper(\%ENV));
diag("MESON_BUILD_ROOT:\t" . Dumper($ENV{MESON_BUILD_ROOT}));
diag("top_builddir:\t" . Dumper($ENV{top_builddir}));
ok(1==1, 'dummy test');
done_testing();