bug-coreutils
[Top][All Lists]
Advanced

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

[PATCH] tests: move input-tty into a test-lib.sh function


From: Jim Meyering
Subject: [PATCH] tests: move input-tty into a test-lib.sh function
Date: Wed, 10 Sep 2008 13:19:44 +0200

Another clean-up patch.
In case you apply this, it comes before the Exit one.

>From 22e5102f1961c5552d20c3791cbc99b6b001e83f Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 7 Sep 2008 11:54:43 +0200
Subject: [PATCH] tests: move input-tty into a test-lib.sh function

* 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       |    1 -
 tests/input-tty         |   10 ----------
 tests/misc/stty         |    2 +-
 tests/misc/stty-invalid |    3 +--
 tests/misc/stty-row-col |    3 +--
 tests/mv/i-3            |    2 +-
 tests/test-lib.sh       |   13 +++++++++++++
 7 files changed, 17 insertions(+), 17 deletions(-)
 delete mode 100644 tests/input-tty

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8a58356..bc656c4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 7df1515..0000000
--- a/tests/input-tty
+++ /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
diff --git a/tests/misc/stty b/tests/misc/stty
index 8b5fbff..8216c8e 100755
--- a/tests/misc/stty
+++ b/tests/misc/stty
@@ -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
diff --git a/tests/misc/stty-invalid b/tests/misc/stty-invalid
index 168bb59..302dbe0 100755
--- a/tests/misc/stty-invalid
+++ b/tests/misc/stty-invalid
@@ -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

diff --git a/tests/misc/stty-row-col b/tests/misc/stty-row-col
index 7fc917f..8ac1143 100755
--- a/tests/misc/stty-row-col
+++ b/tests/misc/stty-row-col
@@ -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.
diff --git a/tests/mv/i-3 b/tests/mv/i-3
index eed3c8b..9d8b03e 100755
--- a/tests/mv/i-3
+++ b/tests/mv/i-3
@@ -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
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
index f386933..f0e1070 100644
--- a/tests/test-lib.sh
+++ b/tests/test-lib.sh
@@ -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
--
1.6.0.1.285.g1070




reply via email to

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