move wc tests from own subdir into a single script
authorJim Meyering <meyering@redhat.com>
Sat, 26 Apr 2008 21:40:03 +0000 (23:40 +0200)
committerJim Meyering <meyering@redhat.com>
Sun, 27 Apr 2008 19:31:33 +0000 (21:31 +0200)
* configure.ac (AC_CONFIG_FILES): Remove wc/Makefile from the list.
* tests/Makefile.am (SUBDIRS): Remove wc from the list.
(TESTS): Add misc/wc.
* tests/misc/wc: New file, derived from tests/wc/Tests.pm.
* tests/wc/Test.pm: Remove file.

configure.ac
tests/Makefile.am
tests/misc/wc [new file with mode: 0755]
tests/wc/Test.pm [deleted file]

index adf2903..6a7c5a8 100644 (file)
@@ -354,6 +354,5 @@ AC_CONFIG_FILES(
   tests/test/Makefile
   tests/tr/Makefile
   tests/uniq/Makefile
-  tests/wc/Makefile
   )
 AC_OUTPUT
index 785e438..8dde07e 100644 (file)
@@ -25,7 +25,7 @@ EXTRA_DIST =          \
 
 ## N O T E :: Do not add more names to this list.
 ## N O T E :: Even these are expected to go away.
-SUBDIRS = cut head join pr sort tac tail test tr uniq wc
+SUBDIRS = cut head join pr sort tac tail test tr uniq
 
 root_tests =                                   \
   chown/basic                                  \
@@ -141,6 +141,7 @@ TESTS =                                             \
   misc/chcon-fail                              \
   misc/selinux                                 \
   misc/cut                                     \
+  misc/wc                                      \
   misc/wc-files0-from                          \
   misc/wc-files0                               \
   misc/cat-proc                                        \
diff --git a/tests/misc/wc b/tests/misc/wc
new file mode 100755 (executable)
index 0000000..539b1dd
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Basic tests for "wc".
+
+# Copyright (C) 1997, 2003, 2006, 2008 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 3 of the License, 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/>.
+
+: ${srcdir=.}
+. $top_srcdir/tests/require-perl
+
+me=`echo $0|sed 's,.*/,,'`
+exec $PERL -w -I$top_srcdir/tests -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF
+require 5.003;
+use strict;
+
+my $prog = 'wc';
+
+# Turn off localisation of executable's ouput.
+@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+
+my $degenerate = "d41d8cd98f00b204e9800998ecf8427e";
+
+my @Tests =
+    (
+     ['a0', '-c',  {IN_PIPE=>''},            {OUT=>"0\n"}],
+     ['a1', '-l',  {IN_PIPE=>''},            {OUT=>"0\n"}],
+     ['a2', '-w',  {IN_PIPE=>''},            {OUT=>"0\n"}],
+     ['a3', '-c',  {IN_PIPE=>'x'},           {OUT=>"1\n"}],
+     ['a4', '-w',  {IN_PIPE=>'x'},           {OUT=>"1\n"}],
+     ['a5', '-w',  {IN_PIPE=>"x y\n"},       {OUT=>"2\n"}],
+     ['a6', '-w',  {IN_PIPE=>"x y\nz"},      {OUT=>"3\n"}],
+     # Remember, -l counts *newline* bytes, not logical lines.
+     ['a7', '-l',  {IN_PIPE=>"x y"},         {OUT=>"0\n"}],
+     ['a8', '-l',  {IN_PIPE=>"x y\n"},       {OUT=>"1\n"}],
+     ['a9', '-l',  {IN_PIPE=>"x\ny\n"},      {OUT=>"2\n"}],
+     ['b0', '',    {IN_PIPE=>""},         {OUT=>"      0       0       0\n"}],
+     ['b1', '',    {IN_PIPE=>"a b\nc\n"}, {OUT=>"      2       3       6\n"}],
+     ['c0', '-L',  {IN_PIPE=>"1\n12\n"},     {OUT=>"2\n"}],
+     ['c1', '-L',  {IN_PIPE=>"1\n123\n1\n"}, {OUT=>"3\n"}],
+     ['c2', '-L',  {IN_PIPE=>"\n123456"},    {OUT=>"6\n"}],
+    );
+
+my $save_temps = $ENV{DEBUG};
+my $verbose = $ENV{VERBOSE};
+
+my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose);
+exit $fail;
+EOF
diff --git a/tests/wc/Test.pm b/tests/wc/Test.pm
deleted file mode 100644 (file)
index dae08ff..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-# Test "wc".
-
-# Copyright (C) 1997, 2003, 2006 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 3 of the License, 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/>.
-
-package Test;
-require 5.002;
-use strict;
-
-$Test::input_via_stdin = 1;
-
-my @tv = (
-# test flags  input                 expected output        expected return code
-['a0', '-c',  '',                   "0\n",                          0],
-['a1', '-l',  '',                   "0\n",                          0],
-['a2', '-w',  '',                   "0\n",                          0],
-['a3', '-c',  'x',                  "1\n",                          0],
-['a4', '-w',  'x',                  "1\n",                          0],
-['a5', '-w',  "x y\n",              "2\n",                          0],
-['a6', '-w',  "x y\nz",             "3\n",                          0],
-# Remember, -l counts *newline* bytes, not logical lines.
-['a7', '-l',  "x y",                "0\n",                          0],
-['a8', '-l',  "x y\n",              "1\n",                          0],
-['a9', '-l',  "x\ny\n",             "2\n",                          0],
-['b0', '',    "",                   "0 0 0\n",                      0],
-['b1', '',    "a b\nc\n",           "2 3 6\n",                      0],
-['c0', '-L',  "1\n12\n",            "2\n",                          0],
-['c1', '-L',  "1\n123\n1\n",        "3\n",                          0],
-['c2', '-L',  "\n123456",           "6\n",                          0],
-);
-
-sub test_vector
-{
-  my $t;
-  foreach $t (@tv)
-    {
-      my ($test_name, $flags, $in, $exp, $ret) = @$t;
-      # By default, test both stdin-redirection and input from a pipe.
-      $Test::input_via{$test_name} = {REDIR => 0, PIPE => 0};
-
-      # But if test name ends with `-file', test only with file arg(s).
-      # FIXME: unfortunately, invoking wc like `wc FILE' makes it put
-      # FILE in the ouput -- and FILE is different depending on $srcdir.
-      $Test::input_via{$test_name} = {FILE => 0}
-        if $test_name =~ /-file$/;
-
-      # Now that `wc FILE' (note, with no options) produces results
-      # different from `cat FILE|wc', disable those two `PIPE' tests.
-      $flags eq ''
-       and delete $Test::input_via{$test_name}->{PIPE};
-    }
-
-  return @tv;
-}
-
-1;