Re: set TESTDIR from perl rather than Makefile

From: Andres Freund <andres(at)anarazel(dot)de>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>
Subject: Re: set TESTDIR from perl rather than Makefile
Date: 2022-02-21 00:39:08
Message-ID: 20220221003908.lw33x7zmsxk5wm2z@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2022-02-19 17:53:09 -0600, Justin Pryzby wrote:
> I also meant to also attach it.

Is the patch actually independent of the other patches in your stack?

I like this concept a lot:

- I've had to use a wrapper around individual tap tests for meson, just to set
the CWD etc.
- Being able to run all tap tests at once, instead of many separate prove
invocations is a lot more readable. And can be faster.
- makes it easier to invoke tap tests "manually", which can be useful when
debugging problems (not fun to run make in valgrind or rr)
- I'd like to put test data and test log files in different places than they
are eventually. This seems like it gets us a tiny bit closer to that.

> - $expected = slurp_file_eval("traces/$testname.trace");
> + my $inputdir = "$ENV{'TESTDIR'}/tmp_check";
> + $expected = slurp_file_eval("$inputdir/traces/$testname.trace");

Why is this needed? Shouldn't we end up in exactly the same dir with/without
this patch?

> diff --git a/src/test/perl/PostgreSQL/Test/Utils.pm b/src/test/perl/PostgreSQL/Test/Utils.pm
> index 31e2b0315e..8a8d95ca8c 100644
> --- a/src/test/perl/PostgreSQL/Test/Utils.pm
> +++ b/src/test/perl/PostgreSQL/Test/Utils.pm
> @@ -184,19 +184,21 @@ INIT
> # test may still fail, but it's more likely to report useful facts.
> $SIG{PIPE} = 'IGNORE';
>
> - # Determine output directories, and create them. The base path is the
> - # TESTDIR environment variable, which is normally set by the invoking
> - # Makefile.
> - $tmp_check = $ENV{TESTDIR} ? "$ENV{TESTDIR}/tmp_check" : "tmp_check";
> + my $test_dir = File::Spec->rel2abs(dirname($0));
> + my $test_name = basename($0);
> + $test_name =~ s/\.[^.]+$//;
> +
> + # Determine output directories, and create them.
> + # TODO: set srcdir?
> + $tmp_check = "$test_dir/tmp_check";
> $log_path = "$tmp_check/log";
> + $ENV{TESTDIR} = $test_dir;
>
> mkdir $tmp_check;
> mkdir $log_path;
>
> # Open the test log file, whose name depends on the test name.
> - $test_logfile = basename($0);
> - $test_logfile =~ s/\.[^.]+$//;
> - $test_logfile = "$log_path/regress_log_$test_logfile";
> + $test_logfile = "$log_path/regress_log_$test_name";
> open my $testlog, '>', $test_logfile
> or die "could not open STDOUT to logfile \"$test_logfile\": $!";
>
> diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
> index e2b0db0879..63085506e0 100644
> --- a/src/tools/msvc/vcregress.pl
> +++ b/src/tools/msvc/vcregress.pl
> @@ -261,10 +261,8 @@ sub tap_check
> $ENV{PG_REGRESS} = "$topdir/$Config/pg_regress/pg_regress";
> $ENV{REGRESS_SHLIB} = "$topdir/src/test/regress/regress.dll";
>
> - $ENV{TESTDIR} = "$dir";
> my $module = basename $dir;
> - # add the module build dir as the second element in the PATH
> - $ENV{PATH} =~ s!;!;$topdir/$Config/$module;!;
> + #$ENV{VCREGRESS_MODE} = $Config;

Hm. How does the module build dir end up on PATH after this?

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Corey Huinker 2022-02-21 00:53:47 Re: WIP: System Versioned Temporal Table
Previous Message osumi.takamichi@fujitsu.com 2022-02-21 00:25:22 RE: Optionally automatically disable logical replication subscriptions on error