]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: remove directory, tests/cut/
authorJim Meyering <meyering@redhat.com>
Sun, 4 May 2008 19:31:10 +0000 (21:31 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 6 May 2008 06:21:30 +0000 (08:21 +0200)
* configure.ac (AC_CONFIG_FILES): Remove tests/cut/Makefile.
* tests/Makefile.am (SUBDIRS): Remove cut.
* tests/misc/cut: Many new tests, from...
* tests/cut/Test.pm: ...here.  Remove file.

configure.ac
tests/Makefile.am
tests/cut/Test.pm [deleted file]
tests/misc/cut

index 1e0911c804b0a1686977aac9abc6fd2e5ed63332..688ade43ce7e601b56c2c651b408c25fb8578e30 100644 (file)
@@ -347,7 +347,6 @@ AC_CONFIG_FILES(
   src/Makefile
   tests/Makefile
   gnulib-tests/Makefile
-  tests/cut/Makefile
   tests/join/Makefile
   tests/pr/Makefile
   tests/sort/Makefile
index 5d352b96b1876fdc3f0b64adc81fd4741afe1687..2b00c0e09cf5f38f6fee17048224daf0302272bc 100644 (file)
@@ -23,7 +23,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 join pr sort tac tail test tr uniq
+SUBDIRS = join pr sort tac tail test tr uniq
 
 root_tests =                                   \
   chown/basic                                  \
diff --git a/tests/cut/Test.pm b/tests/cut/Test.pm
deleted file mode 100644 (file)
index b5e3d08..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-# Test 'cut'.
-
-# Copyright (C) 1996, 1997, 1998, 1999, 2003, 2004, 2007 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_default = {REDIR => 0, FILE => 0, PIPE => 0};
-
-my @tv = (
-# test flags           input           expected output expected return code
-#
-['1', '-d: -f1,3-',    "a:b:c\n",              "a:c\n",                0],
-['2', '-d: -f1,3-',    "a:b:c\n",              "a:c\n",                0],
-['3', '-d: -f2-',      "a:b:c\n",              "b:c\n",                0],
-['4', '-d: -f4',       "a:b:c\n",              "\n",                   0],
-['5', '-d: -f4',       "",                     "",                     0],
-['6', '-c4',           "123\n",                "\n",                   0],
-['7', '-c4',           "123",                  "\n",                   0],
-['8', '-c4',           "123\n1",               "\n\n",                 0],
-['9', '-c4',           "",                     "",                     0],
-['a', '-s -d: -f3-',   "a:b:c\n",              "c\n",                  0],
-['b', '-s -d: -f2,3',  "a:b:c\n",              "b:c\n",                0],
-['c', '-s -d: -f1,3',  "a:b:c\n",              "a:c\n",                0],
-# Trailing colon should not be output
-['d', '-s -d: -f1,3',  "a:b:c:\n",             "a:c\n",                0],
-['e', '-s -d: -f3-',   "a:b:c:\n",             "c:\n",                 0],
-['f', '-s -d: -f3-4',  "a:b:c:\n",             "c:\n",                 0],
-['g', '-s -d: -f3,4',  "a:b:c:\n",             "c:\n",                 0],
-# Make sure -s suppresses non-delimited lines
-['h', '-s -d: -f2,3',  "abc\n",                "",                     0],
-#
-['i', '-d: -f1-3',     ":::\n",                "::\n",                 0],
-['j', '-d: -f1-4',     ":::\n",                ":::\n",                0],
-['k', '-d: -f2-3',     ":::\n",                ":\n",                  0],
-['l', '-d: -f2-4',     ":::\n",                "::\n",                 0],
-['m', '-s -d: -f1-3',  ":::\n",                "::\n",                 0],
-['n', '-s -d: -f1-4',  ":::\n",                ":::\n",                0],
-['o', '-s -d: -f2-3',  ":::\n",                ":\n",                  0],
-['p', '-s -d: -f2-4',  ":::\n",                "::\n",                 0],
-['q', '-s -d: -f2-4',  ":::\n:\n",             "::\n\n",               0],
-['r', '-s -d: -f2-4',  ":::\n:1\n",            "::\n1\n",              0],
-['s', '-s -d: -f1-4',  ":::\n:a\n",            ":::\n:a\n",            0],
-['t', '-s -d: -f3-',   ":::\n:1\n",            ":\n\n",                0],
-# Make sure it handles empty input properly, with and without -s.
-['u', '-s -f3-',       "",                     "",                     0],
-['v', '-f3-',          "",                     "",                     0],
-# Make sure it handles empty input properly.
-['w', '-b 1',          "",                     "",                     0],
-['x', '-s -d: -f2-4',  ":\n",                  "\n",                   0],
-# Errors
-# -s may be used only with -f
-['y', '-s -b4',                ":\n",                  "",                     1],
-# You must specify bytes or fields (or chars)
-['z', '',              ":\n",                  "",                     1],
-# Empty field list
-['empty-fl', '-f \'\'',        ":\n",                  "",                     1],
-# Missing field list
-['missing-fl', '-f',   ":\n",                  "",                     1],
-# Empty byte list
-['empty-bl', '-b \'\'',        ":\n",                  "",                     1],
-# Missing byte list
-['missing-bl', '-b',   ":\n",                  "",                     1],
-
-# This test fails with cut from textutils-1.22.
-['empty-f1', '-f1',    "",                     "",                     0],
-
-['empty-f2', '-f2',    "",                     "",                     0],
-
-['o-delim', '-d: -f2,3 --out=_', "a:b:c\n",    "b_c\n",                0],
-['nul-idelim', "-d '' -f2,3 --out=_", "a\0b\0c\n", "b_c\n",            0],
-['nul-odelim', "-d: -f2,3 --out=", "a:b:c\n",  "b\0c\n",               0],
-['multichar-od', "-d: -f2,3 --out=_._", "a:b:c\n", "b_._c\n",          0],
-
-# Prior to 1.22i, you couldn't use a delimiter that would sign-extend.
-['8bit-delim', "'-d\255' -f2,3 --out=_", "a\255b\255c\n", "b_c\n",     0],
-
-# New functionality:
-['out-delim1', '-c1-3,5- --output-d=:', "abcdefg\n", "abc:efg\n",      0],
-# A totally overlapped field shouldn't change anything:
-['out-delim2', '-c1-3,2,5- --output-d=:', "abcdefg\n", "abc:efg\n",    0],
-# Partial overlap: index `2' is not at the start of a range.
-['out-delim3', '-c1-3,2-4,6 --output-d=:', "abcdefg\n", "abcd:f\n",    0],
-['out-delim3a', '-c1-3,2-4,6- --output-d=:', "abcdefg\n", "abcd:fg\n", 0],
-# Ensure that the following two commands produce the same output.
-# Before an off-by-one fix, the output from the former would not contain a `:'.
-['out-delim4', '-c4-,2-3 --output-d=:', "abcdefg\n", "bc:defg\n",      0],
-['out-delim5', '-c2-3,4- --output-d=:', "abcdefg\n", "bc:defg\n",      0],
-# This test would fail for cut from coreutils-5.0.1 and earlier.
-['out-delim6', '-c2,1-3 --output-d=:', "abc\n", "abc\n",       0],
-#
-['od-abut',    '-b1-2,3-4 --output-d=:', "abcd\n", "ab:cd\n",  0],
-['od-overlap', '-b1-2,2   --output-d=:', "abc\n",  "ab\n",     0],
-['od-overlap2', '-b1-2,2- --output-d=:', "abc\n",  "abc\n",    0],
-['od-overlap3', '-b1-3,2- --output-d=:', "abcd\n",  "abcd\n",  0],
-['od-overlap4', '-b1-3,2-3 --output-d=:', "abcd\n",  "abc\n",  0],
-['od-overlap5', '-b1-3,1-4 --output-d=:', "abcde\n",  "abcd\n",        0],
-
-# None of the following invalid ranges provoked an error up to coreutils-6.9.
-['inval1',     '-f 2-0',       '',             '',             1],
-['inval2',     '-f -',         '',             '',             1],
-['inval3',     '-f 4,-',       '',             '',             1],
-['inval4',     '-f 1-2,-',     '',             '',             1],
-['inval5',     '-f 1-,-',      '',             '',             1],
-['inval6',     '-f -1,-',      '',             '',             1],
-);
-
-# Don't use a pipe for failing tests.  Otherwise, sometimes they
-# fail so early they'd evoke the `Broken pipe' message.
-my $t;
-foreach $t (@tv)
-  {
-    my ($test_name, $flags, $in, $exp, $ret) = @$t;
-    $Test::input_via{$test_name} = {REDIR => 0, FILE => 0} if $ret;
-  }
-
-sub test_vector
-{
-  return @tv;
-}
-
-1;
index 760448c4e68fd2290aad80482fc2462bafe947b8..67e280bed7f9f2cb9eba974d90a756688242ce55 100755 (executable)
@@ -30,24 +30,132 @@ use strict;
 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
 
 my $prog = 'cut';
-my $diag = <<DIAG_EOF;
-$prog: fields and positions are numbered from 1
-Try \`cut --help' for more information.
-DIAG_EOF
+my $try = "Try \`$prog --help' for more information.\n";
+my $from_1 = "$prog: fields and positions are numbered from 1\n$try";
+my $inval = "$prog: invalid byte or field list\n$try";
+my $no_endpoint = "$prog: invalid range with no endpoint: -\n$try";
 
 my @Tests =
-  (
-   # Provoke a double-free in cut from coreutils-6.7.
-   ['dbl-free', '-f2-', {IN=>{f=>'x'}}, {IN=>{g=>'y'}}, {OUT=>"x\ny\n"}],
-
-   # This failed (as it should) even before coreutils-6.9.90,
-   # but cut from 6.9.90 produces a more useful diagnostic.
-   ['zero-1', '-b0',   {ERR=>$diag}, {EXIT => 1} ],
-
-   # Up to coreutils-6.9, specifying a range of 0-2 was not an error.
-   # It was treated just like "-2".
-   ['zero-2', '-f0-2', {ERR=>$diag}, {EXIT => 1} ],
-  );
+ (
+  # Provoke a double-free in cut from coreutils-6.7.
+  ['dbl-free', '-f2-', {IN=>{f=>'x'}}, {IN=>{g=>'y'}}, {OUT=>"x\ny\n"}],
+
+  # This failed (as it should) even before coreutils-6.9.90,
+  # but cut from 6.9.90 produces a more useful diagnostic.
+  ['zero-1', '-b0',   {ERR=>$from_1}, {EXIT => 1} ],
+
+  # Up to coreutils-6.9, specifying a range of 0-2 was not an error.
+  # It was treated just like "-2".
+  ['zero-2', '-f0-2', {ERR=>$from_1}, {EXIT => 1} ],
+
+  ['1', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}],
+  ['2', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}],
+  ['3', qw(-d: -f2-), {IN=>"a:b:c\n"}, {OUT=>"b:c\n"}],
+  ['4', qw(-d: -f4), {IN=>"a:b:c\n"}, {OUT=>"\n"}],
+  ['5', qw(-d: -f4), {IN=>""}, {OUT=>""}],
+  ['6', '-c4', {IN=>"123\n"}, {OUT=>"\n"}],
+  ['7', '-c4', {IN=>"123"}, {OUT=>"\n"}],
+  ['8', '-c4', {IN=>"123\n1"}, {OUT=>"\n\n"}],
+  ['9', '-c4', {IN=>""}, {OUT=>""}],
+  ['a', qw(-s -d:), '-f3-', {IN=>"a:b:c\n"}, {OUT=>"c\n"}],
+  ['b', qw(-s -d:), '-f2,3', {IN=>"a:b:c\n"}, {OUT=>"b:c\n"}],
+  ['c', qw(-s -d:), '-f1,3', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}],
+  # Trailing colon should not be output
+  ['d', qw(-s -d:), '-f1,3', {IN=>"a:b:c:\n"}, {OUT=>"a:c\n"}],
+  ['e', qw(-s -d:), '-f3-', {IN=>"a:b:c:\n"}, {OUT=>"c:\n"}],
+  ['f', qw(-s -d:), '-f3-4', {IN=>"a:b:c:\n"}, {OUT=>"c:\n"}],
+  ['g', qw(-s -d:), '-f3,4', {IN=>"a:b:c:\n"}, {OUT=>"c:\n"}],
+  # Make sure -s suppresses non-delimited lines
+  ['h', qw(-s -d:), '-f2,3', {IN=>"abc\n"}, {OUT=>""}],
+  #
+  ['i', qw(-d: -f1-3), {IN=>":::\n"}, {OUT=>"::\n"}],
+  ['j', qw(-d: -f1-4), {IN=>":::\n"}, {OUT=>":::\n"}],
+  ['k', qw(-d: -f2-3), {IN=>":::\n"}, {OUT=>":\n"}],
+  ['l', qw(-d: -f2-4), {IN=>":::\n"}, {OUT=>"::\n"}],
+  ['m', qw(-s -d: -f1-3), {IN=>":::\n"}, {OUT=>"::\n"}],
+  ['n', qw(-s -d: -f1-4), {IN=>":::\n"}, {OUT=>":::\n"}],
+  ['o', qw(-s -d: -f2-3), {IN=>":::\n"}, {OUT=>":\n"}],
+  ['p', qw(-s -d: -f2-4), {IN=>":::\n"}, {OUT=>"::\n"}],
+  ['q', qw(-s -d: -f2-4), {IN=>":::\n:\n"}, {OUT=>"::\n\n"}],
+  ['r', qw(-s -d: -f2-4), {IN=>":::\n:1\n"}, {OUT=>"::\n1\n"}],
+  ['s', qw(-s -d: -f1-4), {IN=>":::\n:a\n"}, {OUT=>":::\n:a\n"}],
+  ['t', qw(-s -d: -f3-), {IN=>":::\n:1\n"}, {OUT=>":\n\n"}],
+  # Make sure it handles empty input properly, with and without -s.
+  ['u', qw(-s -f3-), {IN=>""}, {OUT=>""}],
+  ['v', '-f3-', {IN=>""}, {OUT=>""}],
+  # Make sure it handles empty input properly.
+  ['w', qw(-b 1), {IN=>""}, {OUT=>""}],
+  ['x', qw(-s -d: -f2-4), {IN=>":\n"}, {OUT=>"\n"}],
+  # Errors
+  # -s may be used only with -f
+  ['y', qw(-s -b4), {IN=>":\n"}, {OUT=>""}, {EXIT=>1},
+   {ERR=>"$prog: suppressing non-delimited lines makes sense\n"
+    . "\tonly when operating on fields\n$try"}],
+  # You must specify bytes or fields (or chars)
+  ['z', '', {IN=>":\n"}, {OUT=>""}, {EXIT=>1},
+   {ERR=>"$prog: you must specify a list of bytes, characters, or fields\n$try"}],
+  # Empty field list
+  ['empty-fl', qw(-f ''), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$from_1}],
+  # Missing field list
+  ['missing-fl', qw(-f --), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$inval}],
+  # Empty byte list
+  ['empty-bl', qw(-b ''), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$from_1}],
+  # Missing byte list
+  ['missing-bl', qw(-b --), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$inval}],
+
+  # This test fails with cut from textutils-1.22.
+  ['empty-f1', '-f1', {IN=>""}, {OUT=>""}],
+
+  ['empty-f2', '-f2', {IN=>""}, {OUT=>""}],
+
+  ['o-delim', qw(-d: --out=_), '-f2,3', {IN=>"a:b:c\n"}, {OUT=>"b_c\n"}],
+  ['nul-idelim', qw(-d '' --out=_), '-f2,3', {IN=>"a\0b\0c\n"}, {OUT=>"b_c\n"}],
+  ['nul-odelim', qw(-d: --out=), '-f2,3', {IN=>"a:b:c\n"}, {OUT=>"b\0c\n"}],
+  ['multichar-od', qw(-d: --out=_._), '-f2,3', {IN=>"a:b:c\n"},
+   {OUT=>"b_._c\n"}],
+
+  # Prior to 1.22i, you couldn't use a delimiter that would sign-extend.
+  ['8bit-delim', '-d', "\255", '--out=_', '-f2,3', {IN=>"a\255b\255c\n"},
+   {OUT=>"b_c\n"}],
+
+  # New functionality:
+  ['out-delim1', '-c1-3,5-', '--output-d=:', {IN=>"abcdefg\n"},
+   {OUT=>"abc:efg\n"}],
+  # A totally overlapped field shouldn't change anything:
+  ['out-delim2', '-c1-3,2,5-', '--output-d=:', {IN=>"abcdefg\n"},
+   {OUT=>"abc:efg\n"}],
+  # Partial overlap: index `2' is not at the start of a range.
+  ['out-delim3', '-c1-3,2-4,6', '--output-d=:', {IN=>"abcdefg\n"},
+   {OUT=>"abcd:f\n"}],
+  ['out-delim3a', '-c1-3,2-4,6-', '--output-d=:', {IN=>"abcdefg\n"},
+   {OUT=>"abcd:fg\n"}],
+  # Ensure that the following two commands produce the same output.
+  # Before an off-by-one fix, the output from the former would not contain a `:'.
+  ['out-delim4', '-c4-,2-3', '--output-d=:',
+   {IN=>"abcdefg\n"}, {OUT=>"bc:defg\n"}],
+  ['out-delim5', '-c2-3,4-', '--output-d=:',
+   {IN=>"abcdefg\n"}, {OUT=>"bc:defg\n"}],
+  # This test would fail for cut from coreutils-5.0.1 and earlier.
+  ['out-delim6', '-c2,1-3', '--output-d=:', {IN=>"abc\n"}, {OUT=>"abc\n"}],
+  #
+  ['od-abut', '-b1-2,3-4', '--output-d=:', {IN=>"abcd\n"}, {OUT=>"ab:cd\n"}],
+  ['od-overlap', '-b1-2,2', '--output-d=:', {IN=>"abc\n"}, {OUT=>"ab\n"}],
+  ['od-overlap2', '-b1-2,2-', '--output-d=:', {IN=>"abc\n"}, {OUT=>"abc\n"}],
+  ['od-overlap3', '-b1-3,2-', '--output-d=:', {IN=>"abcd\n"}, {OUT=>"abcd\n"}],
+  ['od-overlap4', '-b1-3,2-3', '--output-d=:', {IN=>"abcd\n"}, {OUT=>"abc\n"}],
+  ['od-overlap5', '-b1-3,1-4', '--output-d=:', {IN=>"abcde\n"}, {OUT=>"abcd\n"}],
+
+  # None of the following invalid ranges provoked an error up to coreutils-6.9.
+  ['inval1', qw(-f 2-0), {IN=>''}, {OUT=>''}, {EXIT=>1},
+   {ERR=>"$prog: invalid decreasing range\n$try"}],
+  ['inval2', qw(-f -), {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}],
+  ['inval3', '-f', '4,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}],
+  ['inval4', '-f', '1-2,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}],
+  ['inval5', '-f', '1-,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}],
+  ['inval6', '-f', '-1,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}],
+ );
+
+@Tests = triple_test \@Tests;
 
 my $save_temps = $ENV{DEBUG};
 my $verbose = $ENV{VERBOSE};