[PATCH] {master} cosmetics: better use of m4 quoting and m4sugar macros (was: Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches)

2011-03-17 Thread Stefano Lattarini
Hello automakers, and sorry for the delay.

Reference:
 

[Stefano Lattarini]
> > > > > --- a/tests/python5.test
> > > > > +++ b/tests/python5.test
> > > > 
> > > > > @@ -24,16 +24,32 @@ set -e
> > > > >  
> > > > >  cat >>configure.in < > > > >  # Hopefully the Python team will never release such a version.
> > > > > -AM_PATH_PYTHON(.9)
> > > > > +AM_PATH_PYTHON([.9])
> > > > 
[Ralf Wildenhues]
> > > > Nice that you do it here, but up in python.m4 you should then, too.
> > > >
[Stefano Lattarini]
> > > 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.
> > 
[Ralf Wildenhues]
> > OK.
> >
[Stefano Lattarini]
> Patch still on the todo list ...
> 
Now patch ready! (about time you'll say :-)
The testsuite still passes with it applied.

OK for master?  I'll push in 72 hours if there's no objection.

Regards,
  Stefano
From b5b89f1eeb9a0b235a0ed285d03a851a623a2ed4 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini 
Date: Tue, 15 Mar 2011 17:36:40 +0100
Subject: [PATCH] cosmetics: better use of m4 quoting and m4sugar macros

* m4/dmalloc.m4: Better use of m4 quoting.  Bump serial number.
* m4/gcj.m4: Likewise.
* m4/init.m4: Likewise.
* m4/install-sh.m4: Likewise.
* m4/lex.m4: Likewise.
* m4/multi.m4: Likewise.
* m4/option.m4: Likewise.
* m4/python.m4: Likewise.
* m4/sanity.m4: Likewise.
* m4/cond.m4: Likewise.  Also, prefer the m4sugar macro 'm4_if'
over the plain m4 macro 'ifelse'.
* m4/depend.m4: Likewise.
* tests/deprecated-acinit.test: New test.
* tests/Makefile.am (TESTS): Update.
---
 ChangeLog|   18 ++
 m4/cond.m4   |   10 
 m4/depend.m4 |   14 +-
 m4/dmalloc.m4|   14 +-
 m4/gcj.m4|9 ---
 m4/init.m4   |   34 ++-
 m4/install-sh.m4 |5 ++-
 m4/lex.m4|8 +++---
 m4/multi.m4  |6 ++--
 m4/options.m4|6 ++--
 m4/python.m4 |   10 
 m4/sanity.m4 |4 +-
 tests/Makefile.am|1 +
 tests/Makefile.in|1 +
 tests/deprecated-acinit.test |   52 ++
 15 files changed, 134 insertions(+), 58 deletions(-)
 create mode 100755 tests/deprecated-acinit.test

diff --git a/ChangeLog b/ChangeLog
index 5b666d7..9677fb1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2011-03-17  Stefano Lattarini  
+
+	cosmetics: better use of m4 quoting and m4sugar macros
+	* m4/dmalloc.m4: Better use of m4 quoting.  Bump serial number.
+	* m4/gcj.m4: Likewise.
+	* m4/init.m4: Likewise.
+	* m4/install-sh.m4: Likewise.
+	* m4/lex.m4: Likewise.
+	* m4/multi.m4: Likewise.
+	* m4/option.m4: Likewise.
+	* m4/python.m4: Likewise.
+	* m4/sanity.m4: Likewise.
+	* m4/cond.m4: Likewise.  Also, prefer the m4sugar macro 'm4_if'
+	over the plain m4 macro 'ifelse'.
+	* m4/depend.m4: Likewise.
+	* tests/deprecated-acinit.test: New test.
+	* tests/Makefile.am (TESTS): Update.
+
 2011-03-04  Stefano Lattarini  
 
 	tests: fix bug (comments-in-var-defn.test + autoconf 2.62)
diff --git a/m4/cond.m4 b/m4/cond.m4
index fd248b2..7fa5dfd 100644
--- a/m4/cond.m4
+++ b/m4/cond.m4
@@ -1,21 +1,21 @@
 # AM_CONDITIONAL-*- Autoconf -*-
 
-# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008, 2011
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 9
+# serial 10
 
 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
 # -
 # Define a conditional.
 AC_DEFUN([AM_CONDITIONAL],
-[AC_PREREQ(2.52)dnl
- ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
-	[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+[AC_PREREQ([2.52])dnl
+ m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+   [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
 AC_SUBST([$1_TRUE])dnl
 AC_SUBST([$1_FALSE])dnl
 _AM_SUBST_NOTMAKE([$1_TRUE])dnl
diff --git a/m4/depend.m4 b/m4/depend.m4
index a5726c6..cf1b3d8 100644
--- a/m4/depend.m4
+++ b/m4/depend.m4
@@ -6,7 +6,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 13
+# serial 14
 
 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
 # written in clear, in which case automake, when reading aclocal.m4,
@@ -31,12 +31,12 @@ AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
 AC_REQUIRE([AM_MAKE_INCLUDE])dnl
 AC_REQUIRE(

Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches

2011-02-14 Thread Stefano Lattarini
On Monday 14 February 2011, Ralf Wildenhues wrote:
> Hi Stefano,
> 
> * Stefano Lattarini wrote on Mon, Feb 14, 2011 at 11:23:54AM CET:
> > On Sunday 13 February 2011, Ralf Wildenhues wrote:
> > > OK.  That is, 'CONFIG_SITE=/dev/null; export CONFIG_SITE' of course.
> > >
> > Done.
> > 
> > Also, since in `python-virtualenv.test' we call `python' directly even
> > after the virtualenv has been deactivated, I added `python' to $required.
> 
> Cool.
> 
> > Attached is the amended patch that I'll push in 72 hours if there are no
> > further objections.
> 
> Feel free to go ahead.
> 
Done.

Thanks,
  Stefano



Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches

2011-02-14 Thread Ralf Wildenhues
Hi Stefano,

* Stefano Lattarini wrote on Mon, Feb 14, 2011 at 11:23:54AM CET:
> On Sunday 13 February 2011, Ralf Wildenhues wrote:
> > OK.  That is, 'CONFIG_SITE=/dev/null; export CONFIG_SITE' of course.
> >
> Done.
> 
> Also, since in `python-virtualenv.test' we call `python' directly even
> after the virtualenv has been deactivated, I added `python' to $required.

Cool.

> Attached is the amended patch that I'll push in 72 hours if there are no
> further objections.

Feel free to go ahead.

Thanks!
Ralf

> Subject: [PATCH] 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.
> * 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.



Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches

2011-02-14 Thread Stefano Lattarini
Hello Ralf, and sorry for the delay.

On Sunday 13 February 2011, Ralf Wildenhues wrote:
> * Stefano Lattarini wrote on Sun, Feb 13, 2011 at 02:09:03PM CET:
> > On Sunday 13 February 2011, Ralf Wildenhues wrote:
> > > * Stefano Lattarini wrote on Sun, Feb 13, 2011 at 11:49:28AM CET:
> > > > +   cat pythondir
> > > > +   case `cat pythondir` in '$${prefix}'/*);; *) exit 1;; esac
> > > > +   cat pyexecdir
> > > > +   case `cat pyexecdir` in '$${exec_prefix}'/*);; *) exit 1;; esac
> > > 
> > > This is probably pragmatically correct most anywhere, but I don't think
> > > we require pyexecdir to start with ${exec_prefix}.  The user can
> > > override it, for example by a cache variable entry in config.site, no?
> > >
> > Yes, but than he could do so also for `pythondir' -- which would cause
> > failures in both `python-vars.test' and `python-virtualenv.test'.  Maybe
> > the best fix would be to `export CONFIG_SITE=/dev/null' in these tests?
> 
> OK.  That is, 'CONFIG_SITE=/dev/null; export CONFIG_SITE' of course.
>
Done.

Also, since in `python-virtualenv.test' we call `python' directly even
after the virtualenv has been deactivated, I added `python' to $required.

> > Or should we start caring about those cache variables only once (and if)
> > they start creating real troubles?
> 
> However you like.  Since we've determined this test to be potentially
> problematic already, we can address it now and stop worrying.
>
OK.

> > > Tests should generally be lax wrt. sane config.site entries.  When we
> > > meet insane ones, we may want to decide to disable it for our testsuite,
> > > but let's cross that bridge when we get to it.
> 
> > Also, as an aside, now that $pyvars does not contain anymore `pythondir'
> > and `pyexecdir', I think we should also squash-in the following diff in
> > the test.  OK?
> 
> Sure, why not.
> 
> Thanks,
> Ralf
> 

Attached is the amended patch that I'll push in 72 hours if there are no
further objections.

Thanks,
  Stefano
From 4ceaba8f6938a6e84f3e6c75515cdf53d96bf069 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini 
Date: Sun, 13 Feb 2011 11:40:16 +0100
Subject: [PATCH] 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.
* 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|   14 ++
 tests/python-vars.test   |   38 +++---
 tests/python-virtualenv.test |5 -
 3 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0df8d8e..960e6bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-02-14  Stefano Lattarini  
+
+	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
+	evan after the virtualenv has been deactivated.  Ignore cached
+	values from config.site by exporting CONFIG_SITE=/dev/null.
+
 2011-02-06  Stefano Lattarini  
 
 	python: extend and improve tests, fix minor glitches
diff --git a/tests/python-vars.test b/tests/python-vars.test
index ad263a5..7defee2 100755
--- a/tests/python-vars.test
+++ b/tests/python-vars.test
@@ -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="\${py

Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches

2011-02-13 Thread Ralf Wildenhues
* Stefano Lattarini wrote on Sun, Feb 13, 2011 at 02:09:03PM CET:
> On Sunday 13 February 2011, Ralf Wildenhues wrote:
> > * Stefano Lattarini wrote on Sun, Feb 13, 2011 at 11:49:28AM CET:
> > > + cat pythondir
> > > + case `cat pythondir` in '$${prefix}'/*);; *) exit 1;; esac
> > > + cat pyexecdir
> > > + case `cat pyexecdir` in '$${exec_prefix}'/*);; *) exit 1;; esac
> > 
> > This is probably pragmatically correct most anywhere, but I don't think
> > we require pyexecdir to start with ${exec_prefix}.  The user can
> > override it, for example by a cache variable entry in config.site, no?
> >
> Yes, but than he could do so also for `pythondir' -- which would cause
> failures in both `python-vars.test' and `python-virtualenv.test'.  Maybe
> the best fix would be to `export CONFIG_SITE=/dev/null' in these tests?

OK.  That is, 'CONFIG_SITE=/dev/null; export CONFIG_SITE' of course.

> Or should we start caring about those cache variables only once (and if)
> they start creating real troubles?

However you like.  Since we've determined this test to be potentially
problematic already, we can address it now and stop worrying.

> > Tests should generally be lax wrt. sane config.site entries.  When we
> > meet insane ones, we may want to decide to disable it for our testsuite,
> > but let's cross that bridge when we get to it.

> Also, as an aside, now that $pyvars does not contain anymore `pythondir'
> and `pyexecdir', I think we should also squash-in the following diff in
> the test.  OK?

Sure, why not.

Thanks,
Ralf

> --- a/tests/python-vars.test
> +++ b/tests/python-vars.test
> @@ -93,7 +93,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



Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches

2011-02-13 Thread Stefano Lattarini
On Sunday 13 February 2011, Ralf Wildenhues wrote:
> * Stefano Lattarini wrote on Sun, Feb 13, 2011 at 11:49:28AM CET:
> > OK to apply?  I will push in 72 hours if there are no further
> > objections.
> 
> The patch is OK as it is a strict improvement IIUC, but I still have a
> question below.
> 
> Thanks,
> Ralf
> 
> > Subject: [PATCH] python: fix spurious failure in tests
> > 
> > * tests/python-vars.test: 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.
> 
> > --- a/tests/python-vars.test
> > +++ b/tests/python-vars.test
> > @@ -24,21 +24,23 @@ set -e
> >  
> >  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 +60,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
> 
> This is probably pragmatically correct most anywhere, but I don't think
> we require pyexecdir to start with ${exec_prefix}.  The user can
> override it, for example by a cache variable entry in config.site, no?
>
Yes, but than he could do so also for `pythondir' -- which would cause
failures in both `python-vars.test' and `python-virtualenv.test'.  Maybe
the best fix would be to `export CONFIG_SITE=/dev/null' in these tests?
Or should we start caring about those cache variables only once (and if)
they start creating real troubles?

> Tests should generally be lax wrt. sane config.site entries.  When we
> meet insane ones, we may want to decide to disable it for our testsuite,
> but let's cross that bridge when we get to it.
> 
> > 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
> 
> Same here.
> 
> >  END
> 

Also, as an aside, now that $pyvars does not contain anymore `pythondir'
and `pyexecdir', I think we should also squash-in the following diff in
the test.  OK?

-*-*-

diff --git a/tests/python-vars.test b/tests/python-vars.test
index 2242691..ab2fe35 100755
--- a/tests/python-vars.test
+++ b/tests/python-vars.test
@@ -93,7 +93,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



Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches

2011-02-13 Thread Ralf Wildenhues
* Stefano Lattarini wrote on Sun, Feb 13, 2011 at 11:49:28AM CET:
> OK to apply?  I will push in 72 hours if there are no further
> objections.

The patch is OK as it is a strict improvement IIUC, but I still have a
question below.

Thanks,
Ralf

> Subject: [PATCH] python: fix spurious failure in tests
> 
> * tests/python-vars.test: 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.

> --- a/tests/python-vars.test
> +++ b/tests/python-vars.test
> @@ -24,21 +24,23 @@ set -e
>  
>  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 +60,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

This is probably pragmatically correct most anywhere, but I don't think
we require pyexecdir to start with ${exec_prefix}.  The user can
override it, for example by a cache variable entry in config.site, no?

Tests should generally be lax wrt. sane config.site entries.  When we
meet insane ones, we may want to decide to disable it for our testsuite,
but let's cross that bridge when we get to it.

>   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

Same here.

>  END



Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches

2011-02-13 Thread Stefano Lattarini
On Friday 11 February 2011, Ralf Wildenhues wrote:
> Hi Stefano,
> 
> * Stefano Lattarini wrote on Wed, Feb 02, 2011 at 12:10:15AM CET:
> > Subject: [PATCH] python: extend and improve tests, fix minor glitches
> > 
> [...]
> > * tests/python-vars.test: New test, checking that AM_PATH_PYTHON
> > correctly set all the output variables advertised in the manual.
> 
> This test fails for me, see below.
>
Yes, I can reproduce this with my system-level installation of python3
on Debian (I had previously checked the test only with custom python
installations -- both 2.x and 3.x -- which all worked as expected).

The attached patch should fix this.

> As a minor nit, the test trace contains hyped output again, I think
>   echo "$var=$val"
> and
>   echo "$var=@$var@"
> 
> would have resulted in both smaller trace output and also more
> informative diff.
>
Agreed.  The attached patch addresses this too.

OK to apply?  I will push in 72 hours if there are no further
objections.

Thanks,
   Stefano

> Cheers,
> Ralf
> 
> FAIL: python-vars.test (exit: 2)
> 
> 
> /tmp/automake/build/tests:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
> python-vars: running python -V
> Python 2.6.5
> + set -e
> + pwd
> /tmp/automake/build/tests/python-vars.dir
> + set -e
> + PYTHON=python
> + python -c import sys; print(sys.version[:3])
> + PYTHON_VERSION=2.6
> + python -c import sys; print(sys.platform)
> + PYTHON_PLATFORM=linux2
> + PYTHON_EXEC_PREFIX=${exec_prefix}
> + PYTHON_PREFIX=${prefix}
> + pythondir=${prefix}/lib/python2.6/site-packages
> + pyexecdir=${exec_prefix}/lib/python2.6/site-packages
> + pkgpythondir=${pythondir}/python-vars
> + pkgpyexecdir=${pyexecdir}/python-vars
> + pyvars=PYTHON_VERSION PYTHON_PLATFORM PYTHON_PREFIX PYTHON_EXEC_PREFIX
> pythondir pyexecdir pkgpythondir pkgpyexecdir
> + cat
> + cat
> + cat
> + echo
> + echo
> + echo test-am:
> + eval val=$PYTHON_VERSION
> + val=2.6
> + echo ### PYTHON_VERSION ###
> + echo 2.6
> + echo
> + echo ### PYTHON_VERSION ###
> + echo @PYTHON_VERSION@
> + echo
> + echotest x'$(PYTHON_VERSION)' = x'2.6'
> + eval val=$PYTHON_PLATFORM
> + val=linux2
> + echo ### PYTHON_PLATFORM ###
> + echo linux2
> + echo
> + echo ### PYTHON_PLATFORM ###
> + echo @PYTHON_PLATFORM@
> + echo
> + echotest x'$(PYTHON_PLATFORM)' = x'linux2'
> + eval val=$PYTHON_PREFIX
> + val=${prefix}
> + echo ### PYTHON_PREFIX ###
> + echo ${prefix}
> + echo
> + echo ### PYTHON_PREFIX ###
> + echo @PYTHON_PREFIX@
> + echo
> + echotest x'$(PYTHON_PREFIX)' = x'${prefix}'
> + eval val=$PYTHON_EXEC_PREFIX
> + val=${exec_prefix}
> + echo ### PYTHON_EXEC_PREFIX ###
> + echo ${exec_prefix}
> + echo
> + echo ### PYTHON_EXEC_PREFIX ###
> + echo @PYTHON_EXEC_PREFIX@
> + echo
> + echotest x'$(PYTHON_EXEC_PREFIX)' = x'${exec_prefix}'
> + eval val=$pythondir
> + val=${prefix}/lib/python2.6/site-packages
> + echo ### pythondir ###
> + echo ${prefix}/lib/python2.6/site-packages
> + echo
> + echo ### pythondir ###
> + echo @pythondir@
> + echo
> + echotest x'$(pythondir)' = x'${prefix}/lib/python2.6/site-packages'
> + eval val=$pyexecdir
> + val=${exec_prefix}/lib/python2.6/site-packages
> + echo ### pyexecdir ###
> + echo ${exec_prefix}/lib/python2.6/site-packages
> + echo
> + echo ### pyexecdir ###
> + echo @pyexecdir@
> + echo
> + echotest x'$(pyexecdir)' = 
> x'${exec_prefix}/lib/python2.6/site-packages'
> + eval val=$pkgpythondir
> + val=${pythondir}/python-vars
> + echo ### pkgpythondir ###
> + echo ${pythondir}/python-vars
> + echo
> + echo ### pkgpythondir ###
> + echo @pkgpythondir@
> + echo
> + echotest x'$(pkgpythondir)' = x'${pythondir}/python-vars'
> + eval val=$pkgpyexecdir
> + val=${pyexecdir}/python-vars
> + echo ### pkgpyexecdir ###
> + echo ${pyexecdir}/python-vars
> + echo
> + echo ### pkgpyexecdir ###
> + echo @pkgpyexecdir@
> + echo
> + echotest x'$(pkgpyexecdir)' = x'${pyexecdir}/python-vars'
> + cat Makefile.am
> 
> 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:
>   test x'$(PYTHON_VERSION)' = x'2.6'
>   test x'$(PYTHON_PLATFORM)' = x'linux2'
>   test x'$(PYTHON_PREFIX)' = x'${prefix}'
>   test x'$(PYTHON_EXEC_PREFIX)' = x'${exec_prefix}'
>   test x'$(pythondir)' = x'${prefix}/lib/python2.6/site-packages'
>   test x'$(pyexecdir)' = x'${exec_prefix}/lib/python2.6/site-packages'
>   test x'$(pkgpythondir)' = x'${pythondir}/python-vars'
>   test x'$(pkgpyexecdir)' = x'${pyexecdir}/python-vars'
> + cat vars-got.in
> 
> ### PYTHON_VERSION ###
> @PYTHON_VERSION@
> 
> ### PYTHON_PLATFORM ###
> @PYTHON_PLATFORM@
> 
> ### PYTHON_PREFIX ###
> @PYTHON_PREFIX@
> 
> ### PYTHON_EXEC_PREFIX ###
> @PYTHON_EXEC_PREFIX@
> 
> ### pythondir ###
> @pythondir@
> 
> ###

Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches

2011-02-11 Thread Ralf Wildenhues
Hi Stefano,

* Stefano Lattarini wrote on Wed, Feb 02, 2011 at 12:10:15AM CET:
> Subject: [PATCH] python: extend and improve tests, fix minor glitches
> 
[...]
> * tests/python-vars.test: New test, checking that AM_PATH_PYTHON
> correctly set all the output variables advertised in the manual.

This test fails for me, see below.

As a minor nit, the test trace contains hyped output again, I think
  echo "$var=$val"
and
  echo "$var=@$var@"

would have resulted in both smaller trace output and also more
informative diff.

Cheers,
Ralf

FAIL: python-vars.test (exit: 2)


/tmp/automake/build/tests:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
python-vars: running python -V
Python 2.6.5
+ set -e
+ pwd
/tmp/automake/build/tests/python-vars.dir
+ set -e
+ PYTHON=python
+ python -c import sys; print(sys.version[:3])
+ PYTHON_VERSION=2.6
+ python -c import sys; print(sys.platform)
+ PYTHON_PLATFORM=linux2
+ PYTHON_EXEC_PREFIX=${exec_prefix}
+ PYTHON_PREFIX=${prefix}
+ pythondir=${prefix}/lib/python2.6/site-packages
+ pyexecdir=${exec_prefix}/lib/python2.6/site-packages
+ pkgpythondir=${pythondir}/python-vars
+ pkgpyexecdir=${pyexecdir}/python-vars
+ pyvars=PYTHON_VERSION PYTHON_PLATFORM PYTHON_PREFIX PYTHON_EXEC_PREFIX
pythondir pyexecdir pkgpythondir pkgpyexecdir
+ cat
+ cat
+ cat
+ echo
+ echo
+ echo test-am:
+ eval val=$PYTHON_VERSION
+ val=2.6
+ echo ### PYTHON_VERSION ###
+ echo 2.6
+ echo
+ echo ### PYTHON_VERSION ###
+ echo @PYTHON_VERSION@
+ echo
+ echo  test x'$(PYTHON_VERSION)' = x'2.6'
+ eval val=$PYTHON_PLATFORM
+ val=linux2
+ echo ### PYTHON_PLATFORM ###
+ echo linux2
+ echo
+ echo ### PYTHON_PLATFORM ###
+ echo @PYTHON_PLATFORM@
+ echo
+ echo  test x'$(PYTHON_PLATFORM)' = x'linux2'
+ eval val=$PYTHON_PREFIX
+ val=${prefix}
+ echo ### PYTHON_PREFIX ###
+ echo ${prefix}
+ echo
+ echo ### PYTHON_PREFIX ###
+ echo @PYTHON_PREFIX@
+ echo
+ echo  test x'$(PYTHON_PREFIX)' = x'${prefix}'
+ eval val=$PYTHON_EXEC_PREFIX
+ val=${exec_prefix}
+ echo ### PYTHON_EXEC_PREFIX ###
+ echo ${exec_prefix}
+ echo
+ echo ### PYTHON_EXEC_PREFIX ###
+ echo @PYTHON_EXEC_PREFIX@
+ echo
+ echo  test x'$(PYTHON_EXEC_PREFIX)' = x'${exec_prefix}'
+ eval val=$pythondir
+ val=${prefix}/lib/python2.6/site-packages
+ echo ### pythondir ###
+ echo ${prefix}/lib/python2.6/site-packages
+ echo
+ echo ### pythondir ###
+ echo @pythondir@
+ echo
+ echo  test x'$(pythondir)' = x'${prefix}/lib/python2.6/site-packages'
+ eval val=$pyexecdir
+ val=${exec_prefix}/lib/python2.6/site-packages
+ echo ### pyexecdir ###
+ echo ${exec_prefix}/lib/python2.6/site-packages
+ echo
+ echo ### pyexecdir ###
+ echo @pyexecdir@
+ echo
+ echo  test x'$(pyexecdir)' = x'${exec_prefix}/lib/python2.6/site-packages'
+ eval val=$pkgpythondir
+ val=${pythondir}/python-vars
+ echo ### pkgpythondir ###
+ echo ${pythondir}/python-vars
+ echo
+ echo ### pkgpythondir ###
+ echo @pkgpythondir@
+ echo
+ echo  test x'$(pkgpythondir)' = x'${pythondir}/python-vars'
+ eval val=$pkgpyexecdir
+ val=${pyexecdir}/python-vars
+ echo ### pkgpyexecdir ###
+ echo ${pyexecdir}/python-vars
+ echo
+ echo ### pkgpyexecdir ###
+ echo @pkgpyexecdir@
+ echo
+ echo  test x'$(pkgpyexecdir)' = x'${pyexecdir}/python-vars'
+ cat Makefile.am

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:
test x'$(PYTHON_VERSION)' = x'2.6'
test x'$(PYTHON_PLATFORM)' = x'linux2'
test x'$(PYTHON_PREFIX)' = x'${prefix}'
test x'$(PYTHON_EXEC_PREFIX)' = x'${exec_prefix}'
test x'$(pythondir)' = x'${prefix}/lib/python2.6/site-packages'
test x'$(pyexecdir)' = x'${exec_prefix}/lib/python2.6/site-packages'
test x'$(pkgpythondir)' = x'${pythondir}/python-vars'
test x'$(pkgpyexecdir)' = x'${pyexecdir}/python-vars'
+ cat vars-got.in

### PYTHON_VERSION ###
@PYTHON_VERSION@

### PYTHON_PLATFORM ###
@PYTHON_PLATFORM@

### PYTHON_PREFIX ###
@PYTHON_PREFIX@

### PYTHON_EXEC_PREFIX ###
@PYTHON_EXEC_PREFIX@

### pythondir ###
@pythondir@

### pyexecdir ###
@pyexecdir@

### pkgpythondir ###
@pkgpythondir@

### pkgpyexecdir ###
@pkgpyexecdir@

+ aclocal-1.11a -Werror
+ automake-1.11a --foreign -Werror -Wall --add-missing
Makefile.am:2: installing `./py-compile'
+ grep ^PYTHON_VERSION *= Makefile.in
PYTHON_VERSION = @PYTHON_VERSION@
+ grep ^PYTHON_PLATFORM *= Makefile.in
PYTHON_PLATFORM = @PYTHON_PLATFORM@
+ grep ^PYTHON_PREFIX *= Makefile.in
PYTHON_PREFIX = @PYTHON_PREFIX@
+ grep ^PYTHON_EXEC_PREFIX *= Makefile.in
PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+ grep ^pythondir *= Makefile.in
pythondir = @pythondir@
+ grep ^pyexecdir *= Makefile.in
pyexecdir = @pyexecdir@
+ grep ^pkgpythondir *= Makefile.in
pkgpythondir = @pkgpythondir@
+ grep ^pkgpyexecdir *= Makefile.in
pkgpyexecdir = @pkgpyexecdir@
+ autoconf
+ ./configure P

Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches

2011-02-10 Thread Ralf Wildenhues
Hi Stefano,

* Stefano Lattarini wrote on Sun, Feb 06, 2011 at 06:32:56PM CET:
> Hello Ralf, and sorry for the delay.

No worries.  I'm waay more behind.

> On Thursday 03 February 2011, Ralf Wildenhues wrote:
> > * 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='...'

Neat; but also expensive.

> BTW, following your advice, I have uncovered a bug in python-dist.test.
> Fixed in the attached squash-in.

Cool.

> > > 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).

Thanks.

> > 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?

I think so; to avoid requirements.

> Should that be fixed in a follow-up patch?

Well, the overlap of instdir.test with the instdir-*.test is pretty
large anyway, so it's not too important to have this full.

> > > --- 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).

OK.  It's a close call anyway, and not a big problem either way.

> > > --- a/tests/python5.test
> > > +++ b/tests/python5.test
> > 
> > > @@ -24,16 +24,32 @@ set -e
> > >  
> > >  cat >>configure.in < > >  # Hopefully the Python team will never release such a version.
> > > -AM_PATH_PYTHON(.9)
> > > +AM_PATH_PYTHON([.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.

OK.

> > > --- a/tests/python6.test
> > > +++ b/tests/python6.test

> > > +# 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,

True, but makes reading slightly harder IMVHO.

> so I'll simply remove it.

Thanks.

> > 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`.

OK with me.

> 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.

OK but I have a question below.

> --- a/tests/instdir-ltlib.test
> +++ b/tests/instdir-ltlib.test

> @@ -14,7 +14,8 @@
>  # You should have received a copy of the GNU General Public License
>  # along with this program.  If not, see .
>  
> -# 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_

Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches

2011-02-10 Thread Stefano Lattarini
On Wednesday 09 February 2011, Ralf Wildenhues wrote:
> Hi Stefano,
> 
> * Stefano Lattarini wrote on Sun, Feb 06, 2011 at 06:32:56PM CET:
> > Hello Ralf, and sorry for the delay.
> 
> No worries.  I'm waay more behind.
> 
> > On Thursday 03 February 2011, Ralf Wildenhues wrote:
> > > * 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.
> > >
I've now merged to patch (branched off of maint) into master, and pushed.

> > > 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='...'
> 
> Neat; but also expensive.
>
Ah, but botching up system-wide python is much more expensive.
And Murphy is always lurking ... ;-)

> [CUT]

> > > > --- a/tests/python5.test
> > > > +++ b/tests/python5.test
> > > 
> > > > @@ -24,16 +24,32 @@ set -e
> > > >  
> > > >  cat >>configure.in < > > >  # Hopefully the Python team will never release such a version.
> > > > -AM_PATH_PYTHON(.9)
> > > > +AM_PATH_PYTHON([.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.
> 
> OK.
>
Patch still on the todo list ...

> > 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.
> 
> OK but I have a question below.
> 
> > --- a/tests/instdir-ltlib.test
> > +++ b/tests/instdir-ltlib.test
> 
> > @@ -14,7 +14,8 @@
> >  # You should have received a copy of the GNU General Public License
> >  # along with this program.  If not, see .
> >  
> > -# 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
> >   
> 
> > --- a/tests/instdir-prog.test
> > +++ b/tests/instdir-prog.test
> 
> > @@ -14,7 +14,8 @@
> >  # You should have received a copy of the GNU General Public License
> >  # along with this program.  If not, see .
> >  
> > -# 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
> >  
> 
> Do these two tests require python now?
>
No, since I define the relevant configure cache values explicitly,
and also force PYTHON to `echo'.  Also, making such important and
generic tests depend on python would have been a royally bad idea.

> In that case maybe the merging
> wasn't such a good idea after all; several of the machines I
> test on do not have python in the default PATH.
>
In light of the above, this shouldn't be a problem.

Regards,
   Stefano



Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches

2011-02-07 Thread Stefano Lattarini
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
> >

Re: [PATCH] {maint} python: extend and improve tests, fix minor glitches

2011-02-03 Thread Ralf Wildenhues
Hi Stefano,

* 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).

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
> 
> * 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.
> 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
> 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 virtualenvs.

What is virtualenvs?

> * 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.  And a no-contents
version in instdir.test, analogously to the rest.

> +. ./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 && E