[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches
From: |
Stefano Lattarini |
Subject: |
Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches |
Date: |
Sun, 6 Feb 2011 18:32:56 +0100 |
User-agent: |
KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; ) |
On Thursday 03 February 2011, Ralf Wildenhues wrote:
> Hi Stefano,
>
Hello Ralf, and sorry for the delay.
> * Stefano Lattarini wrote on Wed, Feb 02, 2011 at 12:10:15AM CET:
> > A testsuite-enhancement patch stemmed from my brief foray into
> > Automake's python support. This patch is in small part cosmetic,
> > but IMHO offers real improvements and valuable additions, and
> > also fixes a couple of glitches in python.m4.
>
> OK for master (branched off of maint, if you prefer) with nits
> addressed.
>
> Before pushing, please test on a system without a python interpreter
> installed (you can rename you pythons temporarily).
>
Nah, IMHO is better to do something like:
$ cd ~/src/automake/tests
$ mkdir xbin && cd xbin
$ for f in /bin/* /usr/bin/* /usr/local/bin/*; do
> case $f in *python*);; *) ln -s $f .;; esac
> done
$ cd ..
$ PATH=`pwd`/xbin make check TESTS='...'
BTW, following your advice, I have uncovered a bug in python-dist.test.
Fixed in the attached squash-in.
> Sorry for the absence of other reviews, I'll try to make room for some
> one of the next weekends.
>
> Thanks,
> Ralf
>
> > Subject: [PATCH] python: extend and improve tests, fix minor glitches
> >
> > * tests/python-virtualenv.test: New test, checking that python
> > support offered by automake works well with virtualenvs.
>
> What is virtualenvs?
>
"virtual python environments" created by the 'virtualenv' program. I
fixed the ChangeLog entry to be more precise (see attached squash-in).
> > * tests/instdir-pyexec.test: New, sister of `instdir-python.test',
> > but checking `$(pyexecdir)' instead of `$(pythondir)'.
> > * tests/Makefile.am (TESTS): Update.
>
> > --- a/m4/python.m4
> > +++ b/m4/python.m4
> > @@ -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
>
> > --- /dev/null
> > +++ b/tests/instdir-pyexec.test
>
> > +# If $(pyexecdir) is the empty string, then nothing should be installed
> > +# there.
>
> This could just be checked in instdir-prog.test.
>
Right, done. And similarly for `instdir-ltlib.test'. And I've
obviously removed the test `instdir-pyexec.test'.
> And a no-contents version in instdir.test, analogously to the rest.
>
Hmm... I see that this test lacks entries for the PROGRAMS, LIBRARIES
and LTLIBRARIES primaries. Is this deliberate? Should that be fixed
in a follow-up patch? For the moment, I've not touched this test.
> > --- /dev/null
> > +++ b/tests/python-vars.test
>
> > +# Check that AM_PATH_PYTHON correctly set all the output variables
>
> sets
>
Fixed.
> > +# 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
>
> Please check this code with some versions of both python 2 and python 3.
>
Done. It works.
> > +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
>
> test-am:
>
OK.
> > +END
> > +
> > +echo > vars-exp
> > +echo > vars-got.in
> > +echo test-am: >> Makefile.am
>
> and then delete this line.
>
OK.
> > +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
>
> > --- /dev/null
> > +++ b/tests/python-virtualenv.test
>
> > +# Check that python support can work well with virtualenvs.
> > +# This test also works as a mild stress-test on the python support.
> > +
> > +. ./defs || Exit 1
> > +
> > +set -e
> > +
> > +# Skip the test if a proper virtualenv cannot be created.
> > +virtualenv --version || Exit 77
> > +virtualenv --verbose virtenv || Exit 77
> > +test -f virtenv/bin/activate || Exit 77
>
> required=virtualenv ?
>
Good point. Done.
> > +# 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]))'`
>
> Ditto (testing with python{2,3}).
>
Done. It works.
> > +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
> > +
> > +
I've removed the extra blank line here (it was there only for a mistake).
> > +# 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
>
> > --- a/tests/python.test
> > +++ b/tests/python.test
>
> > @@ -20,14 +20,21 @@
> >
> > set -e
> >
> > -echo 'AM_PATH_PYTHON' >> configure.in
> > +cat >> configure.in << 'END'
> > +AM_PATH_PYTHON
> > +END
>
> No, please please no more of these kinds of changes ever more.
> Especially since you violate your own coding "standard" in above
> new tests. Thanks.
>
OK, reverted this hunk.
> > cat > Makefile.am << 'END'
> > 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
> > --- a/tests/python2.test
> > +++ b/tests/python2.test
>
> > @@ -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
>
> These changes will make the test less resilient against changes to
> python.m4. I like the increased coverage but the increased brittleness
> of the test is somewhat of a downer. Hmm.
>
Would you maybe like a more lax regexp, e.g.:
$EGREP 'pythondir.*(un|not )defined' stderr
or even:
$EGREP 'pythondir.*(un|not )defined|define.*pythondir' stderr
But IMHO this would be overkill, as changing the test in case the error
messages are modifed should be a no-brainer. For the moment, I've not
touched this hunk (nor the similar ones below).
> > 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
> > --- a/tests/python5.test
> > +++ b/tests/python5.test
>
> > @@ -24,16 +24,32 @@ 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])
>
> Nice that you do it here, but up in python.m4 you should then, too.
>
Definitely. But in a follow-up patch IMHO (and since we are at it, we
should fix underquoting in all the other *.m4 automake files). I will
submit this patch in the coming week.
> > AC_OUTPUT
> > EOF
> >
> > +mkdir bin
> > +cat > bin/python <<EOF
> > +#! /bin/sh
> > +exit 1
> > +EOF
> > +chmod a+x bin/python
> > +PATH=`pwd`/bin:$PATH_SEPARATOR$PATH
>
> Superfluous colon.
>
> What is this bin/python script for? It seems wrong here. Please omit
> it.
>
Hmm... Yes, it seems to be really useless. Probably a leftover from a
previous version of the present patch. Removed.
> > : > Makefile.am
> >
> > $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
> > --- /dev/null
> > +++ b/tests/python5b.test
>
> > +# 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 && {
>
> trailing whitespace
>
Oops. Fixed.
> > + 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
> > --- a/tests/python6.test
> > +++ b/tests/python6.test
>
> > @@ -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":"
>
> A colon doesn't need quoting.
>
True, but it doesn't hurt either, and IMVHO improves consistency.
Bikeshedding anyway, so I'll simply remove it.
> The cat py output doesn't either,
> so this can just be
> test x`cat py` = x:
>
Hmmm... but why make the test less reliable in face of possible "weird"
failures (in case, let's say, PYTHON gets erroneously redfined to ': ',
note the trailing space)?
For the moment, I've kept the quotes around `cat py`.
>
> > --- a/tests/python7.test
> > +++ b/tests/python7.test
>
> > @@ -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":"
>
> See above.
>
Likewise.
> > --- a/tests/python9.test
> > +++ b/tests/python9.test
>
> > @@ -15,15 +15,16 @@
> > # 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`" = x'0:1'
>
> See above.
>
Likewise.
-*-*-*-
Attached is what I've squashed into the previous version of the patch.
I will push in 72 hours if there are no further objections.
Thanks,
Stefano
diff --git a/ChangeLog b/ChangeLog
index 482226c..0df8d8e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,4 @@
-2011-02-02 Stefano Lattarini <address@hidden>
+2011-02-06 Stefano Lattarini <address@hidden>
python: extend and improve tests, fix minor glitches
* m4/python.m4 (AM_PATH_PYTHON): Ensure the "checking ..." messages
@@ -7,7 +7,6 @@
* 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.
- Prefer `cat' over `echo' to append to the generated configure.in.
Add trailing `:' command.
* tests/python2.test: Remove repeated calls aclocal: they are
useless because configure.in is never modified. Make grepping
@@ -43,9 +42,12 @@
* 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 virtualenvs.
- * tests/instdir-pyexec.test: New, sister of `instdir-python.test',
- but checking `$(pyexecdir)' instead of `$(pythondir)'.
+ 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 <address@hidden>
diff --git a/tests/Makefile.am b/tests/Makefile.am
index db9889c..624d5b0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -400,7 +400,6 @@ instdir-lisp.test \
instdir-ltlib.test \
instdir-prog.test \
instdir-python.test \
-instdir-pyexec.test \
instdir-texi.test \
instexec.test \
instfail.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index c18ede8..5a039b4 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -670,7 +670,6 @@ instdir-lisp.test \
instdir-ltlib.test \
instdir-prog.test \
instdir-python.test \
-instdir-pyexec.test \
instdir-texi.test \
instexec.test \
instfail.test \
diff --git a/tests/instdir-ltlib.test b/tests/instdir-ltlib.test
index 1fb4f37..b9fbed2 100755
--- a/tests/instdir-ltlib.test
+++ b/tests/instdir-ltlib.test
@@ -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
+
:
diff --git a/tests/instdir-prog.test b/tests/instdir-prog.test
index 6a73b75..edd7c91 100755
--- a/tests/instdir-prog.test
+++ b/tests/instdir-prog.test
@@ -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
+
:
diff --git a/tests/instdir-pyexec.test b/tests/instdir-pyexec.test
deleted file mode 100755
index 3d3ac96..0000000
--- a/tests/instdir-pyexec.test
+++ /dev/null
@@ -1,67 +0,0 @@
-#! /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/>.
-
-# If $(pyexecdir) is the empty string, then nothing should be installed
-# there.
-
-. ./defs || Exit 1
-
-set -e
-
-cat >>configure.in <<'END'
-AM_PATH_PYTHON
-AC_PROG_CC
-AC_OUTPUT
-END
-
-cat >Makefile.am <<'END'
-pyexec_PROGRAMS = foo
-END
-
-cat >foo.c <<'END'
-int main (void)
-{
- return 0;
-}
-END
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE
-
-cwd=`pwd`
-instdir=$cwd/inst
-destdir=$cwd/dest
-mkdir build
-cd build
-../configure --prefix="$instdir"
-$MAKE
-
-pyexecdir=''; export pyexecdir
-
-$MAKE -e install
-test ! -d "$instdir"
-$MAKE -e install DESTDIR="$destdir"
-test ! -d "$instdir"
-test ! -d "$destdir"
-$MAKE -e uninstall > stdout || { cat stdout; Exit 1; }
-cat stdout
-grep 'rm ' stdout && Exit 1
-$MAKE -e uninstall DESTDIR="$destdir" > stdout || { cat stdout; Exit 1; }
-cat stdout
-grep 'rm ' stdout && Exit 1
-
-:
diff --git a/tests/python-dist.test b/tests/python-dist.test
index 1ddb476..fbf3ca5 100755
--- a/tests/python-dist.test
+++ b/tests/python-dist.test
@@ -22,7 +22,7 @@
set -e
cat >> configure.in << 'END'
-AM_PATH_PYTHON
+AM_PATH_PYTHON([], [:], [:])
AC_OUTPUT
END
diff --git a/tests/python-vars.test b/tests/python-vars.test
index b6c5d2c..ad263a5 100755
--- a/tests/python-vars.test
+++ b/tests/python-vars.test
@@ -14,7 +14,7 @@
# 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 set all the output variables
+# Check that AM_PATH_PYTHON correctly sets all the output variables
# advertised in the manual.
required=python
diff --git a/tests/python-virtualenv.test b/tests/python-virtualenv.test
index fcef00d..478a8dc 100755
--- a/tests/python-virtualenv.test
+++ b/tests/python-virtualenv.test
@@ -17,12 +17,12 @@
# 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 --version || Exit 77
virtualenv --verbose virtenv || Exit 77
test -f virtenv/bin/activate || Exit 77
@@ -170,7 +170,6 @@ 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
diff --git a/tests/python.test b/tests/python.test
index 7e90844..e44ceb5 100755
--- a/tests/python.test
+++ b/tests/python.test
@@ -20,9 +20,7 @@
set -e
-cat >> configure.in << 'END'
-AM_PATH_PYTHON
-END
+echo 'AM_PATH_PYTHON' >> configure.in
cat > Makefile.am << 'END'
python_PYTHON = foo.py
diff --git a/tests/python5.test b/tests/python5.test
index 87c7787..a4c2b40 100755
--- a/tests/python5.test
+++ b/tests/python5.test
@@ -28,14 +28,6 @@ AM_PATH_PYTHON([9999.9])
AC_OUTPUT
EOF
-mkdir bin
-cat > bin/python <<EOF
-#! /bin/sh
-exit 1
-EOF
-chmod a+x bin/python
-PATH=`pwd`/bin:$PATH_SEPARATOR$PATH
-
: > Makefile.am
$ACLOCAL
diff --git a/tests/python5b.test b/tests/python5b.test
index d9aeb81..7f77cda 100755
--- a/tests/python5b.test
+++ b/tests/python5b.test
@@ -42,7 +42,7 @@ $ACLOCAL
$AUTOCONF
$AUTOMAKE --add-missing
-./configure PYTHON=my-python >stdout 2>stderr && {
+./configure PYTHON=my-python >stdout 2>stderr && {
cat stdout
cat stderr >&2
Exit 1
diff --git a/tests/python6.test b/tests/python6.test
index f42ad6b..117448a 100755
--- a/tests/python6.test
+++ b/tests/python6.test
@@ -35,6 +35,6 @@ $AUTOMAKE --add-missing
# Simulate no Python.
./configure PYTHON=:
-test x"`cat py`" = x":"
+test x"`cat py`" = x:
:
diff --git a/tests/python7.test b/tests/python7.test
index 1457ed1..b74dc9b 100755
--- a/tests/python7.test
+++ b/tests/python7.test
@@ -35,6 +35,6 @@ $AUTOCONF
$AUTOMAKE --add-missing
./configure
-test x"`cat py`" = x":"
+test x"`cat py`" = x:
:
diff --git a/tests/python9.test b/tests/python9.test
index c73bea0..71588f8 100755
--- a/tests/python9.test
+++ b/tests/python9.test
@@ -35,6 +35,6 @@ $AUTOCONF
$AUTOMAKE --add-missing
./configure
-test x"`cat py.out`" = x'0:1'
+test x"`cat py.out`" = x0:1
:
- [PATCH] {maint} python: extend and improve tests, fix minor glitches, Stefano Lattarini, 2011/02/01
- Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches, Ralf Wildenhues, 2011/02/11
- Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches, Stefano Lattarini, 2011/02/13
- Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches, Ralf Wildenhues, 2011/02/13
- Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches, Stefano Lattarini, 2011/02/13
- Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches, Ralf Wildenhues, 2011/02/13
- Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches, Stefano Lattarini, 2011/02/14
- Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches, Ralf Wildenhues, 2011/02/14
- Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches, Stefano Lattarini, 2011/02/14