X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=t%2Fax%2Fam-test-lib.sh;h=351db1307f4da93e31f35a5432af8bdf796ca19e;hb=2d6fec692f032ab60c27f5c22391ae87e49c53c7;hp=29ed61ad269a7169a4c79ec8c96ed21578f09348;hpb=33263a0fec525a7dfb0b0b0c0c21bb9d35b1d12f;p=platform%2Fupstream%2Fautomake.git diff --git a/t/ax/am-test-lib.sh b/t/ax/am-test-lib.sh index 29ed61a..351db13 100644 --- a/t/ax/am-test-lib.sh +++ b/t/ax/am-test-lib.sh @@ -1,6 +1,6 @@ # -*- shell-script -*- # -# Copyright (C) 1996-2012 Free Software Foundation, Inc. +# Copyright (C) 1996-2013 Free Software Foundation, Inc. # # 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 @@ -34,11 +34,6 @@ distdir=$me-1.0 ## Environment cleanup. ## ## ---------------------- ## -# Temporarily disable this, since some shells (e.g., older version -# of Bash) can return a non-zero exit status upon the when a non-set -# variable is unset. -set +e - # Unset some make-related variables that may cause $MAKE to act like # a recursively invoked sub-make. Any $MAKE invocation in a test is # conceptually an independent invocation, not part of the main @@ -48,18 +43,16 @@ unset __MKLVL__ MAKE_JOBS_FIFO # For BSD make. unset DMAKE_CHILD DMAKE_DEF_PRINTED DMAKE_MAX_JOBS # For Solaris dmake. # Unset verbosity flag. unset V -# Also unset variables that will let "make -e install" divert -# files into unwanted directories. +# Also unset variables that might influence "make install". unset DESTDIR unset prefix exec_prefix bindir datarootdir datadir docdir dvidir unset htmldir includedir infodir libdir libexecdir localedir mandir unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir -# Unset variables that might change the "make distcheck" behaviour. +# Unset variables that might influence "make distcheck". unset DISTCHECK_CONFIGURE_FLAGS AM_DISTCHECK_CONFIGURE_FLAGS # Used by install rules for info files. unset AM_UPDATE_INFO_DIR -# The tests call "make -e" but we do not want $srcdir from the environment -# to override the definition from the Makefile. +# We don't want to use the $srcdir value exported by the test driver. unset srcdir # Also unset variables that control our test driver. While not # conceptually independent, they cause some changed semantics we @@ -85,9 +78,6 @@ for pfx in TEST_ SH_ TAP_ ''; do done unset pfx -# Re-enable, it had been temporarily disabled above. -set -e - # cross_compiling # --------------- # Tell whether we are cross-compiling. This is especially useful to skip @@ -129,6 +119,186 @@ is_blocked_signal () fi } +# single_quote STRING +# ------------------- +# Single-quote STRING for the shell, also dealing with embedded single +# quotes. Place the result in the '$am_result', that is thus to be +# considered public. +single_quote () +{ + am_result=$1 + case $am_result in + *\'*) am_result=$(printf '%s\n' "$*" | sed -e "s/'/'\\\\''/g");; + esac + am_result="'$am_result'" +} + +# append_single_quoted VARIABLE STRING +# ------------------------------------ +append_single_quoted () +{ + am__var=$1; shift + single_quote "$1" # Sets 'am_result'. + eval "${am__var}=\${$am__var:+\"\${$am__var} \"}\$am_result" + unset am__var am_result +} + +# is_valid_varname STRING +# ----------------------- +# Tell whether STRING is a valid name for a shell variable. Return 0 +# if yes, return 1 if not. +is_valid_varname () +{ + # FIXME: is the below truly portable even for LC_COLLATE != "C" ? + case $1 in + [0-9]*) return 1;; + *[!a-zA-Z0-9_]*) return 1;; + esac + return 0 +} + +# run_make [-e STATUS] [-O] [-E] [-M] [--] [VAR=VAL ...] [MAKE-ARGS...] +# --------------------------------------------------------------------- +# +# Run $MAKE with the given command-line, and fail if it doesn't exit with +# STATUS (default: 0). If STATUS is "FAIL", then any exit status > 0 is +# acceptable. If STATUS is "IGNORE", any exit value is acceptable. +# +# Other options: +# +# -O save the standard output from make on disk, in a regular file +# named 'stdout'. +# +# -E save the standard error from make on disk, in a regular file +# named 'stderr'. +# +# -M save both the standard output and standard error from make on +# disk, in a regular file named 'output'. This option supersedes +# both the '-O' and '-E' options. +# +# This function also handle command-line override of variable definition +# in a smart way, using AM_MAKEFLAGS if a non-GNU make implementation +# is in use. +# +run_make () +{ + am__make_redirect_stdout=no + am__make_redirect_stderr=no + am__make_redirect_stdall=no + am__make_flags= + am__make_rc_exp=0 + # Follow-up code might want to analyse this, so mark is as + # publicly accessible (no double undesrscore). + am_make_rc=0 + # Parse options for this function. + while test $# -gt 0; do + case $1 in + -e) am__make_rc_exp=$2; shift;; + -O) am__make_redirect_stdout=yes;; + -E) am__make_redirect_stderr=yes;; + -M) am__make_redirect_stdall=yes;; + --) shift; break;; + *) break;; + esac + shift + done + + # Use append mode here to avoid dropping output. See automake bug#11413 + if using_gmake; then + # We can trust GNU make to correctly pass macro definitions given + # on the command line down to sub-make invocations, and this allow + # us to have a vary simple implementation: delegate all the work + # to GNU make. + : + else + # We have to explicitly parse arguments passed to make. Not 100% + # safe w.r.t. options like '-I' that can have an argument, but + # should be good enough for our usages so far. + for am__x + do + case $am__x in + *=*) + am__maybe_var=${am__x%%=*} + am__maybe_val=${am__x#*=} + am__maybe_def="${am__maybe_var}=${am__maybe_val}" + # Some variables should be portably overridable from the command + # line, even when using non-GNU make. + case $am__maybe_var in + V|\ + DESTDIR|\ + SHELL|\ + VERBOSE|\ + DISABLE_HARD_ERRORS|\ + DISTCHECK_CONFIGURE_FLAGS) + ;; + *) + if is_valid_varname "$am__maybe_var"; then + append_single_quoted am__make_flags "$am__maybe_def" + fi + esac + unset am__maybe_var am__maybe_val am__maybe_def + ;; + esac + done + unset am__x + fi + + if test x"$am__make_flags" != x; then + set AM_MAKEFLAGS="$am__make_flags" ${1+"$@"} + unset am__make_flags + fi + + # In redirecting make output below, use append mode, to avoid + # dropping output. See automake bug#11413 for details. + # The exit status of 253 is a more-or-less random choice, to + # help us catch possible errors in redirections and error out + # accordingly. + ( + : exec $MAKE ${1+"$@"} # Display traces for future command. + set +x # We need to remove them now, not to pollute redirected stderr. + if test $am__make_redirect_stdall = yes; then + : > output && exec 1>>output 2>&1 || exit 253 + else + if test $am__make_redirect_stdout = yes; then + : > stdout && exec 1>>stdout || exit 253 + fi + if test $am__make_redirect_stderr = yes; then + : > stderr && exec 2>>stderr || exit 253 + fi + fi + exec $MAKE ${1+"$@"} + ) || am_make_rc=$? + + if test $am_make_rc -eq 253; then + fatal_ "run_make: problems in redirecting make output" + fi + + if test $am__make_redirect_stdall = yes; then + cat output || fatal_ "displaying make output" + else + if test $am__make_redirect_stdout = yes; then + cat stdout || fatal_ "displaying make output" + fi + if test $am__make_redirect_stderr = yes; then + cat stderr >&2 || fatal_ "displaying make output" + fi + fi + + case $am__make_rc_exp in + IGNORE) + : Ignore exit status + ;; + FAIL) + test $am_make_rc -gt 0 || return 1 + ;; + *) + test $am__make_rc_exp -ge 0 && test $am__make_rc_exp -le 255 \ + || fatal_ "invalid expected exit status: '$am__make_rc_exp'" + test $am_make_rc -eq $am__make_rc_exp || return 1 + ;; + esac +} + # AUTOMAKE_run [-e STATUS] [-d DESCRIPTION] [--] [AUTOMAKE-ARGS...] # ----------------------------------------------------------------- # Run automake with AUTOMAKE-ARGS, and fail if it doesn't exit with @@ -319,7 +489,7 @@ useless_vpath_rebuild () .a.b: ; cp $< $@ baz: bar ; cp ../baz bar END - if $MAKE all && test ! -e foo.b && test ! -e bar; then + if run_make all && test ! -e foo.b && test ! -e bar; then am__useless_vpath_rebuild=no else am__useless_vpath_rebuild=yes @@ -331,12 +501,42 @@ END yes) return 0;; no) return 1;; "") ;; - *) fatal_ "no_useless_builddir_remake: internal error";; + *) fatal_ "useless_vpath_rebuild: internal error";; esac } am__useless_vpath_rebuild="" -yl_distcheck () { useless_vpath_rebuild || $MAKE distcheck ${1+"$@"}; } +yl_distcheck () { useless_vpath_rebuild || run_make distcheck ${1+"$@"}; } + +null_install () +{ + for am__v in nulldirs destdir instdir; do + if ! eval 'test -n "$'$am__v'"'; then + fatal_ "null_install() invoked with \$$am__v unset" + fi + done + unset am__v + case $#,$1 in + 0,) + am__inst='install';; + 1,-t|1,--texi) + am__inst='install install-html install-dvi install-ps install-pdf';; + *) + fatal_ "null_install(): invalid usage";; + esac + run_make $nulldirs $am__inst + test ! -e "$instdir" + run_make $nulldirs $am__inst DESTDIR="$destdir" + test ! -e "$instdir" + test ! -e "$destdir" + run_make -M $nulldirs uninstall + # Creative quoting below to please maintainer-check. + grep 'rm'' ' output && exit 1 + run_make -M $nulldirs uninstall DESTDIR="$destdir" + # Creative quoting below to please maintainer-check. + grep 'rm'' ' output && exit 1 + : # For 'set -e'. +} # count_test_results total=N pass=N fail=N xpass=N xfail=N skip=N error=N # ----------------------------------------------------------------------- @@ -439,8 +639,6 @@ fetch_tap_driver () || framework_failure_ "couldn't fetch $am_tap_implementation TAP driver" sed 10q tap-driver # For debugging. } -# The shell/awk implementation of the TAP driver is still mostly dummy, so -# use the perl implementation by default for the moment. am_tap_implementation=${am_tap_implementation-shell} # $PYTHON and support for PEP-3147. Needed to check our python-related @@ -597,16 +795,17 @@ require_tool () || skip_all_ "required program 'etags' not available" ;; GNUmake) - for make_ in "$MAKE" gmake gnumake :; do - MAKE=$make_ am__using_gmake='' - test "$MAKE" = : && break + for am_make in "$MAKE" gmake gnumake :; do + MAKE=$am_make + am__using_gmake= # Invalidate cache used by 'using_gmake()'. + test "$MAKE" = : && break echo "$me: determine whether $MAKE is GNU make" using_gmake && break : For shells with busted 'set -e'. done test "$MAKE" = : && skip_all_ "this test requires GNU make" export MAKE - unset make_ + unset am_make ;; gcj) GCJ=$GNU_GCJ GCJFLAGS=$GNU_GCJFLAGS; export GCJ GCJFLAGS @@ -662,8 +861,7 @@ require_tool () java -version -help || skip_all_ "Sun Java interpreter not found" ;; lib) - AR=lib - export AR + AR=lib; export AR # Attempting to create an empty archive will actually not # create the archive, but lib will output its version. echo "$me: running $AR -out:defstest.lib" @@ -675,13 +873,6 @@ require_tool () makedepend -f- \ || skip_all_ "required program 'makedepend' not available" ;; - makeinfo-html) - # Make sure we have makeinfo, and it understands '--html'. - echo "$me: running makeinfo --html --version" - makeinfo --html --version \ - || skip_all_ "cannot find a makeinfo program that groks" \ - "the '--html' option" - ;; mingw) uname_s=$(uname -s || echo UNKNOWN) echo "$me: system name: $uname_s" @@ -694,7 +885,7 @@ require_tool () non-root) # Skip this test case if the user is root. # We try to append to a read-only file to detect this. - priv_check_temp=priv-check.$$ + priv_check_temp=am--priv-check.$$ touch $priv_check_temp && chmod a-w $priv_check_temp \ || framework_failure_ "creating unwritable file $priv_check_temp" # Not a useless use of subshell: lesser shells might bail @@ -756,12 +947,6 @@ require_tool () skip_all_ "TeX is required, but it wasn't found by configure" fi ;; - texi2dvi-o) - # Texi2dvi supports '-o' since Texinfo 4.1. - echo "$me: running texi2dvi -o /dev/null --version" - texi2dvi -o /dev/null --version \ - || skip_all_ "required program 'texi2dvi' not available" - ;; lex) test x"$LEX" = x"false" && skip_all_ "lex not found or disabled" export LEX @@ -780,6 +965,19 @@ require_tool () echo "$me: running bison --version" bison --version || skip_all_ "required program 'bison' not available" ;; + valac) + echo "$me: running valac --version" + if ! valac --version; then + skip_all_ "required program 'valac' not available" + elif cross_compiling; then + skip_all_ "cross-compiling valac-generated C files is brittle" + fi + # TODO: We also know we need GNU make, the C compiler, and pkg-config + # here, but there is no easy way to express this with the current + # code organization. We should improve the situation, sooner or + # later. At which point the tests requiring 'valac' can drop the + # explicit requirements for those tools. + ;; *) # Generic case: the tool must support --version. echo "$me: running $1 --version" @@ -807,7 +1005,7 @@ process_requirements () *" $am_tool"*) . ./t/$am_tool-macros.dir/get.sh;; esac done - am_tool=; unset am_tool + unset am_tool } ## ---------------------------------------------------------------- ## @@ -843,9 +1041,9 @@ am_setup_testdir () { echo "AC_INIT([$me], [1.0])" if test x"$am_serial_tests" = x"yes"; then - echo "AM_INIT_AUTOMAKE" + echo "AM_INIT_AUTOMAKE([serial-tests])" else - echo "AM_INIT_AUTOMAKE([parallel-tests])" + echo "AM_INIT_AUTOMAKE" fi echo "AC_CONFIG_FILES([Makefile])" } >configure.ac || framework_failure_ "creating configure.ac skeleton"