Run each test in a process-private subdirectory.
[automake/plouj.git] / tests / defs.in
blobd79d874e657e1ee8a4f6794a16919776efac0130
1 # -*- shell-script -*-
2 # @configure_input@
4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 # 2005, 2006, 2007  Free Software Foundation, Inc.
7 # This file is part of GNU Automake.
9 # GNU Automake is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3, or (at your option)
12 # any later version.
14 # GNU Automake is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with autoconf; see the file COPYING.  If not, write to
21 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 # Boston, MA 02110-1301, USA.
24 # Defines for Automake testing environment.
25 # Tom Tromey <tromey@cygnus.com>
27 # Be Bourne compatible.
28 # (Snippet copied from configure's initialization in Autoconf 2.59c.)
29 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
30   emulate sh
31   NULLCMD=:
32   # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
33   # is contrary to our usage.  Disable this feature.
34   alias -g '${1+"$@"}'='"$@"'
35 else
36   case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
38 BIN_SH=xpg4; export BIN_SH # for Tru64
39 DUALCASE=1; export DUALCASE # for MKS sh
41 # Ensure we are running from the right directory.
42 test -f ./defs || {
43    echo "defs: not found in current directory" 1>&2
44    exit 1
47 # If srcdir is not set, then we are not running from `make check', be verbose.
48 if test -z "$srcdir"; then
49    VERBOSE=x
50    # compute $srcdir.
51    srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
52    test $srcdir = $0 && srcdir=.
53 else :; fi
55 # Ensure $srcdir is set correctly.
56 test -f $srcdir/defs.in || {
57    echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
58    exit 1
61 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
63 # See how redirections should work.  User can set VERBOSE to see all
64 # output.
65 test -z "$VERBOSE" && {
66    exec > /dev/null 2>&1
69 # Make sure we override the user shell.
70 SHELL='@SHELL@'
71 export SHELL
72 # User can override various tools used.
73 test -z "$PERL" && PERL='@PERL@'
74 test -z "$MAKE" && MAKE=make
75 test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
76 test -z "$AUTOHEADER" && AUTOHEADER="@AUTOHEADER@"
77 test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
78 test -z "$MISSING" && MISSING=`pwd`/../lib/missing
79 # Use -Werror because this also turns some Perl warnings into error.
80 # (Tests for which this is inappropriate should use -Wno-error.)
81 test -z "$ACLOCAL" && ACLOCAL="aclocal-@APIVERSION@ -Werror"
82 # Extra flags to pass to aclocal before all other flags added by this script.
83 ACLOCAL_TESTSUITE_FLAGS=
84 export ACLOCAL_TESTSUITE_FLAGS
86 # See how Automake should be run.  We put --foreign as the default
87 # strictness to avoid having to create lots and lots of files.  A test
88 # can override this by specifying a different strictness.  Use -Wall
89 # -Werror by default.  Tests for which this is inappropriate
90 # (e.g. when testing that a warning is enabled by a specific switch)
91 # should use -Wnone or/and -Wno-error
92 test -z "$AUTOMAKE" && AUTOMAKE="automake-@APIVERSION@ --foreign -Werror -Wall"
94 PATH="`pwd`@PATH_SEPARATOR@$PATH"
95 echo $PATH
96 # Some shells forget to export modified environment variables.
97 # (See note about `export' in the Autoconf manual.)
98 export PATH
100 for tool in : $required
102   # Check that each required tool is present.
103   case $tool in
104     :) ;;
105     bison)
106       # Since bison is required, we pick YACC for ./configure.
107       YACC='bison -y'
108       export YACC
109       echo "$me: running bison --version"
110       ( bison --version ) || exit 77
111       ;;
112     bzip2)
113       # Do not use --version, bzip2 still tries to compress stdin.
114       echo "$me: running bzip2 --help"
115       ( bzip2 --help ) || exit 77
116       ;;
117     etags)
118       # Exuberant Ctags will create a TAGS file even
119       # when asked for --help or --version.  (Emacs's etags
120       # does not have such problem.)  Use -o /dev/null
121       # to make sure we do not pollute the tests/ directory.
122       echo "$me: running etags --version -o /dev/null"
123       ( etags --version -o /dev/null ) || exit 77
124       ;;
125     GNUmake)
126       # Use --version AND -v, because SGI Make doesn't fail on --version.
127       # Also grep for GNU because newer versions of FreeBSD make do
128       # not complain about `--version' (they seem to silently ignore it).
129       echo "$me: running $MAKE --version -v | grep GNU"
130       ( $MAKE --version -v | grep GNU ) || exit 77
131       ;;
132     gcc)
133       # When gcc is required, export `CC=gcc' so that ./configure
134       # always use it.  This is important only when the user
135       # has defined CC in his environment, otherwise ./configure will
136       # prefer gcc to other compilers.
137       CC=gcc
138       export CC
139       echo "$me: running $CC --version"
140       ( $CC --version ) || exit 77
141       ;;
142     gcj)
143       GCJ=gcj
144       export GCJ
145       echo "$me: running $GCJ --version"
146       ( $GCJ --version ) || exit 77
147       ( $GCJ -v ) || exit 77
148       ;;
149     g++)
150       CXX=g++
151       export CXX
152       echo "$me: running $CXX --version"
153       ( $CXX --version ) || exit 77
154       ;;
155     icc)
156       CC=icc
157       export CC
158       # There is no way to ask *only* the compiler's version.
159       # This tool always want to do something (by default
160       # it will try link *nothing* and complain it cannot find
161       # main(); funny).  Use -help so it does not try linking anything.
162       echo "$me: running $CC -V -help"
163       ( $CC -V -help ) || exit 77
164       ;;
165     makedepend)
166       echo "$me: running makedepend -f-"
167       ( makedepend -f- ) || exit 77
168       ;;
169     makeinfo-html)
170       # Make sure makeinfo understands --html.
171       echo "$me: running makeinfo --html --version"
172       ( makeinfo --html --version ) || exit 77
173       ;;
174     non-root)
175       # Skip this test case if the user is root.
176       # We try to append to a read-only file to detect this.
177       priv_check_temp=priv-check.$$
178       touch $priv_check_temp || exit 1
179       chmod a-w $priv_check_temp || exit 1
180       (echo foo >> $priv_check_temp) >/dev/null 2>&1
181       overwrite_status=$?
182       rm -f $priv_check_temp
183       test $overwrite_status = 0 && exit 77
184       ;;
185     python)
186       # Python doesn't support --version, it has -V
187       echo "$me: running python -V"
188       ( python -V ) || exit 77
189       ;;
190     ro-dir)
191       # Skip this test case if read-only directories aren't supported
192       # (e.g., under DOS.)
193       ro_dir_temp=ro_dir.$$
194       mkdir $ro_dir_temp || exit 1
195       chmod a-w $ro_dir_temp || exit 1
196       (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
197       create_status=$?
198       rm -rf $ro_dir_temp
199       test $create_status = 0 && exit 77
200       ;;
201     runtest)
202       # DejaGnu's runtest program. We rely on being able to specify
203       # the program on the runtest command-line. This requires
204       # DejaGnu 1.4.3 or later.
205       echo "$me: running runtest --version"
206       (runtest SOMEPROGRAM=someprogram --version) || exit 77
207       ;;
208     tex)
209       # No all versions of Tex support `--version', so we use
210       # a configure check.
211       test -n "@TEX@" || exit 77
212       ;;
213     texi2dvi-o)
214       # Texi2dvi supports `-o' since Texinfo 4.1.
215       echo "$me: running texi2dvi -o /dev/null --version"
216       ( texi2dvi -o /dev/null --version ) || exit 77
217       ;;
218     # Generic case: the tool must support --version.
219     *)
220       echo "$me: running $tool --version"
221       ( $tool --version ) || exit 77
222       ;;
223   esac
224 done
227 # Always use an absolute srcdir.  Otherwise symlinks made in subdirs
228 # of the test dir just won't work.
229 case "$srcdir" in
230  [\\/]* | ?:[\\/]*)
231     ;;
233  *)
234     srcdir=`CDPATH=: && cd "$srcdir" && pwd`
235     ;;
236 esac
238 curdir=`pwd`
239 testSubDir=$me.dir
240 chmod -R u+rwx $testSubDir > /dev/null 2>&1
241 rm -rf $testSubDir > /dev/null 2>&1
242 mkdir $testSubDir
244 trap 'exit_status=$?
245   cd "$curdir"
246   case $exit_status,$keep_testdirs in
247   0,)
248     chmod -R a+rwx $testSubDir > /dev/null 2>&1
249     rm -rf "$testSubDir" ;;
250   esac
251   test "$signal" != 0 &&
252     echo "$as_me: caught signal $signal"
253   echo "$as_me: exit $exit_status"
254   exit $exit_status
255 ' 0
256 for signal in 1 2 13 15; do
257   trap 'signal='$signal'; { (exit 1); exit 1; }' $signal
258 done
259 signal=0
261 # Copy in some files we need.
262 for file in install-sh missing depcomp; do
263    cp $srcdir/../lib/$file $testSubDir/$file || exit 1
264 done
266 cd ./$testSubDir
268 # Build appropriate environment in test directory.  Eg create
269 # configure.in, touch all necessary files, etc.
270 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
271 # still produces a valid configure.ac.  But then, tests running
272 # config.status really need to append AC_OUTPUT.
273 cat > configure.in << END
274 AC_INIT([$me], [1.0])
275 AM_INIT_AUTOMAKE
276 AC_CONFIG_FILES([Makefile])
279 # Unset some MAKE... variables that may cause $MAKE to act like a
280 # recursively invoked sub-make.  Any $MAKE invocation in a test is
281 # conceptually an independent invocation, not part of the main
282 # 'automake' build.
283 unset MFLAGS
284 unset MAKEFLAGS
285 unset MAKELEVEL
286 unset DESTDIR
288 echo "=== Running test $0"
290 # We might need extra macros, e.g., from Libtool or Gettext.
291 # Find them on the system.
292 # Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
293 # other `-I' directories added for libtool and gettext might contain
294 # files from an old version of Automake that we don't want to use.
295 # Use `-Wno-syntax' because we do not want our test suite to fail because
296 # some third-party .m4 file is underquoted.
297 case $required in
298   *libtool* | *gettext* )
299     aclocaldir='@prefix@/share/aclocal'
300     extra_includes=""
301     if test -f $aclocaldir/dirlist; then
302        extra_includes=`(tmp_inc=""
303        while read LINE ; do
304           tmp_inc="$tmp_inc -I $LINE"
305        done
306        echo $tmp_inc) < $aclocaldir/dirlist`
307     else :; fi
309     libtool_found=no
310     gettext_found=no
311     for d in $extra_includes $aclocaldir ; do
312        test "x$d" != x-I || continue
313        if test -f "$d/libtool.m4"; then
314           libtool_found=yes
315        fi
316        if test -f "$d/gettext.m4"; then
317           gettext_found=yes
318        fi
319     done
320     case $required in
321       *libtool* ) test $libtool_found = yes || exit 77 ;;
322       *gettext* ) test $gettext_found = yes || exit 77 ;;
323     esac
324     ACLOCAL="$ACLOCAL -Wno-syntax -I $srcdir/../m4 $extra_includes -I $aclocaldir"
325     ;;
326 esac
328 testaclocaldir='@abs_top_srcdir@/m4'
330 # POSIX no longer requires 'egrep' and 'fgrep',
331 # but some hosts lack 'grep -E' and 'grep -F'.
332 EGREP='@EGREP@'
333 FGREP='@FGREP@'
335 # The amount we should wait after modifying files depends on the platform.
336 # For instance, Windows '95, '98 and ME have 2-second granularity
337 # and can be up to 3 seconds in the future w.r.t. the system clock.
338 sleep='sleep @MODIFICATION_DELAY@'
340 # The tests call `make -e' but we do not want $srcdir from the environment
341 # to override the definition from the Makefile.
342 testsrcdir=$srcdir
343 unset srcdir
345 # An old timestamp that can be given to a file, in "touch -t" format.
346 # The time stamp should be portable to all file systems of interest.
347 # Just for fun, choose the exact time of the announcement of the GNU project
348 # in UTC; see <http://www.gnu.org/gnu/initial-announcement.html>.
349 old_timestamp=198309271735.59
351 # is_newest FILE FILES
352 # --------------------
353 # Return false if any file in FILES is newer than FILE.
354 # Resolve ties in favor of FILE.
355 is_newest ()
357   is_newest_files=`find "$@" -newer "$1"`
358   test -z "$is_newest_files"
362 # AUTOMAKE_run status [options...]
363 # --------------------------------
364 # Run Automake with OPTIONS, and fail if automake
365 # does not exit with STATUS.
366 AUTOMAKE_run ()
368   expected_exitcode=$1
369   shift
370   exitcode=0
371   $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$?
372   cat stderr
373   cat stdout
374   test $exitcode = $expected_exitcode || exit 1
377 # AUTOMAKE_fails [options...]
378 # ---------------------------
379 # Run Automake with OPTIONS, and fail if automake
380 # does not exit with STATUS.
381 AUTOMAKE_fails ()
383   AUTOMAKE_run 1 ${1+"$@"}
386 # Turn on shell traces when VERBOSE is set.
387 if test -n "$VERBOSE"; then
388   set -x
389 else
390   :