coreutils
[Top][All Lists]
Advanced

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

[PATCH] tests: remove crufty test=test_name code from old tests


From: Jim Meyering
Subject: [PATCH] tests: remove crufty test=test_name code from old tests
Date: Mon, 23 Jan 2012 14:45:33 +0100

Some old tests in tests/rm/* still had remnants showing that
they pre-dated our use of init.sh and similar frameworks.
Here's a clean-up patch:

>From dec02bb98ec59fc1a5a0ed6ae1dda2bda69af111 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 23 Jan 2012 14:42:10 +0100
Subject: [PATCH] tests: remove crufty test=test_name code from old tests

Before init.sh and similar, we would set test=test_name, and then
construct temporary file names using $test.  Now that each
init.sh-using test is in its own directory, that practice is unwelcome.
Remove bad examples.
* tests/rm/f-1: Per above.
* tests/rm/i-1: Likewise.
* tests/rm/interactive-always: Likewise.
* tests/rm/interactive-once: Likewise.
* tests/rm/ir-1: Likewise.
* tests/rm/r-1: Likewise.
---
 tests/rm/f-1                |    2 --
 tests/rm/i-1                |   10 ++++------
 tests/rm/interactive-always |   16 +++++++---------
 tests/rm/interactive-once   |   22 ++++++++++------------
 tests/rm/ir-1               |    6 ++----
 tests/rm/r-1                |   12 ++++--------
 6 files changed, 27 insertions(+), 41 deletions(-)

diff --git a/tests/rm/f-1 b/tests/rm/f-1
index 46e9e6b..e24ff12 100755
--- a/tests/rm/f-1
+++ b/tests/rm/f-1
@@ -16,8 +16,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

-test=f-1
-
 . "${srcdir=.}/init.sh"; path_prepend_ ../src
 print_ver_ rm

diff --git a/tests/rm/i-1 b/tests/rm/i-1
index e452c2d..df023a8 100755
--- a/tests/rm/i-1
+++ b/tests/rm/i-1
@@ -16,8 +16,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

-test=i-1
-
 . "${srcdir=.}/init.sh"; path_prepend_ ../src
 print_ver_ rm

@@ -26,14 +24,14 @@ mkdir -p $t || framework_failure_
 echo > $t/a || framework_failure_
 test -f $t/a || framework_failure_

-echo y > $t/$test.Iy
-echo n > $t/$test.In
+echo y > $t/in-y
+echo n > $t/in-n

-rm -i $t/a < $t/$test.In > /dev/null 2>&1 || fail=1
+rm -i $t/a < $t/in-n > /dev/null 2>&1 || fail=1
 # The file should not have been removed.
 test -f $t/a || fail=1

-rm -i $t/a < $t/$test.Iy > /dev/null 2>&1 || fail=1
+rm -i $t/a < $t/in-y > /dev/null 2>&1 || fail=1
 # The file should have been removed this time.
 test -f $t/a && fail=1

diff --git a/tests/rm/interactive-always b/tests/rm/interactive-always
index 41c8f41..6312cba 100755
--- a/tests/rm/interactive-always
+++ b/tests/rm/interactive-always
@@ -16,8 +16,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

-test=interactive-always
-
 . "${srcdir=.}/init.sh"; path_prepend_ ../src
 print_ver_ rm

@@ -25,7 +23,7 @@ touch file1-1 file1-2 file2-1 file2-2 file3-1 file3-2 file4-1 
file4-2 \
   || framework_failure_
 # If asked, answer no to first question, then yes to second.
 echo 'n
-y' > $test.I || framework_failure_
+y' > in || framework_failure_
 rm -f out err || framework_failure_


@@ -33,36 +31,36 @@ rm -f out err || framework_failure_
 # 'echo .' is inserted after each rm to make it obvious what was asked.

 echo 'no WHEN' > err || fail=1
-rm -R --interactive file1-* < $test.I >> out 2>> err || fail=1
+rm -R --interactive file1-* < in >> out 2>> err || fail=1
 echo . >> err || fail=1
 test -f file1-1 || fail=1
 test -f file1-2 && fail=1

 echo 'WHEN=never' >> err || fail=1
-rm -R --interactive=never file2-* < $test.I >> out 2>> err || fail=1
+rm -R --interactive=never file2-* < in >> out 2>> err || fail=1
 echo . >> err || fail=1
 test -f file2-1 && fail=1
 test -f file2-2 && fail=1

 echo 'WHEN=once' >> err || fail=1
-rm -R --interactive=once file3-* < $test.I >> out 2>> err || fail=1
+rm -R --interactive=once file3-* < in >> out 2>> err || fail=1
 echo . >> err || fail=1
 test -f file3-1 || fail=1
 test -f file3-2 || fail=1

 echo 'WHEN=always' >> err || fail=1
-rm -R --interactive=always file4-* < $test.I >> out 2>> err || fail=1
+rm -R --interactive=always file4-* < in >> out 2>> err || fail=1
 echo . >> err || fail=1
 test -f file4-1 || fail=1
 test -f file4-2 && fail=1

 echo '-f overrides --interactive' >> err || fail=1
-rm -R --interactive=once -f file1-* < $test.I >> out 2>> err || fail=1
+rm -R --interactive=once -f file1-* < in >> out 2>> err || fail=1
 echo . >> err || fail=1
 test -f file1-1 && fail=1

 echo '--interactive overrides -f' >> err || fail=1
-rm -R -f --interactive=once file4-* < $test.I >> out 2>> err || fail=1
+rm -R -f --interactive=once file4-* < in >> out 2>> err || fail=1
 echo . >> err || fail=1
 test -f file4-1 || fail=1

diff --git a/tests/rm/interactive-once b/tests/rm/interactive-once
index 5c4bd93..982d1a4 100755
--- a/tests/rm/interactive-once
+++ b/tests/rm/interactive-once
@@ -16,16 +16,14 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

-test=interactive-once
-
 . "${srcdir=.}/init.sh"; path_prepend_ ../src
 print_ver_ rm

 mkdir -p dir1-1 dir2-1 dir2-2 || framework_failure_
 touch file1-1 file2-1 file2-2 file2-3 file3-1 file3-2 file3-3 file3-4 \
   || framework_failure_
-echo y > $test.Iy || framework_failure_
-echo n > $test.In || framework_failure_
+echo y > in-y || framework_failure_
+echo n > in-n || framework_failure_
 rm -f out err || framework_failure_


@@ -33,19 +31,19 @@ rm -f out err || framework_failure_
 # 'echo .' is inserted after each rm to make it obvious what was asked.

 echo 'one file, no recursion' > err || fail=1
-rm -I file1-* < $test.In >> out 2>> err || fail=1
+rm -I file1-* < in-n >> out 2>> err || fail=1
 echo . >> err || fail=1
 test -f file1-1 && fail=1

 echo 'three files, no recursion' >> err || fail=1
-rm -I file2-* < $test.In >> out 2>> err || fail=1
+rm -I file2-* < in-n >> out 2>> err || fail=1
 echo . >> err || fail=1
 test -f file2-1 && fail=1
 test -f file2-2 && fail=1
 test -f file2-3 && fail=1

 echo 'four files, no recursion, answer no' >> err || fail=1
-rm -I file3-* < $test.In >> out 2>> err || fail=1
+rm -I file3-* < in-n >> out 2>> err || fail=1
 echo . >> err || fail=1
 test -f file3-1 || fail=1
 test -f file3-2 || fail=1
@@ -53,7 +51,7 @@ test -f file3-3 || fail=1
 test -f file3-4 || fail=1

 echo 'four files, no recursion, answer yes' >> err || fail=1
-rm -I file3-* < $test.Iy >> out 2>> err || fail=1
+rm -I file3-* < in-y >> out 2>> err || fail=1
 echo . >> err || fail=1
 test -f file3-1 && fail=1
 test -f file3-2 && fail=1
@@ -61,23 +59,23 @@ test -f file3-3 && fail=1
 test -f file3-4 && fail=1

 echo 'one file, recursion, answer no' >> err || fail=1
-rm -I -R dir1-* < $test.In >> out 2>> err || fail=1
+rm -I -R dir1-* < in-n >> out 2>> err || fail=1
 echo . >> err || fail=1
 test -d dir1-1 || fail=1

 echo 'one file, recursion, answer yes' >> err || fail=1
-rm -I -R dir1-* < $test.Iy >> out 2>> err || fail=1
+rm -I -R dir1-* < in-y >> out 2>> err || fail=1
 echo . >> err || fail=1
 test -d dir1-1 && fail=1

 echo 'multiple files, recursion, answer no' >> err || fail=1
-rm -I -R dir2-* < $test.In >> out 2>> err || fail=1
+rm -I -R dir2-* < in-n >> out 2>> err || fail=1
 echo . >> err || fail=1
 test -d dir2-1 || fail=1
 test -d dir2-2 || fail=1

 echo 'multiple files, recursion, answer yes' >> err || fail=1
-rm -I -R dir2-* < $test.Iy >> out 2>> err || fail=1
+rm -I -R dir2-* < in-y >> out 2>> err || fail=1
 echo . >> err || fail=1
 test -d dir2-1 && fail=1
 test -d dir2-2 && fail=1
diff --git a/tests/rm/ir-1 b/tests/rm/ir-1
index 89f4c43..ea68745 100755
--- a/tests/rm/ir-1
+++ b/tests/rm/ir-1
@@ -16,8 +16,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

-test=ir-1
-
 . "${srcdir=.}/init.sh"; path_prepend_ ../src
 print_ver_ rm

@@ -27,7 +25,7 @@ mkdir -p $t $t/a $t/b $t/c || framework_failure_
 > $t/b/bb || framework_failure_
 > $t/c/cc || framework_failure_

-cat <<EOF > $test.I
+cat <<EOF > in
 y
 y
 y
@@ -44,7 +42,7 @@ EOF
 # Remove all but one of a, b, c -- I doubt that this test can portably
 # determine which one was removed based on order of dir entries.
 # This is a good argument for switching to a dejagnu-style test suite.
-rm --verbose -i -r $t < $test.I > /dev/null 2>&1 || fail=1
+rm --verbose -i -r $t < in > /dev/null 2>&1 || fail=1

 # $t should not have been removed.
 test -d $t || fail=1
diff --git a/tests/rm/r-1 b/tests/rm/r-1
index 97d0959..6fded41 100755
--- a/tests/rm/r-1
+++ b/tests/rm/r-1
@@ -17,29 +17,25 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

-test=r-1
-
 . "${srcdir=.}/init.sh"; path_prepend_ ../src
 print_ver_ rm

 mkdir a a/a || framework_failure_
 > b || framework_failure_

-cat <<\EOF > $test.E || framework_failure_
+cat <<\EOF > exp || framework_failure_
 removed directory: 'a/a'
 removed directory: 'a'
 removed 'b'
 EOF

-rm --verbose -r a b > $test.O || fail=1
+rm --verbose -r a b > out || fail=1

 for d in $dirs; do
-  if test -d $d; then
-    fail=1
-  fi
+  test -d $d && fail=1
 done

 # Compare expected and actual output.
-compare $test.E $test.O || fail=1
+compare exp out || fail=1

 Exit $fail
--
1.7.9.rc2.2.g183d6



reply via email to

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