tests: Enable glib-tap.mk

These files were taken from json-glib, around the era of this commit:

https://git.gnome.org/browse/json-glib/tree/build/autotools?id=2779d537492f1902d71cf648631238110b62b311

Unfortunately, this involved hacking it up a bit:
 - I couldn't easily use `nobase` for the data, so I deleted that.
   Test data goes in the installed-tests dir.
 - Delete duplicated predeclared variables; we're using nonrecursive
   make.
 - Ensure we run each test in its own tmpdir
This commit is contained in:
Colin Walters 2014-12-17 18:11:47 -05:00
parent f93cb5bcc5
commit fee9f48409
4 changed files with 27 additions and 57 deletions

View File

@ -1,41 +1,11 @@
# Makefile for tests code include $(top_srcdir)/buildutil/glib-tap.mk
#
# Copyright (C) 2013,2014 Colin Walters <walters@verbum.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
if BUILDOPT_INSTALL_TESTS tests_shutil_CPPFLAGS = -I $(srcdir)/src
insttest_PROGRAMS = tests_shutil_CFLAGS = $(BUILDDEP_GIO_UNIX_CFLAGS)
tests_shutil_LDADD = $(BUILDDEP_GIO_UNIX_LIBS) libgsystem.la
insttestdir=$(pkglibexecdir)/installed-tests installed_test_data = tests/libtest.sh
testfiles = test-basic \
test_scripts = \
tests/test-basic.sh \
$(NULL) $(NULL)
insttest_SCRIPTS = $(addprefix tests/,$(testfiles:=.sh))
testmetadir = $(datadir)/installed-tests/$(PACKAGE)
testmeta_DATA = $(testfiles:=.test)
insttest_DATA = tests/libtest.sh \
$(NULL)
%.test: tests/%.sh Makefile
$(AM_V_GEN) (echo '[Test]' > $@.tmp; \
echo 'Exec=$(pkglibexecdir)/installed-tests/$(notdir $<)' >> $@.tmp; \
echo 'Type=session' >> $@.tmp; \
echo 'Output=TAP' >> $@.tmp; \
mv $@.tmp $@)
endif

View File

@ -6,27 +6,17 @@ TESTS_ENVIRONMENT= \
G_DEBUG=gc-friendly \ G_DEBUG=gc-friendly \
MALLOC_CHECK_=2 \ MALLOC_CHECK_=2 \
MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/build/autotools/tap-driver.sh LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/buildutil/tap-driver.sh
LOG_COMPILER = $(top_srcdir)/build/autotools/tap-test LOG_COMPILER = $(top_srcdir)/buildutil/tap-test
NULL =
# initialize variables for unconditional += appending
BUILT_SOURCES =
BUILT_EXTRA_DIST =
CLEANFILES = *.log *.trs
DISTCLEANFILES =
MAINTAINERCLEANFILES =
EXTRA_DIST =
TESTS = TESTS =
installed_test_LTLIBRARIES = installed_test_LTLIBRARIES =
installed_test_PROGRAMS = installed_test_PROGRAMS =
installed_test_SCRIPTS = installed_test_SCRIPTS =
installed_test_DATA =
nobase_installed_test_DATA = nobase_installed_test_DATA =
noinst_LTLIBRARIES =
noinst_PROGRAMS =
noinst_SCRIPTS = noinst_SCRIPTS =
noinst_DATA = noinst_DATA =
@ -115,8 +105,8 @@ installed_test_SCRIPTS += $(test_scripts) $(installed_test_scripts) \
$(test_extra_scripts) $(test_installed_extra_scripts) $(test_extra_scripts) $(test_installed_extra_scripts)
installed_test_SCRIPTS += $(dist_test_scripts) $(dist_test_extra_scripts) \ installed_test_SCRIPTS += $(dist_test_scripts) $(dist_test_extra_scripts) \
$(dist_installed_test_scripts) $(dist_installed_test_extra_scripts) $(dist_installed_test_scripts) $(dist_installed_test_extra_scripts)
nobase_installed_test_DATA += $(test_data) $(installed_test_data) installed_test_DATA += $(test_data) $(installed_test_data)
nobase_installed_test_DATA += $(dist_test_data) $(dist_installed_test_data) installed_test_DATA += $(dist_test_data) $(dist_installed_test_data)
installed_test_LTLIBRARIES += $(test_ltlibraries) $(installed_test_ltlibraries) installed_test_LTLIBRARIES += $(test_ltlibraries) $(installed_test_ltlibraries)
installed_testcases = $(test_programs) $(installed_test_programs) \ installed_testcases = $(test_programs) $(installed_test_programs) \
$(test_scripts) $(installed_test_scripts) \ $(test_scripts) $(installed_test_scripts) \
@ -127,7 +117,7 @@ installed_test_meta_DATA = $(installed_testcases:=.test)
%.test: %$(EXEEXT) Makefile %.test: %$(EXEEXT) Makefile
$(AM_V_GEN) (echo '[Test]' > $@.tmp; \ $(AM_V_GEN) (echo '[Test]' > $@.tmp; \
echo 'Type=session' >> $@.tmp; \ echo 'Type=session' >> $@.tmp; \
echo 'Exec=$(installed_testdir)/$<' >> $@.tmp; \ echo 'Exec=$(installed_testdir)/$(notdir $<)' >> $@.tmp; \
mv $@.tmp $@) mv $@.tmp $@)
CLEANFILES += $(installed_test_meta_DATA) CLEANFILES += $(installed_test_meta_DATA)

View File

@ -1,5 +1,13 @@
#! /bin/sh #! /bin/bash
# run a GTest in tap mode. The test binary is passed as $1 # run a GTest in tap mode. The test binary is passed as $1
$1 -k --tap srcd=$(cd $(dirname $1) && pwd)
bn=$(basename $1)
tempdir=$(mktemp -d)
function cleanup () {
rm "${tempdir}" -rf
}
trap cleanup EXIT
cd ${tempdir}
${srcd}/${bn} -k --tap

View File

@ -1,7 +1,7 @@
AC_PREREQ([2.63]) AC_PREREQ([2.63])
AC_INIT([rpm-ostree], [2014.114], [walters@verbum.org]) AC_INIT([rpm-ostree], [2014.114], [walters@verbum.org])
AC_CONFIG_HEADER([config.h]) AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([buildutil])
AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([1.11 -Wno-portability foreign no-define tar-ustar no-dist-gzip dist-xz]) AM_INIT_AUTOMAKE([1.11 -Wno-portability foreign no-define tar-ustar no-dist-gzip dist-xz])
@ -45,6 +45,8 @@ PKG_CHECK_MODULES(PKGDEP_GIO_UNIX, [gio-unix-2.0])
PKG_CHECK_MODULES(PKGDEP_RPMOSTREE, [gio-unix-2.0 json-glib-1.0 ostree-1 >= 2014.13 libgsystem rpm hawkey]) PKG_CHECK_MODULES(PKGDEP_RPMOSTREE, [gio-unix-2.0 json-glib-1.0 ostree-1 >= 2014.13 libgsystem rpm hawkey])
AC_PATH_PROG([XSLTPROC], [xsltproc]) AC_PATH_PROG([XSLTPROC], [xsltproc])
GLIB_TESTS
GOBJECT_INTROSPECTION_REQUIRE([1.34.0]) GOBJECT_INTROSPECTION_REQUIRE([1.34.0])
AC_ARG_ENABLE(installed_tests, AC_ARG_ENABLE(installed_tests,