Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7d0f493

Browse files
committed
Add TAP tests for client programs
Reviewed-by: Pavel Stěhule <[email protected]> Reviewed-by: Erik Rijkers <[email protected]>
1 parent 7b5a9d6 commit 7d0f493

39 files changed

+745
-3
lines changed

GNUmakefile.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ check check-tests: all
6666
check check-tests installcheck installcheck-parallel installcheck-tests:
6767
$(MAKE) -C src/test/regress $@
6868

69-
$(call recurse,check-world,src/test src/pl src/interfaces/ecpg contrib,check)
69+
$(call recurse,check-world,src/test src/pl src/interfaces/ecpg contrib src/bin,check)
7070

71-
$(call recurse,installcheck-world,src/test src/pl src/interfaces/ecpg contrib,installcheck)
71+
$(call recurse,installcheck-world,src/test src/pl src/interfaces/ecpg contrib src/bin,installcheck)
7272

7373
GNUmakefile: GNUmakefile.in $(top_builddir)/config.status
7474
./config.status $@

configure

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ ac_includes_default="\
627627

628628
ac_subst_vars='LTLIBOBJS
629629
vpath_build
630+
PROVE
630631
OSX
631632
XSLTPROC
632633
COLLATEINDEX
@@ -14350,6 +14351,52 @@ fi
1435014351
done
1435114352

1435214353

14354+
#
14355+
# Check for test tools
14356+
#
14357+
for ac_prog in prove
14358+
do
14359+
# Extract the first word of "$ac_prog", so it can be a program name with args.
14360+
set dummy $ac_prog; ac_word=$2
14361+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
14362+
$as_echo_n "checking for $ac_word... " >&6; }
14363+
if ${ac_cv_prog_PROVE+:} false; then :
14364+
$as_echo_n "(cached) " >&6
14365+
else
14366+
if test -n "$PROVE"; then
14367+
ac_cv_prog_PROVE="$PROVE" # Let the user override the test.
14368+
else
14369+
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
14370+
for as_dir in $PATH
14371+
do
14372+
IFS=$as_save_IFS
14373+
test -z "$as_dir" && as_dir=.
14374+
for ac_exec_ext in '' $ac_executable_extensions; do
14375+
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
14376+
ac_cv_prog_PROVE="$ac_prog"
14377+
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
14378+
break 2
14379+
fi
14380+
done
14381+
done
14382+
IFS=$as_save_IFS
14383+
14384+
fi
14385+
fi
14386+
PROVE=$ac_cv_prog_PROVE
14387+
if test -n "$PROVE"; then
14388+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PROVE" >&5
14389+
$as_echo "$PROVE" >&6; }
14390+
else
14391+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14392+
$as_echo "no" >&6; }
14393+
fi
14394+
14395+
14396+
test -n "$PROVE" && break
14397+
done
14398+
14399+
1435314400
# Thread testing
1435414401

1435514402
# We have to run the thread test near the end so we have all our symbols

configure.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,11 @@ PGAC_PATH_COLLATEINDEX
18171817
AC_CHECK_PROGS(XSLTPROC, xsltproc)
18181818
AC_CHECK_PROGS(OSX, [osx sgml2xml sx])
18191819

1820+
#
1821+
# Check for test tools
1822+
#
1823+
AC_CHECK_PROGS(PROVE, prove)
1824+
18201825
# Thread testing
18211826

18221827
# We have to run the thread test near the end so we have all our symbols

doc/src/sgml/installation.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ su - postgres
333333
<application>Perl</> 5.8 or later is needed to build from a Git checkout,
334334
or if you changed the input files for any of the build steps that
335335
use Perl scripts. If building on Windows you will need
336-
<application>Perl</> in any case.
336+
<application>Perl</> in any case. <application>Perl</application> is
337+
also required to run some test suites.
337338
</para>
338339
</listitem>
339340
</itemizedlist>

doc/src/sgml/regress.sgml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ make installcheck-world
204204
located in <filename>src/test/isolation</>.
205205
</para>
206206
</listitem>
207+
<listitem>
208+
<para>
209+
Tests of client programs under <filename>src/bin</filename>. See
210+
also <xref linkend="regress-tap">.
211+
</para>
212+
</listitem>
207213
</itemizedlist>
208214

209215
<para>
@@ -660,6 +666,28 @@ float8:out:i.86-.*-openbsd=float8-small-is-zero.out
660666

661667
</sect1>
662668

669+
<sect1 id="regress-tap">
670+
<title>TAP Tests</title>
671+
672+
<para>
673+
The client program tests under <filename>src/bin</filename> use the Perl
674+
TAP tools and are run by <command>prove</command>. You can pass
675+
command-line options to <command>prove</command> by setting
676+
the <command>make</command> variable <varname>PROVE_FLAGS</>, for example:
677+
<programlisting>
678+
make -C src/bin check PROVE_FLAGS='--reverse'
679+
</programlisting>
680+
The default is <literal>--verbose</literal>. See the manual page
681+
of <command>prove</command> for more information.
682+
</para>
683+
684+
<para>
685+
The tests written in Perl require the Perl
686+
module <literal>IPC::Run</literal>, otherwise most tests will be skipped.
687+
This module is available from CPAN or an operating system package.
688+
</para>
689+
</sect1>
690+
663691
<sect1 id="regress-coverage">
664692
<title>Test Coverage Examination</title>
665693

src/Makefile.global.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,22 @@ XGETTEXT = @XGETTEXT@
292292
GZIP = gzip
293293
BZIP2 = bzip2
294294

295+
# Testing
296+
297+
PROVE = @PROVE@
298+
PG_PROVE_FLAGS = --ext='.pl' -I $(top_srcdir)/src/test/perl/
299+
PROVE_FLAGS = --verbose
300+
301+
define prove_installcheck
302+
PATH="$(bindir):$$PATH" PGPORT='6$(DEF_PGPORT)' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS)
303+
endef
304+
305+
define prove_check
306+
$(MKDIR_P) tmp_check/log
307+
$(MAKE) -C $(top_builddir) DESTDIR=$(CURDIR)/tmp_check/install install >$(CURDIR)/tmp_check/log/install.log 2>&1
308+
PATH="$(CURDIR)/tmp_check/install$(bindir):$$PATH" PGPORT='6$(DEF_PGPORT)' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS)
309+
endef
310+
295311
# Installation.
296312

297313
install_bin = @install_bin@

src/bin/initdb/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
/localtime.c
33

44
/initdb
5+
6+
/tmp_check/

src/bin/initdb/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,10 @@ clean distclean maintainer-clean:
5757

5858
# ensure that changes in datadir propagate into object file
5959
initdb.o: initdb.c $(top_builddir)/src/Makefile.global
60+
61+
62+
check: all
63+
$(prove_check)
64+
65+
installcheck:
66+
$(prove_installcheck)

src/bin/initdb/t/001_initdb.pl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use strict;
2+
use warnings;
3+
use TestLib;
4+
use Test::More tests => 14;
5+
6+
my $tempdir = TestLib::tempdir;
7+
8+
program_help_ok('initdb');
9+
program_version_ok('initdb');
10+
program_options_handling_ok('initdb');
11+
12+
command_ok(['initdb', "$tempdir/data"], 'basic initdb');
13+
command_fails(['initdb', "$tempdir/data"], 'existing data directory');
14+
command_ok(['initdb', '-N', "$tempdir/data2"], 'nosync');
15+
command_ok(['initdb', '-S', "$tempdir/data2"], 'sync only');
16+
command_fails(['initdb', '-S', "$tempdir/data3"], 'sync missing data directory');
17+
mkdir "$tempdir/data4" or BAIL_OUT($!);
18+
command_ok(['initdb', "$tempdir/data4"], 'existing empty data directory');
19+
20+
system_or_bail "rm -rf $tempdir/*";
21+
22+
command_ok(['initdb', "$tempdir/data", '-X', "$tempdir/pgxlog"], 'separate xlog directory');
23+
24+
system_or_bail "rm -rf $tempdir/*";
25+
command_fails(['initdb', "$tempdir/data", '-X', 'pgxlog'], 'relative xlog directory not allowed');
26+
27+
system_or_bail "rm -rf $tempdir/*";
28+
mkdir "$tempdir/pgxlog";
29+
command_ok(['initdb', "$tempdir/data", '-X', "$tempdir/pgxlog"], 'existing empty xlog directory');
30+
31+
system_or_bail "rm -rf $tempdir/*";
32+
mkdir "$tempdir/pgxlog";
33+
mkdir "$tempdir/pgxlog/lost+found";
34+
command_fails(['initdb', "$tempdir/data", '-X', "$tempdir/pgxlog"], 'existing nonempty xlog directory');
35+
36+
system_or_bail "rm -rf $tempdir/*";
37+
command_ok(['initdb', "$tempdir/data", '-T', 'german'], 'select default dictionary');

src/bin/pg_basebackup/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/pg_basebackup
22
/pg_receivexlog
33
/pg_recvlogical
4+
5+
/tmp_check/

0 commit comments

Comments
 (0)