Skip to content

Commit b06a8e3

Browse files
committed
Improve vcregress.pl's handling of tap tests for client programs
The target is now named 'bincheck' rather than 'tapcheck' so that it reflects what is checked instead of the test mechanism. Some of the logic is improved, making it easier to add further sets of TAP based tests in future. Also, the environment setting logic is imrpoved. As discussed on -hackers a couple of months ago.
1 parent d5bb7c6 commit b06a8e3

File tree

1 file changed

+36
-25
lines changed

1 file changed

+36
-25
lines changed

src/tools/msvc/vcregress.pl

+36-25
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
my $what = shift || "";
3535
if ($what =~
36-
/^(check|installcheck|plcheck|contribcheck|ecpgcheck|isolationcheck|upgradecheck|tapcheck)$/i
36+
/^(check|installcheck|plcheck|contribcheck|ecpgcheck|isolationcheck|upgradecheck|bincheck)$/i
3737
)
3838
{
3939
$what = uc $what;
@@ -60,7 +60,14 @@
6060
$schedule = "parallel" if ($what eq 'CHECK' || $what =~ /PARALLEL/);
6161
}
6262

63-
$ENV{PERL5LIB} = "$topdir/src/tools/msvc;$ENV{PERL5LIB}";
63+
if ($ENV{PERL5LIB})
64+
{
65+
$ENV{PERL5LIB} = "$topdir/src/tools/msvc;$ENV{PERL5LIB}";
66+
}
67+
else
68+
{
69+
$ENV{PERL5LIB} = "$topdir/src/tools/msvc";
70+
}
6471

6572
my $maxconn = "";
6673
$maxconn = "--max_connections=$ENV{MAX_CONNECTIONS}"
@@ -79,7 +86,7 @@
7986
ECPGCHECK => \&ecpgcheck,
8087
CONTRIBCHECK => \&contribcheck,
8188
ISOLATIONCHECK => \&isolationcheck,
82-
TAPCHECK => \&tapcheck,
89+
BINCHECK => \&bincheck,
8390
UPGRADECHECK => \&upgradecheck,);
8491

8592
my $proc = $command{$what};
@@ -165,39 +172,43 @@ sub isolationcheck
165172
exit $status if $status;
166173
}
167174

168-
sub tapcheck
175+
sub tap_check
169176
{
177+
die "Tap tests not enabled in configuration"
178+
unless $config->{tap_tests};
179+
180+
my $dir = shift;
181+
chdir $dir;
182+
170183
my @args = ( "prove", "--verbose", "t/*.pl");
171-
my $mstat = 0;
172184

185+
# adjust the environment for just this test
186+
local %ENV = %ENV;
173187
$ENV{PERL5LIB} = "$topdir/src/test/perl;$ENV{PERL5LIB}";
174188
$ENV{PG_REGRESS} = "$topdir/$Config/pg_regress/pg_regress";
175189

190+
$ENV{TESTDIR} = "$dir";
191+
192+
system(@args);
193+
my $status = $? >> 8;
194+
return $status;
195+
}
196+
197+
sub bincheck
198+
{
199+
InstallTemp();
200+
201+
my $mstat = 0;
202+
176203
# Find out all the existing TAP tests by looking for t/ directories
177204
# in the tree.
178-
my $tap_dirs = [];
179-
my @top_dir = ($topdir);
180-
File::Find::find(
181-
{ wanted => sub {
182-
/^t\z/s
183-
&& push(@$tap_dirs, $File::Find::name);
184-
}
185-
},
186-
@top_dir);
205+
my @bin_dirs = glob("$topdir/src/bin/*");
187206

188207
# Process each test
189-
foreach my $test_path (@$tap_dirs)
208+
foreach my $dir (@$bin_dirs)
190209
{
191-
my $dir = dirname($test_path);
192-
my $tmp_root = "$dir/tmp_check";
193-
(mkdir $tmp_root || die $!) unless -d $tmp_root;
194-
my $tmp_install = "$tmp_root/install";
195-
Install($tmp_install, "all", $config);
196-
chdir $dir;
197-
# Reset those values, they may have been changed by another test.
198-
$ENV{TESTDIR} = "$dir";
199-
system(@args);
200-
my $status = $? >> 8;
210+
next unless -d "$dir/t";
211+
my $status = tap_check($dir);
201212
$mstat ||= $status;
202213
}
203214
exit $mstat if $mstat;

0 commit comments

Comments
 (0)