[augeas-devel] [PATCH] Remove some absolute paths for binaries.
Jim Meyering
jim at meyering.net
Fri May 23 20:10:59 UTC 2008
Not really necessary, but worthwhile in the long run,
this hoists from tests/* into one place (tests/Makefile.am)
the knowledge that the tools under test reside in $(abs_top_builddir)/src.
This also makes it so any use of argv[0] from the tests (typically
on stderr) will be more consistent than it would be when invoking via
an absolute name. Currently, the tools don't identify diagnostics with
the usual "$0: " prefix, so this aspect isn't so important.
[Currently, we have this:
$ ./augtool foo
Unknown command 'foo'
What do you think of making augtool emit the conventional prefix:
$ augtool foo
augtool: Unknown command 'foo'
]
Oh! I've just noticed that the existing uses of $(abs_top_builddir)
were not quoted. That's asking for trouble with a meta-character-
containing build directory name... potentially even a security
risk, in pathological cases.
changeset: 491:c25dc2f5e728
tag: tip
user: Jim Meyering <meyering at redhat.com>
date: Fri May 23 21:53:29 2008 +0200
files: tests/Makefile.am tests/augtest tests/rec-initdefault.rb tests/test-interpreter.sh tests/test-lenses.sh
description:
Remove some absolute paths for binaries.
* tests/Makefile.am [TESTS_ENVIRONMENT]: Add a PATH definition that
lets tests invoke "augtool" and "augparse" without any absolute prefix.
Quote uses of $(abs_top_builddir).
* tests/augtest: Remove definition of AUGTOOL. Update use.
* tests/test-lenses.sh: Likewise for AUGPARSE.
* tests/test-interpreter.sh: Likewise.
* tests/rec-initdefault.rb: Use 'augtool -n' in place of #{AUGTOOL}.
diff --git a/tests/Makefile.am b/tests/Makefile.am
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,8 +14,10 @@
check_PROGRAMS = fatest
-TESTS_ENVIRONMENT = top_builddir=$(abs_top_builddir) \
- top_srcdir=$(abs_top_srcdir)
+TESTS_ENVIRONMENT = \
+ top_builddir='$(abs_top_builddir)' \
+ top_srcdir='$(abs_top_srcdir)' \
+ PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH"
TESTS = $(check_SCRIPTS) $(check_PROGRAMS) augtest
diff --git a/tests/augtest b/tests/augtest
--- a/tests/augtest
+++ b/tests/augtest
@@ -23,7 +23,6 @@
TEST_DIR=File::join(TOP_SRCDIR, "tests")
-AUGTOOL="#{TOP_BUILDDIR}/src/augtool -n"
AUGEAS_ROOT=File::join(TOP_BUILDDIR, "build", "augtest")
AUGEAS_LENS_LIB=File::join(TOP_SRCDIR, "lenses")
@@ -63,7 +62,7 @@
redir = echo ? "" : "> /dev/null"
printf("Test %-#{WIDTH}s ... ", File::basename(test, ".rb"))
unless skip
- IO.popen("#{AUGTOOL} #{augtool_check} #{redir}", "w") do |io|
+ IO.popen("augtool -n #{augtool_check} #{redir}", "w") do |io|
io.print(commands)
io.puts("\nquit")
end
diff --git a/tests/rec-initdefault.rb b/tests/rec-initdefault.rb
--- a/tests/rec-initdefault.rb
+++ b/tests/rec-initdefault.rb
@@ -7,7 +7,7 @@
# Query for the record that holds the initdefault
record=""
-`#{AUGTOOL} match '/files/etc/inittab/*/action' initdefault`.each do |l|
+`augtool -n match '/files/etc/inittab/*/action' initdefault`.each do |l|
if l =~ %r{^(/files/etc/inittab/[0-9]+)}
record = $1
end
diff --git a/tests/test-interpreter.sh b/tests/test-interpreter.sh
--- a/tests/test-interpreter.sh
+++ b/tests/test-interpreter.sh
@@ -31,7 +31,7 @@
fi
printf "$action %-30s ... " $(basename $g .aug)
set +e
- errs=$(${AUGPARSE} -I ${MODULES} $g 2>&1 > /dev/null)
+ errs=$(augparse -I ${MODULES} $g 2>&1 > /dev/null)
ret=$?
set -e
if [[ $ret -eq $ret_fail ]]; then
diff --git a/tests/test-lenses.sh b/tests/test-lenses.sh
--- a/tests/test-lenses.sh
+++ b/tests/test-lenses.sh
@@ -12,7 +12,6 @@
[[ -n "$top_srcdir" ]] || top_srcdir=$TOPDIR
-AUGPARSE=${top_builddir}/src/augparse
LENS_DIR=${top_srcdir}/lenses
TESTS=$LENS_DIR/tests/test_*.aug
@@ -23,7 +22,7 @@
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
More information about the augeas-devel
mailing list