automake-patches
[Top][All Lists]
Advanced

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

[FYI] {testsuite-work} tests: more use of TAP in our own testsuite


From: Stefano Lattarini
Subject: [FYI] {testsuite-work} tests: more use of TAP in our own testsuite
Date: Tue, 6 Sep 2011 23:50:00 +0200

* tests/parallel-tests-interrupt.test: Renamed ...
* tests/parallel-tests-interrupt.tap: ... to this, and converted
to the use of TAP protocol.
* tests/self-check-cleanup.test: Renamed ...
* tests/self-check-cleanup.tap: ... to this, and converted to the
use of TAP protocol.
* tests/self-check-dir.test: Renamed ...
* tests/self-check-dir.tap: ... to this, and converted to the use
of TAP protocol.
* tests/self-check-is_newest.test: Renamed ...
* tests/self-check-is_newest.tap: ... to this, and converted to
the use of TAP protocol.
* tests/self-check-unindent.test: Renamed ...
* tests/self-check-unindent.tap: ... to this, and converted to
the use of TAP protocol.
* tests/list-of-tests.mk: Update.
---
 ChangeLog                                          |   20 +++++
 tests/Makefile.in                                  |   10 +-
 tests/list-of-tests.mk                             |   10 +-
 ...interrupt.test => parallel-tests-interrupt.tap} |   50 ++++++++----
 ...f-check-cleanup.test => self-check-cleanup.tap} |   80 ++++++++++++--------
 tests/self-check-dir.tap                           |   72 ++++++++++++++++++
 tests/self-check-dir.test                          |   66 ----------------
 ...eck-is_newest.test => self-check-is_newest.tap} |   39 ++++++----
 ...check-unindent.test => self-check-unindent.tap} |   66 ++++++++--------
 9 files changed, 238 insertions(+), 175 deletions(-)
 rename tests/{parallel-tests-interrupt.test => parallel-tests-interrupt.tap} 
(63%)
 rename tests/{self-check-cleanup.test => self-check-cleanup.tap} (56%)
 create mode 100755 tests/self-check-dir.tap
 delete mode 100755 tests/self-check-dir.test
 rename tests/{self-check-is_newest.test => self-check-is_newest.tap} (77%)
 rename tests/{self-check-unindent.test => self-check-unindent.tap} (76%)

diff --git a/ChangeLog b/ChangeLog
index a3ea13a..c1d9365 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,25 @@
 2011-09-06  Stefano Lattarini  <address@hidden>
 
+       tests: more use of TAP in our own testsuite
+       * tests/parallel-tests-interrupt.test: Renamed ...
+       * tests/parallel-tests-interrupt.tap: ... to this, and converted
+       to the use of TAP protocol.
+       * tests/self-check-cleanup.test: Renamed ...
+       * tests/self-check-cleanup.tap: ... to this, and converted to the
+       use of TAP protocol.
+       * tests/self-check-dir.test: Renamed ...
+       * tests/self-check-dir.tap: ... to this, and converted to the use
+       of TAP protocol.
+       * tests/self-check-is_newest.test: Renamed ...
+       * tests/self-check-is_newest.tap: ... to this, and converted to
+       the use of TAP protocol.
+       * tests/self-check-unindent.test: Renamed ...
+       * tests/self-check-unindent.tap: ... to this, and converted to
+       the use of TAP protocol.
+       * tests/list-of-tests.mk: Update.
+
+2011-09-06  Stefano Lattarini  <address@hidden>
+
        self tests: sanity check on 'is_blocked_signal' function
        * tests/self-check-is-blocked-signal.tap: New test.
        * tests/list-of-tests.mk: Update.
diff --git a/tests/Makefile.in b/tests/Makefile.in
index b56a018..556bf86 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -958,7 +958,7 @@ parallel-tests-fd-redirect.test \
 parallel-tests-extra-programs.test \
 parallel-tests-unreadable.test \
 parallel-tests-subdir.test \
-parallel-tests-interrupt.test \
+parallel-tests-interrupt.tap \
 parallel-tests-reset-term.test \
 parallel-tests-harderror.test \
 parallel-tests-log-override-1.test \
@@ -1123,12 +1123,12 @@ reqd.test \
 reqd2.test \
 repeated-options.test \
 rulepat.test \
-self-check-cleanup.test \
-self-check-dir.test \
+self-check-cleanup.tap \
+self-check-dir.tap \
 self-check-env-sanitize.tap \
 self-check-exit.tap \
 self-check-explicit-skips.test \
-self-check-is_newest.test \
+self-check-is_newest.tap \
 self-check-me.tap \
 self-check-reexec.test \
 self-check-report.test \
@@ -1136,7 +1136,7 @@ self-check-sanity.test \
 self-check-seq.test \
 self-check-is-blocked-signal.tap \
 self-check-tap.test \
-self-check-unindent.test \
+self-check-unindent.tap \
 sanity.test \
 scripts.test \
 seenc.test \
diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk
index abcb698..4783b09 100644
--- a/tests/list-of-tests.mk
+++ b/tests/list-of-tests.mk
@@ -633,7 +633,7 @@ parallel-tests-fd-redirect.test \
 parallel-tests-extra-programs.test \
 parallel-tests-unreadable.test \
 parallel-tests-subdir.test \
-parallel-tests-interrupt.test \
+parallel-tests-interrupt.tap \
 parallel-tests-reset-term.test \
 parallel-tests-harderror.test \
 parallel-tests-log-override-1.test \
@@ -798,12 +798,12 @@ reqd.test \
 reqd2.test \
 repeated-options.test \
 rulepat.test \
-self-check-cleanup.test \
-self-check-dir.test \
+self-check-cleanup.tap \
+self-check-dir.tap \
 self-check-env-sanitize.tap \
 self-check-exit.tap \
 self-check-explicit-skips.test \
-self-check-is_newest.test \
+self-check-is_newest.tap \
 self-check-me.tap \
 self-check-reexec.test \
 self-check-report.test \
@@ -811,7 +811,7 @@ self-check-sanity.test \
 self-check-seq.test \
 self-check-is-blocked-signal.tap \
 self-check-tap.test \
-self-check-unindent.test \
+self-check-unindent.tap \
 sanity.test \
 scripts.test \
 seenc.test \
diff --git a/tests/parallel-tests-interrupt.test 
b/tests/parallel-tests-interrupt.tap
similarity index 63%
rename from tests/parallel-tests-interrupt.test
rename to tests/parallel-tests-interrupt.tap
index bf4f7f0..f0bfbb3 100755
--- a/tests/parallel-tests-interrupt.test
+++ b/tests/parallel-tests-interrupt.tap
@@ -22,6 +22,8 @@
 parallel_tests=yes
 . ./defs || Exit 1
 
+plan_ 16
+
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
@@ -31,7 +33,7 @@ TESTS = foo.test
 ## Provide more debugging info.
 TEST_LOG_COMPILER = $(SHELL) -x
 ## Required by foo.test; see below.
-AM_TESTS_FD_REDIRECT = 9>&2
+AM_TESTS_FD_REDIRECT = 9>&1
 END
 
 # This is hacky and ugly, but has the great advantage of avoiding us a lot
@@ -44,40 +46,54 @@ END
 
 cat > foo.test << 'END'
 #!/bin/sh
-exec 2>&9
+
 echo "foo is starting to run"
-ls -l >&2
-cat foo.log >&2 || : > fail
-grep '^foo is starting to run$' foo.log >&2 || : > fail
-cat pid >&2 || : > fail
-kill -$signum `cat pid` || : > fail
+
+ls -l >&9 || exit 99
+
+test $sig -gt 0 || {
+  echo "Bailout! \$sig not exported to test script" >&9
+  exit 99
+}
+
+res=ok; cat foo.log >&9 || res="not ok"
+echo "$res - logfile created and readable [SIG $sig]" >&9
+
+res=ok; grep '^foo is starting to run$' foo.log >&2 || res='not ok'
+echo "$res - logfile contains output from test script [SIG $sig]" >&9
+
+cat pid >&9 \
+  || echo "Bailout! cannot get PID of test driver" >&9
+kill -$sig `cat pid` \
+  || echo "Bailout! cannot send signal $sig to test driver" >&9
 END
 chmod a+x foo.test
 
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE
+$ACLOCAL  || fatal_ "aclocal failed"
+$AUTOCONF || fatal_ "autoconf failed"
+$AUTOMAKE || fatal_ "automake failed"
 
-./configure
+./configure || fatal_ "./configure failed"
 
 # The only signals that can be trapped portable are 1 "SIGHUP",
 # 2 "SIGINT", 13 "SIGPIPE" and 15 "SIGTERM".
 trapped_signals='1 2 13 15'
 
-for signum in $trapped_signals; do
-  if is_blocked_signal $signum; then
-    echo "$me: signal $signum is blocked, skipping part of the test"
+for sig in $trapped_signals; do
+  if is_blocked_signal $sig; then
+    for i in 1 2 3 4; do echo "ok # SKIP signal $sig is blocked"; done
     continue
   fi
   rm -f pid fail *.log
-  env signum=$signum $MAKE check && { ls -l; Exit 1; }
+  r=ok; env sig=$sig $MAKE check && r='not ok'
+  echo "$r - signal $sig to test driver causes \"make check\" to fail"
   ls -l
   # These files shouldn't exist, but in case they do, their content might
   # provide helpful information about the causes of the failure(s).
   cat foo.log || :
   cat test-suite.log || :
-  test -f fail && Exit 1
-  ls | $EGREP 'foo.*\.(log|tmp)' && Exit 1
+  r=ok; ls | $EGREP 'foo.*\.(log|tmp)' && r='not ok'
+  echo "$r - test driver clean up log and tmp files after signal $sig"
 done
 
 :
diff --git a/tests/self-check-cleanup.test b/tests/self-check-cleanup.tap
similarity index 56%
rename from tests/self-check-cleanup.test
rename to tests/self-check-cleanup.tap
index 754ed0d..c9d0bc9 100755
--- a/tests/self-check-cleanup.test
+++ b/tests/self-check-cleanup.tap
@@ -20,19 +20,24 @@
 . ./defs || Exit 1
 
 if test x"$sh_errexit_works" != x"yes"; then
-  skip_ "$me: no working exit trap with 'set -e'"
+  skip_all_ "$me: no working exit trap with 'set -e'"
 fi
 
+plan_ 42
+
 # We still need a little hack to make ./defs work outside automake's
 # tree `tests' subdirectory.  Not a big deal.
 sed "s|^testbuilddir=.*|testbuilddir='`pwd`'|" ../defs-static >defs-static
-diff ../defs-static defs-static && Exit 99
+diff ../defs-static defs-static && fatal_ "failed to edit defs-static"
 cp ../defs .
 
 AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
 
-have_symlinks=false
-ln -s defs foo && have_symlinks=:
+if ln -s defs foo; then
+  have_symlinks=yes
+else
+  have_symlinks=no
+fi
 export have_symlinks # Is used also by spawned shells.
 
 dir=dummy.dir
@@ -42,28 +47,29 @@ dir=dummy.dir
 mkdir $dir $dir/sub
 cd $dir
 touch file sub/file
-if $have_symlinks; then
+if test $have_symlinks = yes; then
   ln -s file symlink
   ln -s none brokenlink
 fi
 cd ..
 chmod 000 $dir/sub/* $dir/file $dir/symlink
 chmod 000 $dir/sub $dir
-$SHELL -c  '. ./defs' dummy.test
-test ! -f $dir
-test ! -d $dir
-test ! -r $dir
+command_ok_ "pre-cleanup can deal with null-perms testdir" \
+            $SHELL -c  '. ./defs' dummy.test
+command_ok_ "pre-cleanup removed null-perms testdir"
+            eval 'test ! -f $dir && test ! -d $dir && test ! -r $dir'
 
 # Check that post-test cleanup works also with directories with
 # "null" permissions, and containing broken symlinks.
-$SHELL -c '
+command_ok_ "post-cleanup can deal with null-perms testdir" \
+            $SHELL -c  '
   stderr_fileno_=2
   . ./defs || Exit 1
   set -e
   mkdir dir dir/sub
   cd dir
   touch file sub/file
-  if $have_symlinks; then
+  if test $have_symlinks = yes; then
     ln -s file symlink
     ln -s none brokenlink
   fi
@@ -72,13 +78,12 @@ $SHELL -c '
   chmod 000 dir/sub dir
   :
 ' dummy.test
-test ! -f $dir
-test ! -d $dir
-test ! -r $dir
+command_ok_ "post-cleanup removed null-perms testdir"
+            eval 'test ! -f $dir && test ! -d $dir && test ! -r $dir'
 
 # Check that pre-test cleanup does not unduly change the permissions of
 # files to which symlinks in the temporary test directory point to.
-if $have_symlinks; then
+if test $have_symlinks = yes; then
 
   mkdir dir
   chmod 000 dir
@@ -89,53 +94,64 @@ if $have_symlinks; then
   cd $dir
   ln -s ../dir ../file .
   cd ..
-  $SHELL -c '. ./defs' dummy.test
+
+  command_ok_ "pre-cleanup with testdir with zero-perms symlinks" \
+               $SHELL -c '. ./defs' dummy.test
   ls -l # For debugging.
-  ls -l file | grep "^----------.*file"
-  ls -ld dir | grep "^d---------.*dir"
+  command_ok_ "pre-cleanup chmod doesn't follow symlinks to files" \
+               eval 'ls -l file | grep "^----------.*file"'
+  command_ok_ "pre-cleanup chmod doesn't follow symlinks to dirs" \
+              eval 'ls -ld dir | grep "^d---------.*dir"'
 
-  $SHELL -c '
+  command_ok_ "post-cleanup with testdir with zero-perms symlinks" \
+              $SHELL -c '
     ocwd=`pwd` || exit 1
     stderr_fileno_=2
     . ./defs || Exit 1
     ln -s "$ocwd/dir" "$ocwd/file" .
   ' dummy.test
   ls -l # For debugging.
-  ls -l file | grep "^----------.*file"
-  ls -ld dir | grep "^d---------.*dir"
+  command_ok_ "post-cleanup chmod doesn't follow symlinks to files" \
+               eval 'ls -l file | grep "^----------.*file"'
+  command_ok_ "post-cleanup chmod doesn't follow symlinks to dirs" \
+              eval 'ls -ld dir | grep "^d---------.*dir"'
 
   rmdir dir
   rm -f file
 
-fi # $have_symlinks
+else # $have_symlinks = no
+  skip_row_ 6 "symlinks not supported"
+fi
 
 # Check that the cleanup trap does not remove the temporary
 # test directory in case of test failure, skip, hard-error,
 # or when receiving a signal.
 
 for st in 1 2 3 10 77 99 126 127 130 255; do
-  $SHELL -c  "
+  command_ok_ "exit trap doesn't clobber exit status $st" not $SHELL -c "
     stderr_fileno_=2
     . ./defs
     : > foo
     Exit $st
-  " dummy.test && Exit 1
-  test -f dummy.dir/foo
+  " dummy.test
+  command_ok_ "testdir not removed if exiting with status $st" \
+              test -f dummy.dir/foo
   rm -rf dummy.dir
 done
 
-for signum in 1 2 3 9 13 15; do
-  if is_blocked_signal $signum; then
-    echo "$me: signal $signum is blocked, skipping part of the test"
+for sig in 1 2 3 9 13 15; do
+  if is_blocked_signal $sig; then
+    skip_row_ 2 -r "signal $sig seems blocked"
     continue
   fi
-  $SHELL -c  "
+  command_ok_ "exit trap doesn't clobber signal $sig" not $SHELL -c "
     stderr_fileno_=2
     . ./defs
     : > foo
-    kill -$signum \$\$
-  " dummy.test && Exit 1
-  test -f dummy.dir/foo
+    kill -$sig \$\$
+  " dummy.test
+  command_ok_ "testdir not removed if getting signal $sig" \
+              test -f dummy.dir/foo
   rm -rf dummy.dir
 done
 
diff --git a/tests/self-check-dir.tap b/tests/self-check-dir.tap
new file mode 100755
index 0000000..e698b0c
--- /dev/null
+++ b/tests/self-check-dir.tap
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite.
+# Check that tests using `./defs' create a proper temporary directory,
+# and run in it.  Also check that we can prevent the pre-population
+# and the creation of such directory if we want.
+
+am_create_testdir=no
+. ./defs || Exit 99
+
+plan_ 5
+
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
+# This needs to be consistent with what $SHELL deems to be the
+# current working directory.
+cwd=`$SHELL -c 'pwd'` || fatal_ "can't get current working directory"
+echo "$cwd"
+
+do_check ()
+{
+  test ! -d _self.dir || rm -rf _self.dir \
+    || framework_failure_ "cleaning up _self.dir"
+  command_ok_ "$1 [$2]" $SHELL -c "
+    $2
+    . ./defs || Exit 99
+    pwd; ls -l; # For debugging.
+    $3
+  " _self.test
+}
+
+do_check 'testdir has the expected path' \
+         'unset am_create_testdir' \
+         'case `pwd` in '"$cwd"'/_self.dir);; *) Exit 1;; esac'
+
+do_check 'fully pre-populated testdir' \
+         'unset am_create_testdir' \
+         'test -f install-sh || Exit 1
+          test -f configure.in || Exit 1
+          case `pwd` in '"$cwd"'/_self.dir) : ;; *) Exit 1;; esac'
+
+do_check 'testdir has the expected path' \
+         'am_create_testdir=empty' \
+         'case `pwd` in '"$cwd"'/_self.dir) : ;; *) Exit 1;; esac'
+
+do_check 'do not pre-populate testdir' \
+         'am_create_testdir=empty' \
+         'ls -a | grep -v "^\\.\\{1,2\\}$" | grep . && Exit 1; :'
+
+do_check 'do not create nor chdir in testdir' \
+         'am_create_testdir=no' \
+         'test ! -d _self.dir || Exit 1
+          test ! -f _self.dir || Exit 1
+          test ! -r _self.dir || Exit 1
+          test -f self-check-dir.tap || Exit 1
+          case `pwd` in '"$cwd"') : ;; *) Exit 1;; esac'
+
+:
diff --git a/tests/self-check-dir.test b/tests/self-check-dir.test
deleted file mode 100755
index 1aae601..0000000
--- a/tests/self-check-dir.test
+++ /dev/null
@@ -1,66 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Sanity check for the automake testsuite.
-# Check that tests using `./defs' create a proper temporary directory,
-# and run in it.  Also check that we can prevent the pre-population
-# and the creation of such directory if we want.
-
-. ./defs-static || exit 1
-
-set -ex
-AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
-
-# This needs to be consistent with what $SHELL deems to be the
-# current working directory.
-cwd=`$SHELL -c 'pwd'` || exit 99
-echo "$cwd"
-
-rm -f _self.tmp
-
-st=0
-$SHELL -c '
-  . ./defs || Exit 1
-  pwd; ls -l; # For debugging.
-  : > _self.tmp
-  test -f install-sh
-  test -f configure.in
-  case `pwd` in '"$cwd"'/_self.dir);; *) Exit 1;; esac
-' _self.test || st=1
-test -f _self.tmp && { rm -f _self.tmp; st=1; }
-test $st -eq 0 || exit 1
-
-st=0
-$SHELL -c '
-  am_create_testdir=empty
-  . ./defs || Exit 1
-  pwd; ls -l; # For debugging.
-  ls -a | grep -v "^\\.\\{1,2\\}$" | grep . && Exit 1
-  : > _self.tmp
-  case `pwd` in '"$cwd"'/_self.dir);; *) Exit 1;; esac
-  :
-' _self.test || st=1
-test -f _self.tmp && { rm -f _self.tmp; st=1; }
-test $st -eq 0 || exit 1
-
-$SHELL -c '
-  am_create_testdir=no
-  . ./defs || Exit 1
-  test -f self-check-dir.test
-  case `pwd` in '"$cwd"');; *) Exit 1;; esac
-' _self.test || exit 1
-
-:
diff --git a/tests/self-check-is_newest.test b/tests/self-check-is_newest.tap
similarity index 77%
rename from tests/self-check-is_newest.test
rename to tests/self-check-is_newest.tap
index 4e4e315..a41765d 100755
--- a/tests/self-check-is_newest.test
+++ b/tests/self-check-is_newest.tap
@@ -14,11 +14,16 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Sanity check for the automake testsuite.
-# Check the `is_newest' subroutine.
+# Sanity check for the automake testsuite: the `is_newest' subroutine.
 
 . ./defs || Exit 1
 
+plan_ 21
+
+# I'm a lazy typist.
+Y () { command_ok_ "is_newest $*" is_newest "$@"; }
+N () { command_ok_ "not is_newest $*" not is_newest "$@"; }
+
 : > a
 $sleep
 : > b
@@ -26,18 +31,18 @@ $sleep
 
 stat a b c || : # For debugging.
 
-is_newest c a
-is_newest b a
-is_newest a b && Exit 1
-is_newest c b
-is_newest c c
-is_newest c a b c
+Y c a
+Y b a
+N a b
+Y c b
+Y c c
+Y c a b c
 
 touch -r c d
 
 stat c d || : # For debugging.
 
-is_newest c d
+Y c d
 
 # Should work on directories too, both empty and not-empty.  An older
 # implementation of `is_newest' failed if the first argument was a
@@ -56,20 +61,20 @@ stat u v x y x/foo y/foo || : # For debugging.
 
 for older in u x; do
   for newer in v y; do
-    is_newest $newer $older
-    is_newest $older $newer && Exit 1
+    Y $newer $older
+    N $older $newer
   done
 done
 
-is_newest x/foo x
-is_newest x x/foo && Exit 1
+Y x/foo x
+N x x/foo
 
 touch -r x u
-is_newest x u
-is_newest u x
+Y x u
+Y u x
 
 # A couple of mild "stress" tests.
-is_newest y x u v
-is_newest y u x/foo a b c
+Y y x u v
+Y y u x/foo a b c
 
 :
diff --git a/tests/self-check-unindent.test b/tests/self-check-unindent.tap
similarity index 76%
rename from tests/self-check-unindent.test
rename to tests/self-check-unindent.tap
index 0a0f86f..517224a 100755
--- a/tests/self-check-unindent.test
+++ b/tests/self-check-unindent.tap
@@ -19,9 +19,27 @@
 
 . ./defs || Exit 1
 
+plan_ 22
+
+#------------------------------------------------------------------
+
+will_test () { tst=$*; }
+
+do_check ()
+{
+  command_ok_ "$tst [simple, exit status]" \
+              eval 'unindent input > got'
+  command_ok_ "$tst [simple, output]" \
+              diff exp got
+  command_ok_ "$tst [parallel, exit status]" \
+              eval 'unindent input | unindent > got'
+  command_ok_ "$tst [parallel, output]" \
+              diff exp got
+}
+
 #------------------------------------------------------------------
 
-: Leading spaces.
+will_test 'leading spaces'
 
 cat > input <<END
   1
@@ -73,15 +91,11 @@ ${tab}
 last line
 END
 
-unindent input > got
-diff exp got
-
-unindent input | unindent > got
-diff exp got
+do_check
 
 #------------------------------------------------------------------
 
-: Leading tab.
+will_test 'leading tab'
 
 cat > input <<END
 ${tab}1
@@ -131,15 +145,11 @@ ${sp}${tab}
 last line
 END
 
-unindent input > got
-diff exp got
-
-unindent input | unindent > got
-diff exp got
+do_check "leading tab"
 
 #------------------------------------------------------------------
 
-: No leading whitespace.
+will_test 'no leading whitespace'
 
 cat > input <<END
 1
@@ -164,15 +174,11 @@ END
 
 cp input exp
 
-unindent input > got
-diff exp got
-
-unindent input | unindent > got
-diff exp got
+do_check
 
 #------------------------------------------------------------------
 
-: Leading empty lines are ignored [1].
+will_test 'leading empty lines ignored (1)'
 
 cat > input <<END
 
@@ -190,15 +196,11 @@ bar
   quux
 END
 
-unindent input > got
-diff exp got
-
-unindent input | unindent > got
-diff exp got
+do_check
 
 #------------------------------------------------------------------
 
-: Leading empty lines are ignored [2].
+will_test 'leading empty lines ignored (2)'
 
 cat > input <<END
 
@@ -216,15 +218,11 @@ bar
    quux
 END
 
-unindent input > got
-diff exp got
-
-unindent input | unindent > got
-diff exp got
+do_check
 
 #------------------------------------------------------------------
 
-: More elaborated parallel use.
+will_test 'more elaborated parallel use'
 
 cat > input <<END
   x
@@ -249,7 +247,9 @@ c
 ${tab}f
 END
 
-unindent input | sed 1d | unindent > got
-diff exp got
+command_ok_ "$tst [exit status]" \
+            eval 'unindent input | sed 1d | unindent > got'
+
+command_ok_ "$tst [output]" diff exp got
 
 :
-- 
1.7.2.3




reply via email to

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