From 349f80ef8f3e3e2f92f681c2f3bd4a89620aabde Mon Sep 17 00:00:00 2001 From: Francesco Salvestrini Date: Sun, 2 Aug 2009 18:33:07 +0200 Subject: [PATCH] Introduced autoconf-like tests regression environment --- .gitignore | 8 +++ Makefile.am | 2 + configure.ac | 4 +- tests/Makefile.am | 84 +++++++++++++++++++++++++++++ tests/defs.in | 137 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/test-aclocal.in | 20 +++++++ tests/test-autoconf.in | 22 ++++++++ tests/test-fail.in | 13 +++++ tests/test-success.in | 13 +++++ 9 files changed, 301 insertions(+), 2 deletions(-) create mode 100644 tests/Makefile.am create mode 100644 tests/defs.in create mode 100644 tests/test-aclocal.in create mode 100644 tests/test-autoconf.in create mode 100644 tests/test-fail.in create mode 100644 tests/test-success.in diff --git a/.gitignore b/.gitignore index 81c1589..06f46ae 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,14 @@ /INSTALL /Makefile /Makefile.in +/tests/Makefile +/tests/Makefile.in +/tests/testSubDir-* +/tests/test-aclocal +/tests/test-autoconf +/tests/test-fail +/tests/test-success +/tests/defs /aclocal.m4 /autoconf-archive-*.*.*.tar.* /autoconf-archive.info diff --git a/Makefile.am b/Makefile.am index ca7f018..6772d6f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,6 +13,8 @@ dist_html_DATA = $(HTMLFILE) EXTRA_DIST = build-aux/git-version-gen +SUBDIRS = tests + # maintainer rules dist-hook: diff --git a/configure.ac b/configure.ac index 0b43b7a..81450d2 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl configure the Autoconf Archive AC_INIT([autoconf-archive], m4_esyscmd([build-aux/git-version-gen .tarball-version]), address@hidden) AC_CONFIG_AUX_DIR([build-aux]) -AM_INIT_AUTOMAKE([-Wall gnu dist-bzip2 dist-xz]) +AM_INIT_AUTOMAKE([-Wall gnu dist-bzip2]) AC_CONFIG_SRCDIR([m4/ax_have_epoll.m4]) AC_COPYRIGHT([dnl Compilation Copyright 2009 by Peter Simons @@ -35,7 +35,7 @@ done AC_SUBST([HTMLFILE]) AC_MSG_RESULT([done]) -AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([Makefile tests/Makefile tests/defs]) AC_OUTPUT dnl Responsibility shifts to the user after this point. diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..5593fd5 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,84 @@ +# Tests environment for the Autoconf Archive. +# +# Copyright (c) 2009 by Francesco Salvestrini +# Licensed under the terms of the GNU General Public License. + +CLEANFILES = defs +EXTRA_DIST = + +do_subst = sed \ + -e 's,address@hidden@],$(abs_builddir),g' \ + -e 's,address@hidden@],$(SHELL),g' + +all-local: defs + +## +## NOTE: +## In order to debug the tests during the 'distcheck' target use the +## following TESTS_ENVIRONMENT: +## +## TESTS_ENVIRONMENT = address@hidden@ DEBUG=x VERBOSE=x +## +TESTS_ENVIRONMENT = address@hidden@ + +FAIL_TESTS = \ + test-fail + +SUCCESS_TESTS = \ + test-success \ + test-aclocal \ + test-autoconf + +XFAIL_TESTS = $(FAIL_TESTS) +TESTS = $(FAIL_TESTS) $(SUCCESS_TESTS) + +test-success: $(srcdir)/test-success.in Makefile + ( rm -f $@ address@hidden && \ + $(do_subst) < $(srcdir)/test-success.in > address@hidden && \ + chmod +x address@hidden && \ + chmod a-w address@hidden && \ + mv -f address@hidden $@ ) || { \ + rm -f $@ address@hidden ; \ + exit 1 ; \ + } +EXTRA_DIST += test-success.in +CLEANFILES += test-success + +test-fail: $(srcdir)/test-fail.in Makefile + ( rm -f $@ address@hidden && \ + $(do_subst) < $(srcdir)/test-fail.in > address@hidden && \ + chmod +x address@hidden && \ + chmod a-w address@hidden && \ + mv -f address@hidden $@ ) || { \ + rm -f $@ address@hidden ; \ + exit 1 ; \ + } +EXTRA_DIST += test-fail.in +CLEANFILES += test-fail + +test-aclocal: $(srcdir)/test-aclocal.in Makefile + ( rm -f $@ address@hidden && \ + $(do_subst) < $(srcdir)/test-aclocal.in > address@hidden && \ + chmod +x address@hidden && \ + chmod a-w address@hidden && \ + mv -f address@hidden $@ ) || { \ + rm -f $@ address@hidden ; \ + exit 1 ; \ + } +EXTRA_DIST += test-aclocal.in +CLEANFILES += test-aclocal + +test-autoconf: $(srcdir)/test-autoconf.in Makefile + ( rm -f $@ address@hidden && \ + $(do_subst) < $(srcdir)/test-autoconf.in > address@hidden && \ + chmod +x address@hidden && \ + chmod a-w address@hidden && \ + mv -f address@hidden $@ ) || { \ + rm -f $@ address@hidden ; \ + exit 1 ; \ + } +EXTRA_DIST += test-autoconf.in +CLEANFILES += test-autoconf + +clean-local: + rm -rf testSubDir-* diff --git a/tests/defs.in b/tests/defs.in new file mode 100644 index 0000000..2e75e46 --- /dev/null +++ b/tests/defs.in @@ -0,0 +1,137 @@ +# +# This file is based upon defs.in from automake package +# +# Copyright (C) 2009 Francesco Salvestrini +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +# Be Bourne compatible. +# (Snippet copied from configure's initialization in Autoconf 2.57.) +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Ensure we are running from the right directory. +test -f ./defs || { + echo "defs: not found in current directory" 1>&2 + exit 1 +} + +# If srcdir is not set, then we are not running from `make check', be verbose. +if test -z "$srcdir"; then + test -z "$VERBOSE" && VERBOSE=x + # compute $srcdir. + srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'` + test $srcdir = $0 && srcdir=. +fi + +# Ensure $srcdir is set correctly. +test -f $srcdir/defs.in || { + echo "$srcdir/defs.in not found, check \$srcdir" 1>&2 + exit 1 +} + +me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'` + +# See how redirections should work. User can set VERBOSE to see all +# output. +test -z "$VERBOSE" && { + exec > /dev/null 2>&1 +} + +# Make sure we override the user shell. +SHELL='@SHELL@' +export SHELL + +test -z "$AUTOCONF" && AUTOCONF="autoconf" +test -z "$ACLOCAL" && ACLOCAL="aclocal -I @abs_top_builddir@/m4" + +PATH=`pwd`:$PATH +echo $PATH + +# +# NOTE: +# exit 77 means SKIP to automake +# +if test -n "$required" +then + for tool in $required + do + # Check that each required tool is present. + case $tool in + # Generic case: the tool must support --version. + *) + echo "$me: running $tool --version" + ( $tool --version ) || exit 77 + ;; + esac + # Additional variables to define if some $tool is required. + case $tool in + gcc) + ;; + esac + done +fi + +# Always use an absolute srcdir. Otherwise symlinks made in subdirs +# of the test dir just won't work. +case "$srcdir" in + [\\/]* | ?:[\\/]*) + ;; + + *) + srcdir=`CDPATH=: && cd "$srcdir" && pwd` + ;; +esac + +testname=`basename $0 .test` +chmod -R a+rwx testSubDir-$testname > /dev/null 2>&1 +rm -rf testSubDir-$testname > /dev/null 2>&1 +mkdir testSubDir-$testname + +cd ./testSubDir-$testname + +echo "=== Running test $0" + +# POSIX no longer requires 'egrep' and 'fgrep', +# but some hosts lack 'grep -E' and 'grep -F'. +EGREP='@EGREP@' +FGREP='@FGREP@' + +# The amount we should wait after modifying files depends on the platform. +# For instance, Windows '95, '98 and ME have 2-second granularity +# and can be up to 3 seconds in the future w.r.t. the system clock. +sleep='sleep @MODIFICATION_DELAY@' + +# The tests call `make -e' but we do not want $srcdir from the environment +# to override the definition from the Makefile. +testsrcdir=$srcdir +unset srcdir + +# Turn on shell traces when VERBOSE=x. +if test "x$VERBOSE" = xx; then + set -x +else + : +fi + +pwd diff --git a/tests/test-aclocal.in b/tests/test-aclocal.in new file mode 100644 index 0000000..714c1f2 --- /dev/null +++ b/tests/test-aclocal.in @@ -0,0 +1,20 @@ +#! @SHELL@ + +# +# Copyright (C) 2009 Francesco Salvestrini +# Licensed under the terms of the GNU General Public License. + +# Test to ensure that the test environment has a good set-up + +required="aclocal" + +. @abs_builddir@/defs || exit 1 + +cat > ./configure.ac < ./configure.ac <