Re: libpq URI and regression testing - Mailing list pgsql-hackers
From | Alex |
---|---|
Subject | Re: libpq URI and regression testing |
Date | |
Msg-id | 87r4vj7ahe.fsf@commandprompt.com Whole thread Raw |
In response to | Re: libpq URI and regression testing (Peter Eisentraut <peter_e@gmx.net>) |
Responses |
Re: libpq URI and regression testing
|
List | pgsql-hackers |
Peter Eisentraut <peter_e@gmx.net> writes: > On tor, 2012-04-19 at 00:13 +0300, Alex wrote: >> +#!/usr/bin/env perl > > Don't do that. Call the script using $(PERL) from the makefile. Thank you for the suggestion. Attached v2 does just this (while keeping a more commonly found shebang line in the perl script for running it w/o the makefile.) I figure src/tools/msvc/vcregress.pl will need to be updated too, but trying to model all this after ecpg regression tests I'm stuck at replicating ecpg_regression.proj for libpq's uri-regress. I'd appreciate any help from the Windows guys at this point. -- Alex diff --git a/src/interfaces/libpq/test/Makefile b/src/interfaces/libpq/test/Makefile index b9023c3..048f092 100644 --- a/src/interfaces/libpq/test/Makefile +++ b/src/interfaces/libpq/test/Makefile @@ -15,7 +15,7 @@ all: $(PROGS) installcheck: all SRCDIR='$(top_srcdir)' SUBDIR='$(subdir)' \ - $(SHELL) $(top_srcdir)/$(subdir)/regress.sh + $(PERL) $(top_srcdir)/$(subdir)/regress.pl clean distclean maintainer-clean: rm -f $(PROGS) diff --git a/src/interfaces/libpq/test/regress.pl b/src/interfaces/libpq/test/regress.pl new file mode 100755 index 0000000..a19f793 --- /dev/null +++ b/src/interfaces/libpq/test/regress.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl +use strict; + +# use of SRCDIR/SUBDIR is required for supporting VPath builds +my $srcdir = $ENV{'SRCDIR'} or die '$SRCDIR environment variable is not set'; +my $subdir = $ENV{'SUBDIR'} or die '$SUBDIR environment variable is not set'; + +my $regress_in = "$srcdir/$subdir/regress.in"; +my $expected_out = "$srcdir/$subdir/expected.out"; + +# the output file should land in the build_dir of VPath, or just in +# the current dir, if VPath isn't used +my $regress_out = "regress.out"; + +# open input file first, so possible error isn't sent to redirected STDERR +open(REGRESS_IN, "<$regress_in") or die "Can't open <$regress_in: $!"; + +# save STDOUT/ERR and redirect both to regress.out +open(OLDOUT, ">&STDOUT") or die "Can't dup STDOUT: $!"; +open(OLDERR, ">&STDERR") or die "Can't dup STDERR: $!"; + +open(STDOUT, ">$regress_out") or die "Can't open >$regress_out: $!"; +open(STDERR, ">&STDOUT") or die "Can't dup STDOUT: $!"; + +# read lines from regress.in and run uri-regress on them +while (<REGRESS_IN>) { + chomp; + print "trying $_\n"; + system("./uri-regress \"$_\""); + print "\n"; +} + +# restore STDOUT/ERR so we can print the outcome to the user +open(STDERR, ">&OLDERR") or die; # can't complain as STDERR is still duped +open(STDOUT, ">&OLDOUT") or die "Can't restore STDOUT: $!"; + +# just in case +close REGRESS_IN; + +my $diff_status = system("diff -c \"$srcdir/$subdir/expected.out\" regress.out >regress.diff"); +if ($diff_status == 0) { + print <<EOF; +====================================================================== +All tests passed +EOF + exit 0; +} else { + print <<EOF; +====================================================================== +FAILED: the test result differs from the expected output + +Review the difference in "$subdir/regress.diff" +====================================================================== +EOF + exit 1; +} diff --git a/src/interfaces/libpq/test/regress.sh b/src/interfaces/libpq/test/regress.sh deleted file mode 100644 index 298d8bd..0000000 --- a/src/interfaces/libpq/test/regress.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -while read line -do - echo "trying $line" - ./uri-regress "$line" - echo "" -done < "${SRCDIR}/${SUBDIR}"/regress.in >regress.out 2>&1 - -if diff -c "${SRCDIR}/${SUBDIR}/"expected.out regress.out >regress.diff; then - echo "========================================" - echo "All tests passed" - exit 0 -else - echo "========================================" - echo "FAILED: the test result differs from the expected output" - echo - echo "Review the difference in ${SUBDIR}/regress.diff" - echo "========================================" - exit 1 -fi diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index f0fad43..e65971c 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -229,6 +229,15 @@ sub mkvcbuild $libpq->ReplaceFile('src\interfaces\libpq\libpqrc.c','src\interfaces\libpq\libpq.rc'); $libpq->AddReference($libpgport); + my $libpq_uri_regress = $solution->AddProject('libpq_uri_regress','exe','misc'); + $libpq_uri_regress->AddFile('src\interfaces\libpq\test\uri-regress.c'); + $libpq_uri_regress->AddIncludeDir('src\port'); + $libpq_uri_regress->AddIncludeDir('src\interfaces\libpq'); + $libpq_uri_regress->AddLibrary('wsock32.lib'); + $libpq_uri_regress->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); + $libpq_uri_regress->AddDefine('FRONTEND'); + $libpq_uri_regress->AddReference($libpq,$libpgport); + my $libpqwalreceiver = $solution->AddProject('libpqwalreceiver', 'dll', '', 'src\backend\replication\libpqwalreceiver'); $libpqwalreceiver->AddIncludeDir('src\interfaces\libpq');
pgsql-hackers by date: