[augeas-devel] [PATCH] Make distcheck work again

Jim Meyering jim at meyering.net
Fri May 30 14:16:41 UTC 2008


David Lutterkort <dlutter at redhat.com> wrote:
> 2 files changed, 4 insertions(+), 3 deletions(-)
> tests/Makefile.am |    4 +++-
> tests/test-get.sh |    3 +--
>
>
> # HG changeset patch
> # User David Lutterkort <dlutter at redhat.com>
> # Date 1212083479 25200
> # Node ID 01489ef21f1d35aaacb729d5c082be1cd7d7663d
> # Parent  e073c9665e6cd19080a61092598a602e3dc3636c
> Make distcheck work again
>
> Restore top_builddir and top_srcdir so that augtest passes during make
> distcheck.

Sorry about that.
This was my fault.
I searched carefully for the abs_top_srcdir and abs_top_builddir
strings before removing those two lines, not noticing that
those make variables were being aliased to deceptively different
envvar names[*].  In my experience, the LHS and RHS names are the same.

David, to atone (and help avoid similar confusion),
I propose to rename the LHS variables in tests/Makefile.am
and in the scripts that use the envvars.  Two patches below.
Distcheck passes.

[*] In Automake, $(top_srcdir) is usually considered to be a safe
name like ".." in that it won't contain meta-characters, while
abs_top_srcdir is an arbitrary name derived from the absolute source
directory name.

> diff -r e073c9665e6c -r 01489ef21f1d tests/Makefile.am
> --- a/tests/Makefile.am	Thu May 29 10:36:11 2008 -0700
> +++ b/tests/Makefile.am	Thu May 29 10:51:19 2008 -0700
> @@ -15,7 +15,9 @@ check_PROGRAMS = fatest
>  check_PROGRAMS = fatest
>  
>  TESTS_ENVIRONMENT = \
> -  PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH"
> +  PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \
> +  top_builddir=$(abs_top_builddir) \
> +  top_srcdir=$(abs_top_srcdir)


changeset:   503:126c11ca76e7
user:        Jim Meyering <meyering at redhat.com>
date:        Fri May 30 16:11:11 2008 +0200
files:       tests/Makefile.am tests/augtest tests/test-get.sh tests/test-interpreter.sh tests/test-lenses.sh
description:
don't conflate top_srcdir and abs_top_srcdir

* tests/Makefile.am: Use $(var), rather than obsolete @var@ notation.
(TESTS_ENVIRONMENT): Rename LHS to match RHS to help avoid (my) confusion:
s/top_builddir/abs_top_builddir/ and s/top_srcdir/abs_top_srcdir/.
* tests/augtest: Reflect renamings.
* tests/test-interpreter.sh: Likewise.
* tests/test-get.sh: Likewise, and remove unused top_builddir= assignment.
* tests/test-lenses.sh: Likewise; remove unnecessary braces, add quotes
to protect against pathological $TMPDIR.


diff --git a/tests/Makefile.am b/tests/Makefile.am
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,6 @@
 AUGTESTS=$(wildcard *.rb)
 
-AM_CFLAGS = @AUGEAS_CFLAGS@ @WARN_CFLAGS@
+AM_CFLAGS = $(AUGEAS_CFLAGS) $(WARN_CFLAGS)
 
 valgrind: fatest
 	libtool --mode=execute valgrind --quiet --leak-check=full ./fatest
@@ -16,12 +16,12 @@
 
 TESTS_ENVIRONMENT = \
   PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \
-  top_builddir=$(abs_top_builddir) \
-  top_srcdir=$(abs_top_srcdir)
+  abs_top_builddir='$(abs_top_builddir)' \
+  abs_top_srcdir='$(abs_top_srcdir)'
 
 TESTS = $(check_SCRIPTS) $(check_PROGRAMS) augtest
 
 INCLUDES = -I$(top_srcdir)/src
 
 fatest_SOURCES = fatest.c cutest.c cutest.h
-fatest_LDADD = @top_builddir@/src/libaugeas.la
+fatest_LDADD = $(top_builddir)/src/libaugeas.la
diff --git a/tests/augtest b/tests/augtest
--- a/tests/augtest
+++ b/tests/augtest
@@ -18,8 +18,8 @@
 end
 
 TOP_DIR=File::join(File::dirname(__FILE__), "..")
-TOP_BUILDDIR=ENV["top_builddir"] || TOP_DIR
-TOP_SRCDIR=ENV["top_srcdir"] || TOP_DIR
+TOP_BUILDDIR=ENV["abs_top_builddir"] || TOP_DIR
+TOP_SRCDIR=ENV["abs_top_srcdir"] || TOP_DIR
 
 TEST_DIR=File::join(TOP_SRCDIR, "tests")
 
diff --git a/tests/test-get.sh b/tests/test-get.sh
--- a/tests/test-get.sh
+++ b/tests/test-get.sh
@@ -4,11 +4,10 @@
 # any errors
 
 TOPDIR=$(cd $(dirname $0)/.. && pwd)
-[[ -n "$top_builddir" ]] || top_builddir=$TOPDIR
-[[ -n "$top_srcdir" ]] || top_srcdir=$TOPDIR
+[[ -n "$abs_top_srcdir" ]] || abs_top_srcdir=$TOPDIR
 
-export AUGEAS_LENS_LIB=${top_srcdir}/lenses
-export AUGEAS_ROOT=${top_srcdir}/tests/root
+export AUGEAS_LENS_LIB=$abs_top_srcdir/lenses
+export AUGEAS_ROOT=$abs_top_srcdir/tests/root
 
 augtool print '/augeas/files' | grep -q /error && ret=1 || ret=0
 exit $ret
diff --git a/tests/test-interpreter.sh b/tests/test-interpreter.sh
--- a/tests/test-interpreter.sh
+++ b/tests/test-interpreter.sh
@@ -6,9 +6,9 @@
 # If run with option '-v', error output from each augparse run is printed
 
 TOPDIR=$(cd $(dirname $0)/.. && pwd)
-DATADIR=${top_srcdir-${TOPDIR}}/tests
+DATADIR=${abs_top_srcdir-${TOPDIR}}/tests
 MODULES=${DATADIR}/modules
-AUGPARSE=${top_builddir-${DATADIR}/..}/src/augparse
+AUGPARSE=${abs_top_builddir-${DATADIR}/..}/src/augparse
 
 set -e
 
diff --git a/tests/test-lenses.sh b/tests/test-lenses.sh
--- a/tests/test-lenses.sh
+++ b/tests/test-lenses.sh
@@ -8,21 +8,20 @@
 fi
 
 TOPDIR=$(cd $(dirname $0)/.. && pwd)
-[[ -n "$top_builddir" ]] || top_builddir=$TOPDIR
-[[ -n "$top_srcdir" ]] || top_srcdir=$TOPDIR
+[[ -n "$abs_top_srcdir" ]] || top_srcdir=$TOPDIR
 
 
-LENS_DIR=${top_srcdir}/lenses
+LENS_DIR=$abs_top_srcdir/lenses
 TESTS=$LENS_DIR/tests/test_*.aug
 
 LOG=$(mktemp)
-trap "rm $LOG" EXIT
+trap 'rm "$LOG"' EXIT
 
 for t in $TESTS
 do
   printf "%-30s ... " $(basename $t .aug)
   set +e
-  augparse -I $LENS_DIR $t > $LOG 2>&1
+  augparse -I $LENS_DIR $t > "$LOG" 2>&1
   ret=$?
   set -e
   if [[ ! $ret -eq 0 ]]; then
@@ -32,6 +31,6 @@
     echo PASS
   fi
   if [[ "$VERBOSE" == "y" ]] ; then
-     cat $LOG
+     cat "$LOG"
   fi
 done

changeset:   504:b5bc4f9785cb
tag:         tip
user:        Jim Meyering <meyering at redhat.com>
date:        Fri May 30 16:12:45 2008 +0200
files:       tests/test-lenses.sh
description:
* tests/test-lenses.sh: more quotes, protect against space in abs_srcdir


diff --git a/tests/test-lenses.sh b/tests/test-lenses.sh
--- a/tests/test-lenses.sh
+++ b/tests/test-lenses.sh
@@ -19,9 +19,9 @@
 
 for t in $TESTS
 do
-  printf "%-30s ... " $(basename $t .aug)
+  printf "%-30s ... " $(basename "$t" .aug)
   set +e
-  augparse -I $LENS_DIR $t > "$LOG" 2>&1
+  augparse -I "$LENS_DIR" "$t" > "$LOG" 2>&1
   ret=$?
   set -e
   if [[ ! $ret -eq 0 ]]; then




More information about the augeas-devel mailing list