am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / aclocal-macrodir.tap
old mode 100755 (executable)
new mode 100644 (file)
index c35d9e0..4d11917
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2012 Free Software Foundation, Inc.
+# Copyright (C) 2012-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
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Several tests on the use of the m4 macro AC_CONFIG_MACRO_DIR with
-# aclocal.
+# aclocal.  See also related test 'aclocal-macrodir.tap'.
 
 am_create_testdir=empty
-. ./defs || exit 1
+. test-init.sh
 
-plan_ later
+plan_ 7
 
 ocwd=$(pwd) || fatal_ "getting current working directory"
-ACLOCAL_PATH=; unset ACLOCAL_PATH
+unset ACLOCAL_PATH
 
 #
 # General utility functions and variables.
@@ -44,6 +44,7 @@ test_begin ()
   else
     r=ok
     description=$1
+    directive=${2-}
     echo "$description" > README.txt
     shift
   fi
@@ -68,8 +69,6 @@ test_end ()
   fi
 }
 
-test_todo () { directive=TODO; }
-
 #---------------------------------------------------------------------------
 
 test_begin "AC_CONFIG_MACRO_DIR is honored"
@@ -158,4 +157,83 @@ test_end
 
 #---------------------------------------------------------------------------
 
+test_begin "AC_CONFIG_MACRO_DIR([non-existent]) warns with -Wunsupported"
+
+cat > configure.ac << 'END'
+AC_INIT([oops], [1.0])
+AC_CONFIG_MACRO_DIR([non-existent])
+AM_INIT_AUTOMAKE
+END
+
+$ACLOCAL -Wno-error 2>stderr \
+  && cat stderr >&2 \
+  && grep "couldn't open directory 'non-existent'" stderr \
+  && test -f aclocal.m4 \
+  || r='not ok'
+
+rm -rf aclocal.m4 autom4te*.cache
+
+$ACLOCAL -Werror -Wno-unsupported \
+  && test -f aclocal.m4 \
+  || r='not ok'
+
+test_end
+
+#---------------------------------------------------------------------------
+
+test_begin "AC_CONFIG_MACRO_DIR([not-exist]) and ACLOCAL_AMFLAGS = -I not-exist"
+
+cat > configure.ac << 'END'
+AC_INIT([oops], [1.0])
+AC_CONFIG_MACRO_DIR([not-exist])
+END
+
+cat > Makefile.am << 'END'
+ACLOCAL_AMFLAGS = -I not-exist
+END
+
+$ACLOCAL -Wno-error 2>stderr \
+  && cat stderr >&2 \
+  && test $(grep -c "couldn't open directory 'not-exist'" stderr) -eq 1 \
+  || r='not ok'
+
+test_end
+
+#---------------------------------------------------------------------------
+
+# Avoid spurious failures with pre-2.70 autoconf.
+# FIXME: remove this in automake 2.0, once we require Autoconf 2.70.
+if echo 'AC_INIT AC_CONFIG_MACRO_DIRS' | $AUTOCONF -o/dev/null -; then
+
+  test_begin "AC_CONFIG_MACRO_DIR interaction with AC_REQUIRE"
+
+  unindent > configure.ac <<'END'
+  AC_INIT([req], [1.0])
+  AC_CONFIG_MACRO_DIR([macro-dir])
+  AC_DEFUN([MY_FOO], [AC_REQUIRE([MY_BAR])])
+  MY_FOO
+END
+
+  mkdir macro-dir
+  echo 'AC_DEFUN([MY_BAR], [//my//bar//])' > macro-dir/x.m4
+
+  st=0; $ACLOCAL 2>stderr || st=$?
+  cat stderr >&2
+
+  test $st -eq 0 \
+    && test ! -s stderr \
+    && $FGREP 'm4_include([macro-dir/x.m4])' aclocal.m4 \
+    && $AUTOCONF \
+    && not $EGREP 'MY_(FOO|BAR)' configure \
+    && $FGREP '//my//bar//' configure \
+    || r='not ok'
+
+  test_end
+
+else
+
+  skip_ -r "autoconf is too old (AC_CONFIG_MACRO_DIRS not defined)"
+
+fi
+
 :