]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
python: fix spurious failure in tests
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 13 Feb 2011 10:40:16 +0000 (11:40 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 14 Feb 2011 10:28:20 +0000 (11:28 +0100)
* tests/python-vars.test: Ignore cached values from config.site
by exporting CONFIG_SITE=/dev/null.  Be laxer in matching the
expected values of output variables `pythondir' and `pyexecdir',
since they can change quite unpredictably among different python
installations.  Also, avoid "hyping" debugging output, thus
offering smaller trace output and more informative diff.
* tests/python-virtualenv.test: Require python, since we call it
even after the virtualenv has been deactivated.  Ignore cached
values from config.site by exporting CONFIG_SITE=/dev/null.

Report and suggestions by Ralf Wildenhues.

ChangeLog
tests/python-vars.test
tests/python-virtualenv.test

index 0df8d8e08daf051d6da41eff967153065f69f469..e2e59551a003da91c2bf68a72a911c038881789d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-02-14  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       python: fix spurious failure in tests
+       * tests/python-vars.test: Ignore cached values from config.site
+       by exporting CONFIG_SITE=/dev/null.  Be laxer in matching the
+       expected values of output variables `pythondir' and `pyexecdir',
+       since they can change quite unpredictably among different python
+       installations.  Also, avoid "hyping" debugging output, thus
+       offering smaller trace output and more informative diff.
+       Report and suggestions by Ralf Wildenhues.
+       * tests/python-virtualenv.test: Require python, since we call it
+       even after the virtualenv has been deactivated.  Ignore cached
+       values from config.site by exporting CONFIG_SITE=/dev/null.
+
 2011-02-06  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        python: extend and improve tests, fix minor glitches
index ad263a572819c6590b97dad17de16ba370dea60e..7defee20ce1cb768cb75fb3253d8c2a6d3bca1c3 100755 (executable)
@@ -22,23 +22,28 @@ required=python
 
 set -e
 
+# In case the user's config.site defines pythondir or pyexecdir.
+CONFIG_SITE=/dev/null; export CONFIG_SITE
+
 PYTHON=python
 
-# Update these if the documentation changes.
+# Update the definition below if the documentation changes.
+# Note that the value of the `pythondir' and `pyexecdir' variables can
+# vary among different python installations, so we need more relaxed
+# and ad-hoc checks for them.  Also, more proper "functional" checks
+# on them should be done in the `python-virtualenv.test' test.
 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'
+        pkgpythondir pkgpyexecdir'
 
 cat >> configure.in << 'END'
-AC_CONFIG_FILES([vars-got])
+AC_CONFIG_FILES([vars-got pythondir pyexecdir])
 AM_PATH_PYTHON
 AC_OUTPUT
 END
@@ -58,19 +63,30 @@ check-local: test-in test-am
 .PHONY: test-in test-am
 
 test-in:
+       cat pythondir
+       case `cat pythondir` in '$${prefix}'/*);; *) exit 1;; esac
+       cat pyexecdir
+       case `cat pyexecdir` in '$${exec_prefix}'/*);; *) exit 1;; esac
        cat $(srcdir)/vars-exp
        cat $(builddir)/vars-got
        diff $(srcdir)/vars-exp $(builddir)/vars-got
+
+## Note: this target's rules will be extended in the "for" loop below.
+test-am:
+       case '$(pythondir)' in '$(prefix)'/*);; *) exit 1;; esac
+       case '$(pyexecdir)' in '$(exec_prefix)'/*);; *) exit 1;; esac
 END
 
-echo > vars-exp
-echo > vars-got.in
-echo test-am: >> Makefile.am
+echo @pythondir@ > pythondir.in
+echo @pyexecdir@ > pyexecdir.in
+
+: > vars-exp
+: > vars-got.in
 
 for var in $pyvars; do
   eval val=\$$var
-  (echo "### $var ###" && echo "$val" && echo) >> vars-exp
-  (echo "### $var ###" && echo "@$var@" && echo) >> vars-got.in
+  echo "var=$val" >> vars-exp
+  echo "var=@$var@" >> vars-got.in
   echo "${tab}test x'\$($var)' = x'$val'" >> Makefile.am
 done
 
@@ -80,7 +96,7 @@ cat vars-got.in
 $ACLOCAL
 $AUTOMAKE --add-missing
 
-for var in $pyvars; do
+for var in pythondir pyexecdir $pyvars; do
   grep "^$var *=" Makefile.in
 done
 
index 478a8dc3eaf5ecd9f34215a9b871328252f88bc1..4bbfbfc4c8442e93908d92403967d8a14bb225d1 100755 (executable)
 # Check that python support can work well with virtualenvs.
 # This test also works as a mild stress-test on the python support.
 
-required=virtualenv
+required='python virtualenv'
 . ./defs || Exit 1
 
 set -e
 
+# In case the user's config.site defines pythondir or pyexecdir.
+CONFIG_SITE=/dev/null; export CONFIG_SITE
+
 # Skip the test if a proper virtualenv cannot be created.
 virtualenv --verbose virtenv || Exit 77
 test -f virtenv/bin/activate || Exit 77