Merge branch 'micro' into maint
[platform/upstream/automake.git] / t / ax / am-test-lib.sh
index 8a0e117..f35ccd5 100644 (file)
@@ -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
@@ -85,9 +80,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
@@ -155,7 +147,7 @@ AUTOMAKE_run ()
   $AUTOMAKE ${1+"$@"} >stdout 2>stderr || am__got_rc=$?
   cat stderr >&2
   cat stdout
-  if test $am_using_tap != yes; then
+  if test $am_test_protocol = none; then
     test $am__got_rc -eq $am__exp_rc || exit 1
     return
   fi
@@ -439,10 +431,67 @@ 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
+# install rules.
+python_has_pep3147 ()
+{
+  if test -z "$am_pep3147_tag"; then
+    am_pep3147_tag=$($PYTHON -c 'import imp; print(imp.get_tag())') \
+      || am_pep3147_tag=none
+  fi
+  test $am_pep3147_tag != none
+}
+am_pep3147_tag=
+
+# pyc_location [-p] [FILE]
+# ------------------------
+# Determine what the actual location of the given '.pyc' or '.pyo'
+# byte-compiled file should be, taking into account PEP-3147.  Save
+# the location in the '$am_pyc_file' variable.  If the '-p' option
+# is given, print the location on the standard output as well.
+pyc_location ()
+{
+  case $#,$1 in
+    2,-p) am_pyc_print=yes; shift;;
+     1,*) am_pyc_print=no;;
+       *) fatal_ "pyc_location: invalid usage";;
+  esac
+  if python_has_pep3147; then
+    case $1 in
+      */*) am_pyc_dir=${1%/*} am_pyc_base=${1##*/};;
+        *) am_pyc_dir=. am_pyc_base=$1;;
+    esac
+    am_pyc_ext=${am_pyc_base##*.}
+    am_pyc_base=${am_pyc_base%.py?}
+    am_pyc_file=$am_pyc_dir/__pycache__/$am_pyc_base.$am_pep3147_tag.$am_pyc_ext
+  else
+    am_pyc_file=$1
+  fi
+  test $am_pyc_print = no || printf '%s\n' "$am_pyc_file"
+}
+
+# py_installed [--not] FILE
+# --------------------------
+# Check that the given python FILE has been installed (resp. *not*
+# installed, if the '--not' option is specified).  If FILE is a
+# byte-compiled '.pyc' file, the new installation layout specified
+# by PEP-3147 will be taken into account.
+py_installed ()
+{
+  case $#,$1 in
+        1,*) am_test_py_file='test -f';;
+    2,--not) am_test_py_file='test ! -e'; shift;;
+          *) fatal_ "pyc_installed: invalid usage";;
+  esac
+  case $1 in
+    *.py[co]) pyc_location "$1"; am_target_py_file=$am_pyc_file;;
+           *) am_target_py_file=$1;;
+  esac
+  $am_test_py_file "$am_target_py_file"
+}
+
 # Usage: require_compiler_ {cc|c++|fortran|fortran77}
 require_compiler_ ()
 {
@@ -616,13 +665,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"
@@ -661,9 +703,10 @@ require_tool ()
       ! cross_compiling || skip_all_ "doesn't work in cross-compile mode"
       ;;
     python)
-      # Python doesn't support --version, it has -V
-      echo "$me: running python -V"
-      python -V || skip_all_ "python interpreter not available"
+      PYTHON=${PYTHON-python}
+      # Older python versions don't support --version, they have -V.
+      echo "$me: running $PYTHON -V"
+      $PYTHON -V || skip_all_ "python interpreter not available"
       ;;
     ro-dir)
       # Skip this test case if read-only directories aren't supported
@@ -696,12 +739,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
@@ -720,6 +757,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"
@@ -740,14 +790,14 @@ process_requirements ()
   for am_tool in $*; do
     require_tool $am_tool
   done
+  # We might need extra m4 macros, e.g., for Libtool or Gettext.
+  for am_tool in gettext libtool pkg-config; do
+    case " $required " in
+      # The lack of whitespace after $am_tool is intended.
+      *" $am_tool"*) . ./t/$am_tool-macros.dir/get.sh;;
+    esac
+  done
   unset am_tool
-  # We might need extra macros, e.g., from Libtool or Gettext.
-  case " $required " in
-    *\ libtool*) . ./t/libtool-macros.dir/get.sh;;
-  esac
-  case " $required " in
-    *\ gettext*) . ./t/gettext-macros.dir/get.sh;;
-  esac
 }
 
 ## ---------------------------------------------------------------- ##
@@ -773,7 +823,7 @@ am_setup_testdir ()
     || framework_failure_ "cannot chdir into test subdirectory"
   if test x"$am_create_testdir" != x"empty"; then
     cp "$am_scriptdir"/install-sh "$am_scriptdir"/missing \
-       "$am_scriptdir"/depcomp . \
+       "$am_scriptdir"/compile "$am_scriptdir"/depcomp . \
       || framework_failure_ "fetching common files from $am_scriptdir"
     # Build appropriate environment in test directory.  E.g., create
     # configure.ac, touch all necessary files, etc.  Don't use AC_OUTPUT,
@@ -783,9 +833,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"
@@ -795,6 +845,6 @@ am_setup_testdir ()
 am_extra_info ()
 {
   echo "Running from installcheck: $am_running_installcheck"
-  echo "Using TAP: $am_using_tap"
+  echo "Test Protocol: $am_test_protocol"
   echo "PATH = $PATH"
 }