]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
python: extend and improve tests, fix minor glitches
authorStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 1 Feb 2011 22:22:08 +0000 (23:22 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 6 Feb 2011 17:33:33 +0000 (18:33 +0100)
* m4/python.m4 (AM_PATH_PYTHON): Ensure the "checking ..." messages
from configure are always complete, even in case of failure.  Tiny
cosmetic improvement in info/error messages.
* tests/python.test: Also check that automake complains if the
PYTHON primary is used but the `py-compile' script is not present.
Make grepping of generated Makefile.in laxer w.r.t. whitespace.
Add trailing `:' command.
* tests/python2.test: Remove repeated calls aclocal: they are
useless because configure.in is never modified.  Make grepping
of automake stderr more comprehensive.  Remove the pre-existing
`py-compile' file before trying to install it with `--add-missing'.
Add trailing `:' command.
* tests/python3.test: Add trailing `:' command.
* tests/python11.test: Likewise.
* tests/python4.test: Likewise.  Also, try to pass PYTHON config
variable to configure from the environment, rather than only from
the command line.
* tests/python5.test: Ensure that the "checking ..." messages from
configure are always complete.  Use proper m4 quoting.  Add a
trailing `:' command.
* tests/python6.test: Simplify test logic, by checking for files
created by configure rather then grepping its output.
* tests/python7.test: Likewise.
* tests/python8.test: Also check that `$PYTHON' is meaningfully
set in the ACTION-IF-TRUE argument of AM_PATH_PYTHON.
* tests/python9.test: Likewise.
* tests/python10.test: Add trailing `:' command.
(Makefile.am): Declare `disttest' target as `.PHONY', and add
an `ls -l' to its recipe, for debugging.
* tests/nobase-python.test: In testing "make uninstall" and
"make install" results, prefer idioms that make verbose logs
more helpful.  Remove a couple of lines of dead code.  Add a
trailing `:' command.
* tests/python5b.test: New test, checking that configure performs
the check on the python version even when the choice of the python
interpreter is forced by the user.
* tests/python-dist.test: New test, checking the distribution of
*_PYTHON files.
* tests/python-vars.test: New test, checking that AM_PATH_PYTHON
correctly set all the output variables advertised in the manual.
* tests/python-virtualenv.test: New test, checking that python
support offered by automake works well with "virtual python
environments" created by the `virtualenv' program.
* tests/instdir-prog.test: Also check `$(pyexecdir)'.  Existing
checks made slightly stricter.
* tests/instdir-prog.test: Also check `$(pyexecdir)'.  Existing
* tests/instdir-ltlib.test: Likewise.
* tests/Makefile.am (TESTS): Update.

22 files changed:
ChangeLog
m4/python.m4
tests/Makefile.am
tests/Makefile.in
tests/instdir-ltlib.test
tests/instdir-prog.test
tests/nobase-python.test
tests/python-dist.test [new file with mode: 0755]
tests/python-vars.test [new file with mode: 0755]
tests/python-virtualenv.test [new file with mode: 0755]
tests/python.test
tests/python10.test
tests/python11.test
tests/python2.test
tests/python3.test
tests/python4.test
tests/python5.test
tests/python5b.test [new file with mode: 0755]
tests/python6.test
tests/python7.test
tests/python8.test
tests/python9.test

index 31bdd667b068232830ff24d608da3d99d894100d..0df8d8e08daf051d6da41eff967153065f69f469 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,55 @@
+2011-02-06  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       python: extend and improve tests, fix minor glitches
+       * m4/python.m4 (AM_PATH_PYTHON): Ensure the "checking ..." messages
+       from configure are always complete, even in case of failure.  Tiny
+       cosmetic improvement in info/error messages.
+       * tests/python.test: Also check that automake complains if the
+       PYTHON primary is used but the `py-compile' script is not present.
+       Make grepping of generated Makefile.in laxer w.r.t. whitespace.
+       Add trailing `:' command.
+       * tests/python2.test: Remove repeated calls aclocal: they are
+       useless because configure.in is never modified.  Make grepping
+       of automake stderr more comprehensive.  Remove the pre-existing
+       `py-compile' file before trying to install it with `--add-missing'.
+       Add trailing `:' command.
+       * tests/python3.test: Add trailing `:' command.
+       * tests/python11.test: Likewise.
+       * tests/python4.test: Likewise.  Also, try to pass PYTHON config
+       variable to configure from the environment, rather than only from
+       the command line.
+       * tests/python5.test: Ensure that the "checking ..." messages from
+       configure are always complete.  Use proper m4 quoting.  Add a
+       trailing `:' command.
+       * tests/python6.test: Simplify test logic, by checking for files
+       created by configure rather then grepping its output.
+       * tests/python7.test: Likewise.
+       * tests/python8.test: Also check that `$PYTHON' is meaningfully
+       set in the ACTION-IF-TRUE argument of AM_PATH_PYTHON.
+       * tests/python9.test: Likewise.
+       * tests/python10.test: Add trailing `:' command.
+       (Makefile.am): Declare `disttest' target as `.PHONY', and add
+       an `ls -l' to its recipe, for debugging.
+       * tests/nobase-python.test: In testing "make uninstall" and
+       "make install" results, prefer idioms that make verbose logs
+       more helpful.  Remove a couple of lines of dead code.  Add a
+       trailing `:' command.
+       * tests/python5b.test: New test, checking that configure performs
+       the check on the python version even when the choice of the python
+       interpreter is forced by the user.
+       * tests/python-dist.test: New test, checking the distribution of
+       *_PYTHON files.
+       * tests/python-vars.test: New test, checking that AM_PATH_PYTHON
+       correctly set all the output variables advertised in the manual.
+       * tests/python-virtualenv.test: New test, checking that python
+       support offered by automake works well with "virtual python
+       environments" created by the `virtualenv' program.
+       * tests/instdir-prog.test: Also check `$(pyexecdir)'.  Existing
+       checks made slightly stricter.
+       * tests/instdir-prog.test: Also check `$(pyexecdir)'.  Existing
+       * tests/instdir-ltlib.test: Likewise.
+       * tests/Makefile.am (TESTS): Update.
+
 2011-02-01  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        coverage: more tests on simple and parallel test drivers
index 50e15384b0e72432fb12d54f0f5e86187589ea54..c341d5ce31da170d635944c1a3fb5116b2811e43 100644 (file)
@@ -51,10 +51,11 @@ AC_DEFUN([AM_PATH_PYTHON],
     dnl A version check is needed.
     if test -n "$PYTHON"; then
       # If the user set $PYTHON, use it and don't search something else.
-      AC_MSG_CHECKING([whether $PYTHON version >= $1])
+      AC_MSG_CHECKING([whether $PYTHON version is >= $1])
       AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
                              [AC_MSG_RESULT(yes)],
-                             [AC_MSG_ERROR(too old)])
+                             [AC_MSG_RESULT(no)
+                              AC_MSG_ERROR(Python interpreter is too old)])
       am_display_PYTHON=$PYTHON
     else
       # Otherwise, try each interpreter until we find one that satisfies
index c9f846753b115d1500d372666bb60ef07de32958..624d5b0d9563f0b55f27d41c7a3838ec6226b642 100644 (file)
@@ -620,6 +620,7 @@ python2.test \
 python3.test \
 python4.test \
 python5.test \
+python5b.test \
 python6.test \
 python7.test \
 python8.test \
@@ -627,6 +628,9 @@ python9.test \
 python10.test \
 python11.test \
 python12.test \
+python-dist.test \
+python-vars.test \
+python-virtualenv.test \
 recurs.test \
 recurs2.test \
 remake.test \
index 13704614056f02620cef23af211a1385409e8d60..5a039b48c6f9ffbbed39d38cd047b019bc1458c6 100644 (file)
@@ -890,6 +890,7 @@ python2.test \
 python3.test \
 python4.test \
 python5.test \
+python5b.test \
 python6.test \
 python7.test \
 python8.test \
@@ -897,6 +898,9 @@ python9.test \
 python10.test \
 python11.test \
 python12.test \
+python-dist.test \
+python-vars.test \
+python-virtualenv.test \
 recurs.test \
 recurs2.test \
 remake.test \
index 1fb4f37a89197c6238ad05b405171741d1d23020..b9fbed2d862fa043be8e9e20bfaff4b3fb7fa37b 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2009  Free Software Foundation, Inc.
+# Copyright (C) 2009, 2011 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
@@ -14,7 +14,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# If $(libdir) is the empty string, then nothing should be installed there.
+# If $(libdir) or $(pyexecdir) is the empty string, then nothing should
+# be installed there.
 # This test exercises the libtool code paths.
 
 required=libtoolize
@@ -26,6 +27,7 @@ cat >>configure.in <<'END'
 AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_LIBTOOL
+AM_PATH_PYTHON
 AC_OUTPUT
 END
 
@@ -37,6 +39,8 @@ bin_PROGRAMS = p
 nobase_bin_PROGRAMS = np sub/np
 lib_LTIBRARIES = libfoo.la
 nobase_lib_LTLIBRARIES = libnfoo.la sub/libnfoo.la
+pyexec_LTIBRARIES = libpy.la
+nobase_pyexec_LTLIBRARIES = libnpy.la sub/libnpy.la
 END
 
 cat >p.c <<'END'
@@ -47,6 +51,9 @@ cp p.c sub/np.c
 cp p.c libfoo.c
 cp p.c libnfoo.c
 cp p.c sub/libnfoo.c
+cp p.c libpy.c
+cp p.c libnpy.c
+cp p.c sub/libnpy.c
 
 libtoolize
 $ACLOCAL
@@ -57,11 +64,13 @@ instdir=`pwd`/inst
 destdir=`pwd`/dest
 mkdir build
 cd build
-../configure --prefix="$instdir"
+../configure --prefix="$instdir" PYTHON="echo" \
+             am_cv_python_pythondir="$instdir/python" \
+             am_cv_python_pyexecdir="$instdir/pyexec"
 $MAKE
 
-bindir= libdir=
-export bindir libdir
+bindir= libdir= pyexecdir=
+export bindir libdir pyexecdir
 $MAKE -e install
 test ! -d "$instdir"
 $MAKE -e install DESTDIR="$destdir"
@@ -69,6 +78,9 @@ test ! -d "$instdir"
 test ! -d "$destdir"
 $MAKE -e uninstall > stdout || { cat stdout; Exit 1; }
 cat stdout
-grep 'rm -f' stdout && Exit 1
-$MAKE -e uninstall DESTDIR="$destdir"
+grep 'rm ' stdout && Exit 1
+$MAKE -e uninstall DESTDIR="$destdir" > stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'rm ' stdout && Exit 1
+
 :
index 6a73b7572c98bbf3dd6a301d47745314e4a6f1e2..edd7c913ba6e7574bc74bb51a33e256fd7056897 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2009  Free Software Foundation, Inc.
+# Copyright (C) 2009, 2011 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
@@ -14,7 +14,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# If $(bindir) is the empty string, then nothing should be installed there.
+# If $(bindir), $(libdir) or $(pyexecdir) is the empty string, then
+# nothing should be installed there.
 # This test exercises the prog and libs code paths.
 
 . ./defs || Exit 1
@@ -25,6 +26,7 @@ cat >>configure.in <<'END'
 AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_RANLIB
+AM_PATH_PYTHON
 AC_OUTPUT
 END
 
@@ -36,6 +38,8 @@ bin_PROGRAMS = p
 nobase_bin_PROGRAMS = np sub/np
 lib_LIBRARIES = libfoo.a
 nobase_lib_LIBRARIES = libnfoo.a sub/libnfoo.a
+pyexec_PROGRAMS = py
+nobase_pyexec_PROGRAMS = npy sub/npy
 END
 
 cat >p.c <<'END'
@@ -46,6 +50,9 @@ cp p.c sub/np.c
 cp p.c libfoo.c
 cp p.c libnfoo.c
 cp p.c sub/libnfoo.c
+cp p.c py.c
+cp p.c npy.c
+cp p.c sub/npy.c
 
 $ACLOCAL
 $AUTOCONF
@@ -55,11 +62,13 @@ instdir=`pwd`/inst
 destdir=`pwd`/dest
 mkdir build
 cd build
-../configure --prefix="$instdir"
+../configure --prefix="$instdir" PYTHON="echo" \
+             am_cv_python_pythondir="$instdir/python" \
+             am_cv_python_pyexecdir="$instdir/pyexec"
 $MAKE
 
-bindir= libdir=
-export bindir libdir
+bindir= libdir= pyexecdir=
+export bindir libdir pyexecdir
 $MAKE -e install
 test ! -d "$instdir"
 $MAKE -e install DESTDIR="$destdir"
@@ -67,6 +76,9 @@ test ! -d "$instdir"
 test ! -d "$destdir"
 $MAKE -e uninstall > stdout || { cat stdout; Exit 1; }
 cat stdout
-grep 'rm -f' stdout && Exit 1
-$MAKE -e uninstall DESTDIR="$destdir"
+grep 'rm ' stdout && Exit 1
+$MAKE -e uninstall DESTDIR="$destdir" > stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'rm ' stdout && Exit 1
+
 :
index db5b8307623401c9f6e1d334faca321db285c4a2..c353019fc6701f13e2949ab568e2e08ad5bc4a7d 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2008  Free Software Foundation, Inc.
+# Copyright (C) 2008, 2011 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
@@ -32,6 +32,7 @@ my_PYTHON = one.py sub/base.py
 nobase_my_PYTHON = two.py sub/nobase.py
 
 test-install-data: install-data
+       find inst -print; : for debugging
        test   -f inst/my/one.py
        test   -f inst/my/one.pyc
        test   -f inst/my/two.py
@@ -55,16 +56,13 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
 
-mkdir inst
-inst=`pwd`/inst
-
 ./configure --prefix "`pwd`/inst" --program-prefix=p
 
 $MAKE
 $MAKE test-install-data
 $MAKE uninstall
 
-test `find inst/my -type f -print | wc -l` = 0
+find inst/my -type f -print | grep . && Exit 1
 
 $MAKE install-strip
 
@@ -78,4 +76,6 @@ cd build
 $MAKE
 $MAKE test-install-data
 $MAKE uninstall
-test `find inst/my -type f -print | wc -l` = 0
+find inst/my -type f -print | grep . && Exit 1
+
+:
diff --git a/tests/python-dist.test b/tests/python-dist.test
new file mode 100755 (executable)
index 0000000..fbf3ca5
--- /dev/null
@@ -0,0 +1,80 @@
+#! /bin/sh
+# Copyright (C) 2011 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
+# the Free Software Foundation; either version 2, 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, see <http://www.gnu.org/licenses/>.
+
+# Test distribution of *_PYTHON files.
+
+# This test does not require python.
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AM_PATH_PYTHON([], [:], [:])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+python_PYTHON = python.py
+dist_python_PYTHON = python-dist.py
+nodist_python_PYTHON = python-nodist.py
+
+pkgpython_PYTHON = pkgpython.py
+dist_pkgpython_PYTHON = pkgpython-dist.py
+nodist_pkgpython_PYTHON = pkgpython-nodist.py
+
+mydir = $(prefix)/my
+my_PYTHON = my.py
+dist_my_PYTHON = my-dist.py
+nodist_my_PYTHON = my-nodist.py
+
+my.py my-dist.py my-nodist.py:
+       : > $@
+
+.PHONY: disttest
+disttest: distdir
+       ls -l $(distdir)
+       test -f $(distdir)/python.py
+       test -f $(distdir)/python-dist.py
+       test ! -f $(distdir)/python-nodist.py
+       test -f $(distdir)/pkgpython.py
+       test -f $(distdir)/pkgpython-dist.py
+       test ! -f $(distdir)/pkgpython-nodist.py
+       test -f $(distdir)/my.py
+       test -f $(distdir)/my-dist.py
+       test ! -f $(distdir)/my-nodist.py
+END
+
+: > python.py
+: > python-dist.py
+: > python-nodist.py
+
+: > pkgpython.py
+: > pkgpython-dist.py
+: > pkgpython-nodist.py
+
+: > py-compile
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE disttest
+# It's not distributed, hence it shouldn't be needlessly generated.
+test ! -f my-nodist.py
+
+:
diff --git a/tests/python-vars.test b/tests/python-vars.test
new file mode 100755 (executable)
index 0000000..ad263a5
--- /dev/null
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2011 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
+# the Free Software Foundation; either version 2, 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, see <http://www.gnu.org/licenses/>.
+
+# Check that AM_PATH_PYTHON correctly sets all the output variables
+# advertised in the manual.
+
+required=python
+. ./defs || Exit 1
+
+set -e
+
+PYTHON=python
+
+# Update these if the documentation changes.
+PYTHON_VERSION=`$PYTHON -c 'import sys; print(sys.version[:3])'` || Exit 1
+PYTHON_PLATFORM=`$PYTHON -c 'import sys; print(sys.platform)'` || Exit 1
+PYTHON_EXEC_PREFIX='${exec_prefix}'
+PYTHON_PREFIX='${prefix}'
+pythondir="\${prefix}/lib/python$PYTHON_VERSION/site-packages"
+pyexecdir="\${exec_prefix}/lib/python$PYTHON_VERSION/site-packages"
+pkgpythondir="\${pythondir}/$me"
+pkgpyexecdir="\${pyexecdir}/$me"
+
+pyvars='PYTHON_VERSION PYTHON_PLATFORM PYTHON_PREFIX PYTHON_EXEC_PREFIX
+        pythondir pyexecdir pkgpythondir pkgpyexecdir'
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([vars-got])
+AM_PATH_PYTHON
+AC_OUTPUT
+END
+
+cat > my.py << 'END'
+def my():
+    return 1
+END
+
+cat > Makefile.am << 'END'
+
+python_PYTHON = my.py
+
+EXTRA_DIST = vars-exp
+
+check-local: test-in test-am
+.PHONY: test-in test-am
+
+test-in:
+       cat $(srcdir)/vars-exp
+       cat $(builddir)/vars-got
+       diff $(srcdir)/vars-exp $(builddir)/vars-got
+END
+
+echo > vars-exp
+echo > vars-got.in
+echo test-am: >> Makefile.am
+
+for var in $pyvars; do
+  eval val=\$$var
+  (echo "### $var ###" && echo "$val" && echo) >> vars-exp
+  (echo "### $var ###" && echo "@$var@" && echo) >> vars-got.in
+  echo "${tab}test x'\$($var)' = x'$val'" >> Makefile.am
+done
+
+cat Makefile.am
+cat vars-got.in
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+for var in $pyvars; do
+  grep "^$var *=" Makefile.in
+done
+
+$AUTOCONF
+./configure PYTHON="$PYTHON"
+
+$MAKE test-in test-am
+$MAKE distcheck
+
+:
diff --git a/tests/python-virtualenv.test b/tests/python-virtualenv.test
new file mode 100755 (executable)
index 0000000..478a8dc
--- /dev/null
@@ -0,0 +1,183 @@
+#! /bin/sh
+# Copyright (C) 2011 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
+# the Free Software Foundation; either version 2, 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, see <http://www.gnu.org/licenses/>.
+
+# Check that python support can work well with virtualenvs.
+# This test also works as a mild stress-test on the python support.
+
+required=virtualenv
+. ./defs || Exit 1
+
+set -e
+
+# Skip the test if a proper virtualenv cannot be created.
+virtualenv --verbose virtenv || Exit 77
+test -f virtenv/bin/activate || Exit 77
+
+# Activate the virtualenv.
+. ./virtenv/bin/activate
+# Sanity check.
+test -n "$VIRTUAL_ENV" || Exit 99
+
+cwd=`pwd`
+py_version=`python -c 'import sys; print("%u.%u" % tuple(sys.version_info[:2]))'`
+py_site=$VIRTUAL_ENV/lib/python$py_version/site-packages
+
+# We need control over the package name.
+cat > configure.in << END
+AC_INIT([am_virtenv], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_SUBST([MY_VIRTENV], ['$cwd/virtenv'])
+AC_PROG_CC
+AC_PROG_RANLIB
+AM_PATH_PYTHON
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+python_PYTHON = am_foo.py
+pkgpython_PYTHON = __init__.py
+pyexec_LIBRARIES = libquux.a
+libquux_a_SOURCES = foo.c
+pkgpyexec_LIBRARIES = libzardoz.a
+libzardoz_a_SOURCES = foo.c
+
+py_site = $(MY_VIRTENV)/lib/python$(PYTHON_VERSION)/site-packages
+
+.PYTHON: debug test-run test-install test-uninstall
+debug:
+       @echo PYTHON: $(PYTHON)
+       @echo PYTHON_VERSION: $(PYTHON_VERSION)
+       @echo prefix: $(prefix)
+       @echo pythondir: $(pythondir)
+       @echo pkgpythondir: $(pkgpythondir)
+       @echo pyexecdir: $(pyexecdir)
+       @echo pkgpyexecdir: $(pkgpyexecdir)
+test-run:
+       ## In a virtualenv, the default python must be the custom
+       ## virtualenv python.
+       @: \
+         && py1=`python -c 'import sys; print(sys.executable)'` \
+         && py2=`$(PYTHON) -c 'import sys; print(sys.executable)'` \
+         && echo "py1: $$py1" \
+         && echo "py2: $$py2" \
+         && test -n "$$py1" \
+         && test -n "$$py2" \
+         && test x"$$py1" = x"$$py2"
+       ## Check that modules installed in the virtualenv are readily
+       ## available.
+       python -c 'from am_foo import foo_func; assert (foo_func () == 12345)'
+       python -c 'from am_virtenv import old_am; assert (old_am () == "AutoMake")'
+test-install:
+       test -f $(py_site)/am_foo.py
+       test -f $(py_site)/am_foo.pyc
+       test -f $(py_site)/am_foo.pyo
+       test -f $(py_site)/am_virtenv/__init__.py
+       test -f $(py_site)/am_virtenv/__init__.pyc
+       test -f $(py_site)/am_virtenv/__init__.pyo
+       test -f $(py_site)/libquux.a
+       test -f $(py_site)/am_virtenv/libzardoz.a
+test-uninstall:
+       test ! -f $(py_site)/am_foo.py
+       test ! -f $(py_site)/am_foo.pyc
+       test ! -f $(py_site)/am_foo.pyo
+       test ! -f $(py_site)/am_virtenv/__init__.py
+       test ! -f $(py_site)/am_virtenv/__init__.pyc
+       test ! -f $(py_site)/am_virtenv/__init__.pyo
+       test ! -f $(py_site)/libquux.a
+       test ! -f $(py_site)/am_virtenv/libzardoz.a
+all-local: debug
+END
+
+cat > am_foo.py << 'END'
+def foo_func ():
+    return 12345
+END
+
+cat > __init__.py << 'END'
+def old_am ():
+    return 'AutoMake'
+END
+
+cat > foo.c << 'END'
+int foo (void)
+{
+  return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# Try a VPATH build.
+mkdir build
+cd build
+../configure --prefix="$VIRTUAL_ENV"
+$MAKE install
+$MAKE test-install
+$MAKE test-run
+$MAKE uninstall
+$MAKE test-uninstall
+cd ..
+
+# Try an in-tree build.
+./configure --prefix="$VIRTUAL_ENV"
+$MAKE install
+$MAKE test-install
+$MAKE test-run
+$MAKE uninstall
+$MAKE test-uninstall
+
+$MAKE distclean
+
+# Overriding pythondir and pyexecdir with cache variables should work.
+./configure am_cv_python_pythondir="$py_site" \
+            am_cv_python_pyexecdir="$py_site"
+$MAKE install
+$MAKE test-install
+$MAKE test-run
+$MAKE uninstall
+$MAKE test-uninstall
+
+$MAKE distclean
+
+# Overriding pythondir and pyexecdir at make time should be enough.
+./configure --prefix="$cwd/bad-prefix"
+pythondir=$py_site pyexecdir=$py_site
+export pythondir pyexecdir
+$MAKE -e install
+test ! -d bad-prefix
+$MAKE -e test-install
+$MAKE test-run
+$MAKE -e uninstall
+$MAKE -e test-uninstall
+unset pythondir pyexecdir
+
+# Also check that the distribution is self-contained, for completeness.
+$MAKE distcheck
+
+# Finally, check that if we disable the virtualenv, we shouldn't be
+# able to access to the installed modules anymore.
+cd build
+$MAKE install
+python -c 'import am_foo; print(am_foo.__file__)'
+python -c 'import am_virtenv; print(am_virtenv.__file__)'
+deactivate "nondestructive"
+python -c 'import am_foo' && Exit 1
+python -c 'import am_virtenv' && Exit 1
+
+:
index 8102ca002203e496487fc7f407fdb8765d13c6c2..e44ceb533ba671a96cc2ca3dcb9e8f0e8a4b23bb 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2001, 2002  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2011 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
@@ -27,7 +27,12 @@ python_PYTHON = foo.py
 END
 
 $ACLOCAL
-$AUTOMAKE -a
 
-grep '^py_compile =' Makefile.in
+AUTOMAKE_fails
+grep '^Makefile\.am:1:.* required file.*py-compile' stderr
+
+$AUTOMAKE -a
+grep '^py_compile *=' Makefile.in
 test -f py-compile
+
+:
index ff0ee151a912af1a67e7c64b140f5c050c9df887..16566fccae41f2c582812aa6bdedc793a8a7d307 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2004, 2007  Free Software Foundation, Inc.
+# Copyright (C) 2004, 2007, 2011 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
@@ -41,7 +41,9 @@ one.py:
 two.py:
        echo 'def two(): return 1' >$@
 
+.PHONY: disttest
 disttest: distdir
+       ls -l $(distdir)
        test -f $(distdir)/one.py
        test -f $(distdir)/two.py
 END
@@ -81,3 +83,5 @@ test ! -f "$inst/my/one.pyc"
 test ! -f "$inst/my/one.pyo"
 
 $MAKE disttest
+
+:
index 0f15f375f08150a29a1a8724a28e188db8f943f5..f0386be44b11c998c646cbb564ff2b3905639f58 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2004, 2006, 2008  Free Software Foundation, Inc.
+# Copyright (C) 2004, 2006, 2008, 2011 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
@@ -53,3 +53,5 @@ $AUTOCONF
 ./configure PYTHON=foo >stdout && { cat stdout; Exit 1; }
 cat stdout
 grep 'PYTHON = foo' stdout
+
+:
index 3e14fa2b588fb4caeb120fddf738e69ce153c583..d2ace1f421c2f5d336f33cfcaf152d0e44915b8d 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2002, 2003, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2010, 2011 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
@@ -20,6 +20,8 @@
 
 set -e
 
+$ACLOCAL
+
 
 echo 1. pythondir not defined
 
@@ -28,8 +30,8 @@ PYTHON = x
 python_PYTHON = foo.py
 END
 
-$ACLOCAL
 AUTOMAKE_fails -a
+grep 'pythondir.*undefined' stderr
 grep AM_PATH_PYTHON stderr
 
 
@@ -40,8 +42,8 @@ PYTHON = x
 pkgpython_PYTHON = foo.py
 END
 
-$ACLOCAL
 AUTOMAKE_fails -a
+grep 'pkgpythondir.*undefined' stderr
 grep AM_PATH_PYTHON stderr
 
 
@@ -52,8 +54,8 @@ PYTHON = x
 pyexec_PYTHON = foo.py
 END
 
-$ACLOCAL
 AUTOMAKE_fails -a
+grep 'pyexecdir.*undefined' stderr
 grep AM_PATH_PYTHON stderr
 
 
@@ -64,8 +66,8 @@ PYTHON = x
 pkgpyexec_PYTHON = foo.py
 END
 
-$ACLOCAL
 AUTOMAKE_fails -a
+grep 'pkgpyexecdir.*undefined' stderr
 grep AM_PATH_PYTHON stderr
 
 
@@ -76,8 +78,8 @@ pkgpyexecdir = /here/we/go
 pkgpyexec_PYTHON = foo.py
 END
 
-$ACLOCAL
 AUTOMAKE_fails -a
+grep 'PYTHON.*undefined' stderr
 grep AM_PATH_PYTHON stderr
 
 
@@ -89,7 +91,7 @@ pkgpyexecdir = /here/we/go
 pkgpyexec_PYTHON = foo.py
 END
 
-$ACLOCAL
+rm -f py-compile
 $AUTOMAKE -a
 test -f py-compile
 
@@ -102,5 +104,6 @@ fubardir = /here/we/go
 fubar_PYTHON = foo.py
 END
 
-$ACLOCAL
 $AUTOMAKE -a
+
+:
index f01ad3108ae5d46250e3c7be132b02419238862a..91e398931a2da5f029357d28360f51c9b6a73aee 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2002, 2007  Free Software Foundation, Inc.
+# Copyright (C) 2002, 2007, 2011 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
@@ -47,3 +47,5 @@ $MAKE install
 test -f "$inst/my/one.py"
 test -f "$inst/my/one.pyc"
 test -f "$inst/my/one.pyo"
+
+:
index 11bb3ed8497a7f428958fac83b4440ec403ce4cc..b201e0596b65415dfe36c70a97cc5c5b2bc78e04 100755 (executable)
@@ -32,7 +32,14 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
 
-# Simulate no Python
+# Simulate no Python.
 ./configure PYTHON=: 2>stderr && { cat stderr >&2; Exit 1; }
 cat stderr >&2
 grep 'no suitable Python interpreter found' stderr
+
+# Again, but from the environment this time.
+env PYTHON=: ./configure 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'no suitable Python interpreter found' stderr
+
+:
index 86f5863418152a523c245ed37f6a3d1a3d24401f..a4c2b403109aa964a631ba4a4cb6cda130793b45 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2003, 2008  Free Software Foundation, Inc.
+# Copyright (C) 2003, 2008, 2011 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
@@ -24,7 +24,7 @@ set -e
 
 cat >>configure.in <<EOF
 # Hopefully the Python team will never release such a version.
-AM_PATH_PYTHON(9999.9)
+AM_PATH_PYTHON([9999.9])
 AC_OUTPUT
 EOF
 
@@ -34,6 +34,14 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
 
-./configure 2>stderr && { cat stderr >&2; Exit 1; }
+./configure >stdout 2>stderr && { 
+  cat stdout
+  cat stderr >&2
+  Exit 1
+}
+cat stdout
 cat stderr >&2
+$EGREP 'checking for a Python interpreter with version >= 9999\.9\.\.\. no(ne)? *$' stdout
 grep 'no suitable Python interpreter found' stderr
+
+:
diff --git a/tests/python5b.test b/tests/python5b.test
new file mode 100755 (executable)
index 0000000..7f77cda
--- /dev/null
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2003, 2008, 2011 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
+# the Free Software Foundation; either version 2, 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, see <http://www.gnu.org/licenses/>.
+
+# Test detection of missing Python.
+# Same as python5.test, but with the user forcing the python to use.
+
+required=python
+. ./defs || Exit 1
+
+set -e
+
+cat >>configure.in << 'END'
+# Hopefully the Python team will never release such a version.
+AM_PATH_PYTHON([9999.9])
+AC_OUTPUT
+END
+
+mkdir bin
+cat > bin/my-python << 'END'
+#! /bin/sh
+exec python ${1+"$@"}
+END
+chmod a+x bin/my-python
+PATH=`pwd`/bin:$PATH_SEPARATOR$PATH
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure PYTHON=my-python >stdout 2>stderr && {
+  cat stdout
+  cat stderr >&2
+  Exit 1
+}
+cat stdout
+cat stderr >&2
+grep 'whether my-python version is >= 9999\.9\.\.\. no *$' stdout
+grep '[Pp]ython interpreter is too old' stderr
+
+:
index 86dcfbba729d5adb7067374e36e366ee3d036254..117448aea57afb485d12dcd3816ac1a2595596e9 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2003, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2010, 2011 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
@@ -23,7 +23,7 @@
 set -e
 
 cat >>configure.in <<\EOF
-AM_PATH_PYTHON(,, [echo "GREP ME$PYTHON" >&2])
+AM_PATH_PYTHON(,, [echo "$PYTHON" > py])
 AC_OUTPUT
 EOF
 
@@ -33,9 +33,8 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
 
-# Simulate no Python
-./configure PYTHON=: 2>stderr || { cat stderr >&2; Exit 1; }
-cat stderr >&2
-grep 'GREP ME:' stderr
+# Simulate no Python.
+./configure PYTHON=:
+test x"`cat py`" = x:
 
 :
index 27b2e7966d214f19d614e245dbf3e4ee480e5d2e..b74dc9b2be512172eec35ae6a02cff3b9a2524d7 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2003, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2010, 2011 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
@@ -24,7 +24,7 @@ set -e
 
 cat >>configure.in <<\EOF
 # Hopefully the Python team will never release such a version.
-AM_PATH_PYTHON(9999.9,, [echo "GREP ME$PYTHON" >&2])
+AM_PATH_PYTHON([9999.9], [], [echo "$PYTHON" > py])
 AC_OUTPUT
 EOF
 
@@ -34,8 +34,7 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
 
-./configure 2>stderr || { cat stderr >&2; Exit 1; }
-cat stderr >&2
-grep 'GREP ME:' stderr
+./configure
+test x"`cat py`" = x:
 
 :
index 51d02ad9b7f1d30080b4b3d3b838c0142cfbba78..cd87a51785e7c9625f5725504aaf30de054b8349 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2003, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2010, 2011 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
@@ -21,8 +21,9 @@ required=python
 
 set -e
 
-cat >>configure.in <<EOF
-AM_PATH_PYTHON(, [echo 'GREP ME' >&2])
+cat >>configure.in <<'EOF'
+# $PYTHON is supposed to be properly set in ACTION-IF-TRUE.
+AM_PATH_PYTHON(, [$PYTHON -V >py-version 2>&1])
 AC_OUTPUT
 EOF
 
@@ -32,8 +33,7 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
 
-./configure 2>stderr || { cat stderr >&2; Exit 1; }
-cat stderr >&2
-grep 'GREP ME' stderr
+./configure
+grep '^Python [0-9]\.[0-9][0-9]*\.[0-9]' py-version
 
 :
index 6a91e9fee9663b132bf2fba84aaf4f97f008c611..71588f8bfd65aaad9b67325c7df038a90d264886 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2003, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2010, 2011 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/>.
 
 # Test ACTION-IF-TRUE in AM_PATH_PYTHON.
-# Same as python8.test, but requiring a version.
+# Similar to python8.test, but requiring a version.
 
 required=python
 . ./defs || Exit 1
 
 set -e
 
-cat >>configure.in <<EOF
-AM_PATH_PYTHON(0.0, [echo 'GREP ME' >&2])
+cat >>configure.in <<'EOF'
+# $PYTHON is supposed to be properly set in ACTION-IF-TRUE.
+AM_PATH_PYTHON([0.0], [$PYTHON -c 'print("%u:%u" % (1-1, 2**0))' > py.out])
 AC_OUTPUT
 EOF
 
@@ -33,8 +34,7 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
 
-./configure 2>stderr || { cat stderr >&2; Exit 1; }
-cat stderr >&2
-grep 'GREP ME' stderr
+./configure
+test x"`cat py.out`" = x0:1
 
 :