[augeas-devel] [PATCH 7 of 7] Remove bashisms from test scripts

David Lutterkort dlutter at redhat.com
Thu May 29 23:56:49 UTC 2008


4 files changed, 20 insertions(+), 19 deletions(-)
tests/augtest             |    2 +-
tests/test-get.sh         |    6 +++---
tests/test-interpreter.sh |   15 ++++++++-------
tests/test-lenses.sh      |   16 ++++++++--------


# HG changeset patch
# User David Lutterkort <dlutter at redhat.com>
# Date 1212105044 25200
# Node ID 0569b42452dc73c546ff124f260d2d2da3df6507
# Parent  1278209b8324592f6e16115186e88d77bd9acfc0
Remove bashisms from test scripts

Make tests scripts work with plain old sh; also, don't hardcode location of
Ruby interpreter to /usr/bin/ruby.

diff -r 1278209b8324 -r 0569b42452dc tests/augtest
--- a/tests/augtest	Thu May 29 16:49:11 2008 -0700
+++ b/tests/augtest	Thu May 29 16:50:44 2008 -0700
@@ -1,4 +1,4 @@
-#! /usr/bin/ruby
+#! /usr/bin/env ruby
 
 # Read a file with a test description, run augtool against it and
 # look at the diff between the original file and the .augnew file
diff -r 1278209b8324 -r 0569b42452dc tests/test-get.sh
--- a/tests/test-get.sh	Thu May 29 16:49:11 2008 -0700
+++ b/tests/test-get.sh	Thu May 29 16:50:44 2008 -0700
@@ -1,11 +1,11 @@
-#! /bin/bash
+#! /bin/sh
 
 # Check that reading the files in tests/root/ with augtool does not lead to
 # any errors
 
 TOPDIR=$(cd $(dirname $0)/.. && pwd)
-[[ -n "$top_builddir" ]] || top_builddir=$TOPDIR
-[[ -n "$top_srcdir" ]] || top_srcdir=$TOPDIR
+[ -n "$top_builddir" ] || top_builddir=$TOPDIR
+[ -n "$top_srcdir" ] || top_srcdir=$TOPDIR
 
 export AUGEAS_LENS_LIB=${top_srcdir}/lenses
 export AUGEAS_ROOT=${top_srcdir}/tests/root
diff -r 1278209b8324 -r 0569b42452dc tests/test-interpreter.sh
--- a/tests/test-interpreter.sh	Thu May 29 16:49:11 2008 -0700
+++ b/tests/test-interpreter.sh	Thu May 29 16:50:44 2008 -0700
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 
 # Run test modules that make sure the interpreter fails/succeeds in
 # various hairy situations.
@@ -13,11 +13,12 @@ set -e
 set -e
 
 VERBOSE=n
-if [[ "x$1" == "x-v" ]]; then
+if [ "x$1" = "x-v" ]; then
     VERBOSE=y
 fi
 
-function run_tests {
+run_tests ()
+{
     ret_succ=$1
     ret_fail=$(( 1 - $ret_succ ))
     action=$2
@@ -25,7 +26,7 @@ function run_tests {
     shift
 
     for g in $*; do
-        if [[ ! -r "$g" ]]; then
+        if [ ! -r "$g" ]; then
             echo "Grammar file $g is not readable"
             exit 19
         fi
@@ -34,16 +35,16 @@ function run_tests {
         errs=$(augparse -I ${MODULES} $g 2>&1 > /dev/null)
         ret=$?
         set -e
-        if [[ $ret -eq $ret_fail ]]; then
+        if [ $ret -eq $ret_fail ]; then
             echo FAIL
             result=1
-        elif [[ $ret -eq $ret_succ ]]; then
+        elif [ $ret -eq $ret_succ ]; then
             echo PASS
         else
             echo ERROR
             result=19
         fi
-        if [[ "$VERBOSE" == "y" ]] ; then
+        if [ "$VERBOSE" = "y" ] ; then
             echo $errs
         fi
     done
diff -r 1278209b8324 -r 0569b42452dc tests/test-lenses.sh
--- a/tests/test-lenses.sh	Thu May 29 16:49:11 2008 -0700
+++ b/tests/test-lenses.sh	Thu May 29 16:50:44 2008 -0700
@@ -1,21 +1,21 @@
-#! /bin/bash
+#! /bin/sh
 
 set -e
 
 VERBOSE=n
-if [[ "x$1" == "x-v" ]]; then
+if [ "x$1" = "x-v" ]; then
     VERBOSE=y
 fi
 
 TOPDIR=$(cd $(dirname $0)/.. && pwd)
-[[ -n "$top_builddir" ]] || top_builddir=$TOPDIR
-[[ -n "$top_srcdir" ]] || top_srcdir=$TOPDIR
+[ -n "$top_builddir" ] || top_builddir=$TOPDIR
+[ -n "$top_srcdir" ] || top_srcdir=$TOPDIR
 
 
 LENS_DIR=${top_srcdir}/lenses
 TESTS=$LENS_DIR/tests/test_*.aug
 
-LOG=$(mktemp)
+LOG=$(mktemp /tmp/test-lenses.XXXXXX)
 trap "rm $LOG" EXIT
 
 for t in $TESTS
@@ -25,13 +25,13 @@ do
   augparse -I $LENS_DIR $t > $LOG 2>&1
   ret=$?
   set -e
-  if [[ ! $ret -eq 0 ]]; then
+  if [ ! $ret -eq 0 ]; then
     echo FAIL
     result=1
-  elif [[ $ret -eq 0 ]]; then
+  elif [ $ret -eq 0 ]; then
     echo PASS
   fi
-  if [[ "$VERBOSE" == "y" ]] ; then
+  if [ "$VERBOSE" = "y" ] ; then
      cat $LOG
   fi
 done




More information about the augeas-devel mailing list