tests: move input-tty into a test-lib.sh function
authorJim Meyering <meyering@redhat.com>
Sun, 7 Sep 2008 09:54:43 +0000 (11:54 +0200)
committerJim Meyering <meyering@redhat.com>
Mon, 8 Sep 2008 06:20:03 +0000 (08:20 +0200)
* tests/test-lib.sh (require_controlling_input_terminal_): New function, from
* tests/input-tty: ...here.  Remove file.
* tests/Makefile.am (EXTRA_DIST): Remove input-tty.
* tests/mv/i-3: Use the function, not the file.
* tests/misc/stty: Likewise.
* tests/misc/stty-row-col: Likewise.
* tests/misc/stty-invalid: Likewise.

tests/Makefile.am
tests/input-tty [deleted file]
tests/misc/stty
tests/misc/stty-invalid
tests/misc/stty-row-col
tests/mv/i-3
tests/test-lib.sh

index 8a58356..bc656c4 100644 (file)
@@ -11,7 +11,6 @@ EXTRA_DIST =          \
   README               \
   check.mk             \
   envvar-check         \
-  input-tty            \
   lang-default         \
   other-fs-tmpdir      \
   require-perl         \
diff --git a/tests/input-tty b/tests/input-tty
deleted file mode 100644 (file)
index 7df1515..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-# Require a controlling input `terminal'.
-
-tty -s || have_input_tty=no
-test -t 1 || have_input_tty=no
-if test "$have_input_tty" = no; then
-  echo "$0: This test must have a controlling input \`terminal'," 1>&2
-  echo "  so it may not be run via \`batch', \`at', or \`rsh'." 1>&2
-  echo "  On some systems, it may not even be run in the background." 1>&2
-  (exit 77); exit 77
-fi
index 8b5fbff..8216c8e 100755 (executable)
@@ -22,8 +22,8 @@ if test "$VERBOSE" = yes; then
 fi
 
 # Make sure there's a tty on stdin.
-. $srcdir/input-tty
 . $srcdir/test-lib.sh
+require_controlling_input_terminal_
 
 # The following list of reversible options was generated with
 # grep -w REV stty.c|sed -n '/^  {"/{s//REV_/;s/".*/=1/;p;}'|fmt
index 168bb59..302dbe0 100755 (executable)
@@ -21,9 +21,8 @@ if test "$VERBOSE" = yes; then
   stty --version
 fi
 
-# Make sure there's a tty on stdin.
-. $srcdir/input-tty
 . $srcdir/test-lib.sh
+require_controlling_input_terminal_
 
 fail=0
 
index 7fc917f..8ac1143 100755 (executable)
@@ -36,9 +36,8 @@ export COLUMNS
 LC_ALL=C
 export LC_ALL
 
-# Make sure there's a tty on stdin.
-. $srcdir/input-tty
 . $srcdir/test-lib.sh
+require_controlling_input_terminal_
 
 # Versions of GNU stty from shellutils-1.9.2c and earlier failed
 # tests #2 and #4 when run on SunOS 4.1.3.
index eed3c8b..9d8b03e 100755 (executable)
@@ -22,8 +22,8 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/input-tty
 . $srcdir/test-lib.sh
+require_controlling_input_terminal_
 skip_if_root_
 
 touch f g h i || framework_failure
index f386933..f0e1070 100644 (file)
@@ -57,6 +57,19 @@ require_strace_()
     skip_test_ 'strace -qe "'"$1"'" does not work'
 }
 
+# Require a controlling input `terminal'.
+require_controlling_input_terminal_()
+{
+  tty -s || have_input_tty=no
+  test -t 1 || have_input_tty=no
+  if test "$have_input_tty" = no; then
+    echo "$0: This test must have a controlling input \`terminal'," 1>&2
+    echo "  so it may not be run via \`batch', \`at', or \`rsh'." 1>&2
+    echo "  On some systems, it may not even be run in the background." 1>&2
+    (exit 77); exit 77
+  fi
+}
+
 require_built_()
 {
   skip_=no