bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/3] test-perror: rewrite to use init script


From: Eric Blake
Subject: [PATCH 1/3] test-perror: rewrite to use init script
Date: Fri, 20 May 2011 11:59:28 -0600

Make the test simpler, and also check for correct exit status.

* modules/perror-tests (Files): Add init.sh.
* tests/test-perror.sh: Use temporary directory.

Signed-off-by: Eric Blake <address@hidden>
---

General cleanup.  I thought about enhancing this test further, but
then decided to go with a new test when I actually got to patch 2/3.

 ChangeLog            |    6 ++++++
 modules/perror-tests |    1 +
 tests/test-perror.sh |   31 ++++++++++++++-----------------
 3 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f42002c..30bccca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-20  Eric Blake  <address@hidden>
+
+       test-perror: rewrite to use init script
+       * modules/perror-tests (Files): Add init.sh.
+       * tests/test-perror.sh: Use temporary directory.
+
 2011-05-20  Jim Meyering  <address@hidden>

        maint: replace misused "a" with "an"
diff --git a/modules/perror-tests b/modules/perror-tests
index 867f920..bad23fd 100644
--- a/modules/perror-tests
+++ b/modules/perror-tests
@@ -1,4 +1,5 @@
 Files:
+tests/init.sh
 tests/signature.h
 tests/test-perror.c
 tests/test-perror.sh
diff --git a/tests/test-perror.sh b/tests/test-perror.sh
index f2c8fdc..28027ea 100755
--- a/tests/test-perror.sh
+++ b/tests/test-perror.sh
@@ -1,27 +1,24 @@
 #!/bin/sh
-
-tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+: ${srcdir=.}
+. "$srcdir/init.sh"; path_prepend_ .

 # Test NULL prefix. Result should not contain a number.
-tmpfiles="$tmpfiles t-perror.tmp"
-./test-perror${EXEEXT} 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror.tmp
-if grep '[0-9]' t-perror.tmp > /dev/null; then
-  rm -fr $tmpfiles; exit 1
-fi
+test-perror 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror.tmp
+grep '[0-9]' t-perror.tmp > /dev/null \
+  && fail_ "result should not contain a number"

 # Test empty prefix. Result should be the same.
-tmpfiles="$tmpfiles t-perror1.tmp"
-./test-perror${EXEEXT} '' 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror1.tmp
-diff t-perror.tmp t-perror1.tmp
-test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+test-perror '' 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror1.tmp
+diff t-perror.tmp t-perror1.tmp \
+  || fail_ "empty prefix should behave like NULL argument"

 # Test non-empty prefix.
-tmpfiles="$tmpfiles t-perror2.tmp t-perror3.tmp"
-./test-perror${EXEEXT} 'foo' 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > 
t-perror3.tmp
+test-perror foo 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror3.tmp
 sed -e 's/^/foo: /' < t-perror.tmp > t-perror2.tmp
-diff t-perror2.tmp t-perror3.tmp
-test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+diff t-perror2.tmp t-perror3.tmp || fail_ "prefix applied incorrectly"
+
+# Test exit status.
+test-perror >out 2>/dev/null || fail_ "unexpected exit status"
+test -s out && fail_ "unexpected output"

-rm -fr $tmpfiles
 exit 0
-- 
1.7.4.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]