Skip to content

Commit 0e9f986

Browse files
Start using TAP
Convert {glib,gobject,gio}/tests to use the automake TAP driver and test harness instead of gtester. To do so, we add a glib-tap.mk that provides the same interface as glib.mk, except for the reporting and coverage testing functionality. Eventually, we may want to replace glib.mk with it. I've not yet converted the toplevel tests/ directory, since it mixes gtestutils tests with other binaries. https://bugzilla.gnome.org/show_bug.cgi?id=692125
1 parent 1ea3405 commit 0e9f986

File tree

5 files changed

+137
-3
lines changed

5 files changed

+137
-3
lines changed

Diff for: gio/tests/Makefile.am

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
include $(top_srcdir)/glib.mk
1+
include $(top_srcdir)/glib-tap.mk
2+
23
dist_uninstalled_test_data =
34
test_ltlibraries =
45

Diff for: glib-tap.mk

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# GLIB - Library of useful C routines
2+
3+
TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh
4+
LOG_COMPILER = $(top_srcdir)/tap-test
5+
6+
NULL =
7+
8+
# initialize variables for unconditional += appending
9+
BUILT_SOURCES =
10+
BUILT_EXTRA_DIST =
11+
CLEANFILES = *.log *.trs
12+
DISTCLEANFILES =
13+
MAINTAINERCLEANFILES =
14+
EXTRA_DIST =
15+
TESTS =
16+
17+
installed_test_LTLIBRARIES =
18+
installed_test_PROGRAMS =
19+
installed_test_SCRIPTS =
20+
nobase_installed_test_DATA =
21+
22+
noinst_LTLIBRARIES =
23+
noinst_PROGRAMS =
24+
noinst_SCRIPTS =
25+
noinst_DATA =
26+
27+
check_LTLIBRARIES =
28+
check_PROGRAMS =
29+
check_SCRIPTS =
30+
check_DATA =
31+
32+
# We support a fairly large range of possible variables. It is expected that all types of files in a test suite
33+
# will belong in exactly one of the following variables.
34+
#
35+
# First, we support the usual automake suffixes, but in lowercase, with the customary meaning:
36+
#
37+
# test_programs, test_scripts, test_data, test_ltlibraries
38+
#
39+
# The above are used to list files that are involved in both uninstalled and installed testing. The
40+
# test_programs and test_scripts are taken to be actual testcases and will be run as part of the test suite.
41+
# Note that _data is always used with the nobase_ automake variable name to ensure that installed test data is
42+
# installed in the same way as it appears in the package layout.
43+
#
44+
# In order to mark a particular file as being only for one type of testing, use 'installed' or 'uninstalled',
45+
# like so:
46+
#
47+
# installed_test_programs, uninstalled_test_programs
48+
# installed_test_scripts, uninstalled_test_scripts
49+
# installed_test_data, uninstalled_test_data
50+
# installed_test_ltlibraries, uninstalled_test_ltlibraries
51+
#
52+
# Additionally, we support 'extra' infixes for programs and scripts. This is used for support programs/scripts
53+
# that should not themselves be run as testcases (but exist to be used from other testcases):
54+
#
55+
# test_extra_programs, installed_test_extra_programs, uninstalled_test_extra_programs
56+
# test_extra_scripts, installed_test_extra_scripts, uninstalled_test_extra_scripts
57+
#
58+
# Additionally, for _scripts and _data, we support the customary dist_ prefix so that the named script or data
59+
# file automatically end up in the tarball.
60+
#
61+
# dist_test_scripts, dist_test_data, dist_test_extra_scripts
62+
# dist_installed_test_scripts, dist_installed_test_data, dist_installed_test_extra_scripts
63+
# dist_uninstalled_test_scripts, dist_uninstalled_test_data, dist_uninstalled_test_extra_scripts
64+
#
65+
# Note that no file is automatically disted unless it appears in one of the dist_ variables. This follows the
66+
# standard automake convention of not disting programs scripts or data by default.
67+
#
68+
# test_programs, test_scripts, uninstalled_test_programs and uninstalled_test_scripts (as well as their disted
69+
# variants) will be run as part of the in-tree 'make check'. These are all assumed to be runnable under
70+
# gtester. That's a bit strange for scripts, but it's possible.
71+
72+
TESTS += $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
73+
$(dist_test_scripts) $(dist_uninstalled_test_scripts)
74+
75+
# Note: build even the installed-only targets during 'make check' to ensure that they still work.
76+
# We need to do a bit of trickery here and manage disting via EXTRA_DIST instead of using dist_ prefixes to
77+
# prevent automake from mistreating gmake functions like $(wildcard ...) and $(addprefix ...) as if they were
78+
# filenames, including removing duplicate instances of the opening part before the space, eg. '$(addprefix'.
79+
all_test_programs = $(test_programs) $(uninstalled_test_programs) $(installed_test_programs) \
80+
$(test_extra_programs) $(uninstalled_test_extra_programs) $(installed_test_extra_programs)
81+
all_test_scripts = $(test_scripts) $(uninstalled_test_scripts) $(installed_test_scripts) \
82+
$(test_extra_scripts) $(uninstalled_test_extra_scripts) $(installed_test_extra_scripts)
83+
all_dist_test_scripts = $(dist_test_scripts) $(dist_uninstalled_test_scripts) $(dist_installed_test_scripts) \
84+
$(dist_test_extra_scripts) $(dist_uninstalled_test_extra_scripts) $(dist_installed_test_extra_scripts)
85+
all_test_scripts += $(all_dist_test_scripts)
86+
EXTRA_DIST += $(all_dist_test_scripts)
87+
all_test_data = $(test_data) $(uninstalled_test_data) $(installed_test_data)
88+
all_dist_test_data = $(dist_test_data) $(dist_uninstalled_test_data) $(dist_installed_test_data)
89+
all_test_data += $(all_dist_test_data)
90+
EXTRA_DIST += $(all_dist_test_data)
91+
all_test_ltlibs = $(test_ltlibraries) $(uninstalled_test_ltlibraries) $(installed_test_ltlibraries)
92+
93+
if ENABLE_ALWAYS_BUILD_TESTS
94+
noinst_LTLIBRARIES += $(all_test_ltlibs)
95+
noinst_PROGRAMS += $(all_test_programs)
96+
noinst_SCRIPTS += $(all_test_scripts)
97+
noinst_DATA += $(all_test_data)
98+
else
99+
check_LTLIBRARIES += $(all_test_ltlibs)
100+
check_PROGRAMS += $(all_test_programs)
101+
check_SCRIPTS += $(all_test_scripts)
102+
check_DATA += $(all_test_data)
103+
endif
104+
105+
if ENABLE_INSTALLED_TESTS
106+
installed_test_PROGRAMS += $(test_programs) $(installed_test_programs) \
107+
$(test_extra_programs) $(installed_test_extra_programs)
108+
installed_test_SCRIPTS += $(test_scripts) $(installed_test_scripts) \
109+
$(test_extra_scripts) $(test_installed_extra_scripts)
110+
installed_test_SCRIPTS += $(dist_test_scripts) $(dist_test_extra_scripts) \
111+
$(dist_installed_test_scripts) $(dist_installed_test_extra_scripts)
112+
nobase_installed_test_DATA += $(test_data) $(installed_test_data)
113+
nobase_installed_test_DATA += $(dist_test_data) $(dist_installed_test_data)
114+
installed_test_LTLIBRARIES += $(test_ltlibraries) $(installed_test_ltlibraries)
115+
installed_testcases = $(test_programs) $(installed_test_programs) \
116+
$(test_scripts) $(installed_test_scripts) \
117+
$(dist_test_scripts) $(dist_installed_test_scripts)
118+
119+
installed_test_meta_DATA = $(installed_testcases:=.test)
120+
121+
%.test: %$(EXEEXT) Makefile
122+
$(AM_V_GEN) (echo '[Test]' > $@.tmp; \
123+
echo 'Type=session' >> $@.tmp; \
124+
echo 'Exec=$(installed_testdir)/$<' >> $@.tmp; \
125+
mv $@.tmp $@)
126+
127+
CLEANFILES += $(installed_test_meta_DATA)
128+
endif

Diff for: glib/tests/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include $(top_srcdir)/glib.mk
1+
include $(top_srcdir)/glib-tap.mk
22

33
LDADD = $(top_builddir)/glib/libglib-2.0.la -lm
44
AM_CPPFLAGS = -g $(glib_INCLUDES) $(GLIB_DEBUG_FLAGS)

Diff for: gobject/tests/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include $(top_srcdir)/glib.mk
1+
include $(top_srcdir)/glib-tap.mk
22

33
LDADD = ../libgobject-2.0.la $(top_builddir)/glib/libglib-2.0.la
44
AM_CPPFLAGS = -g $(gobject_INCLUDES) $(GLIB_DEBUG_FLAGS)

Diff for: tap-test

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#! /bin/sh
2+
3+
# run a GTest in tap mode. The test binary is passed as $1
4+
5+
$1 -k --tap

0 commit comments

Comments
 (0)