Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a184e4d

Browse files
committed
Convert libpq regress script to Perl
This should ease its use on the Windows build environment.
1 parent adb9b7d commit a184e4d

File tree

3 files changed

+63
-22
lines changed

3 files changed

+63
-22
lines changed

src/interfaces/libpq/test/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ all: $(PROGS)
1515

1616
installcheck: all
1717
SRCDIR='$(top_srcdir)' SUBDIR='$(subdir)' \
18-
$(SHELL) $(top_srcdir)/$(subdir)/regress.sh
18+
$(PERL) $(top_srcdir)/$(subdir)/regress.pl
1919

2020
clean distclean maintainer-clean:
2121
rm -f $(PROGS)

src/interfaces/libpq/test/regress.pl

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/perl -w
2+
3+
use strict;
4+
5+
# use of SRCDIR/SUBDIR is required for supporting VPath builds
6+
my $srcdir = $ENV{'SRCDIR'} or die 'SRCDIR environment variable is not set';
7+
my $subdir = $ENV{'SUBDIR'} or die 'SUBDIR environment variable is not set';
8+
9+
my $regress_in = "$srcdir/$subdir/regress.in";
10+
my $expected_out = "$srcdir/$subdir/expected.out";
11+
12+
# the output file should land in the build_dir of VPath, or just in
13+
# the current dir, if VPath isn't used
14+
my $regress_out = "regress.out";
15+
16+
# open input file first, so possible error isn't sent to redirected STDERR
17+
open(REGRESS_IN, "<", $regress_in)
18+
or die "can't open $regress_in for reading: $!";
19+
20+
# save STDOUT/ERR and redirect both to regress.out
21+
open(OLDOUT, ">&", \*STDOUT) or die "can't dup STDOUT: $!";
22+
open(OLDERR, ">&", \*STDERR) or die "can't dup STDERR: $!";
23+
24+
open(STDOUT, ">", $regress_out)
25+
or die "can't open $regress_out for writing: $!";
26+
open(STDERR, ">&", \*STDOUT) or die "can't dup STDOUT: $!";
27+
28+
# read lines from regress.in and run uri-regress on them
29+
while (<REGRESS_IN>)
30+
{
31+
chomp;
32+
print "trying $_\n";
33+
system("./uri-regress \"$_\"");
34+
print "\n";
35+
}
36+
37+
# restore STDOUT/ERR so we can print the outcome to the user
38+
open(STDERR, ">&", \*OLDERR) or die; # can't complain as STDERR is still duped
39+
open(STDOUT, ">&", \*OLDOUT) or die "Can't restore STDOUT: $!";
40+
41+
# just in case
42+
close REGRESS_IN;
43+
44+
my $diff_status = system(
45+
"diff -c \"$srcdir/$subdir/expected.out\" regress.out >regress.diff");
46+
if ($diff_status == 0)
47+
{
48+
print "=" x 70, "\n";
49+
print "All tests passed\n";
50+
exit 0;
51+
}
52+
else
53+
{
54+
print "=" x 70, "\n";
55+
print <<EOF;
56+
FAILED: the test result differs from the expected output
57+
58+
Review the difference in "$subdir/regress.diff"
59+
EOF
60+
print "=" x 70, "\n";
61+
exit 1;
62+
}

src/interfaces/libpq/test/regress.sh

-21
This file was deleted.

0 commit comments

Comments
 (0)