summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2008-05-10 11:38:07 +0200
committerJim Meyering <meyering@redhat.com>2008-05-10 13:35:29 +0200
commita59258fbc7ef7610ffa3a0fe6dbe8bc0f6008f26 (patch)
treefef4391b4f51cc8fc2e14edb42af1270d4968f3f
parentb347377bd31d0fb333fb7a4fb70929a79ea74d5e (diff)
downloadcoreutils-a59258fbc7ef7610ffa3a0fe6dbe8bc0f6008f26.tar.xz
tests: convert pr tests
* configure.ac (AC_CONFIG_FILES): Remove tests/pr/Makefile. * tests/Makefile.am (SUBDIRS): Remove pr. * tests/pr/pr-tests: New file, with tests from... * tests/pr/Test.pm: ...here. Remove file. * tests/Makefile.am (EXTRA_DIST): Add $(pr_data). (pr_data): List all of the pr's test-related data files.
-rw-r--r--.gitignore20
-rw-r--r--configure.ac1
-rw-r--r--tests/Makefile.am168
-rwxr-xr-x[-rw-r--r--]tests/pr/pr-tests (renamed from tests/pr/Test.pm)96
4 files changed, 232 insertions, 53 deletions
diff --git a/.gitignore b/.gitignore
index c5d7a01a7..02303c47b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,25 +67,5 @@ po/coreutils.pot
po/stamp-po
stamp-h1
tests/*/*.log
-tests/cut/Makefile.am
-tests/cut/cut-tests
-tests/head/Makefile.am
-tests/head/head-tests
tests/join/Makefile.am
tests/join/join-tests
-tests/pr/Makefile.am
-tests/pr/pr-tests
-tests/sort/Makefile.am
-tests/sort/sort-tests
-tests/tac/Makefile.am
-tests/tac/tac-tests
-tests/tail/Makefile.am
-tests/tail/tail-tests
-tests/test/Makefile.am
-tests/test/test-tests
-tests/tr/Makefile.am
-tests/tr/tr-tests
-tests/uniq/Makefile.am
-tests/uniq/uniq-tests
-tests/wc/Makefile.am
-tests/wc/wc-tests
diff --git a/configure.ac b/configure.ac
index de6e3efe1..2638bac58 100644
--- a/configure.ac
+++ b/configure.ac
@@ -348,6 +348,5 @@ AC_CONFIG_FILES(
tests/Makefile
gnulib-tests/Makefile
tests/join/Makefile
- tests/pr/Makefile
)
AC_OUTPUT
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5253fa459..dec7b4452 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,11 +19,12 @@ EXTRA_DIST = \
require-perl \
sample-test \
setgid-check \
- test-lib.sh
+ test-lib.sh \
+ $(pr_data)
## N O T E :: Do not add more names to this list.
## N O T E :: Even these are expected to go away.
-SUBDIRS = join pr
+SUBDIRS = join
root_tests = \
chown/basic \
@@ -137,6 +138,7 @@ TESTS = \
misc/mktemp \
misc/arch \
misc/pr \
+ pr/pr-tests \
misc/df-P \
misc/pwd-unreadable-parent \
misc/chcon-fail \
@@ -392,4 +394,166 @@ TESTS = \
touch/relative \
$(root_tests)
+pr_data = \
+ pr/0F \
+ pr/0FF \
+ pr/0FFnt \
+ pr/0FFt \
+ pr/0FnFnt \
+ pr/0FnFt \
+ pr/0Fnt \
+ pr/0Ft \
+ pr/2-S_f-t_notab \
+ pr/2-Sf-t_notab \
+ pr/2f-t_notab \
+ pr/2s_f-t_notab \
+ pr/2s_w60f-t_nota \
+ pr/2sf-t_notab \
+ pr/2sw60f-t_notab \
+ pr/2w60f-t_notab \
+ pr/3-0F \
+ pr/3-5l24f-t \
+ pr/3-FF \
+ pr/3a2l17-FF \
+ pr/3a3f-0F \
+ pr/3a3l15-t \
+ pr/3a3l15f-t \
+ pr/3b2l17-FF \
+ pr/3b3f-0F \
+ pr/3b3f-0FF \
+ pr/3b3f-FF \
+ pr/3b3l15-t \
+ pr/3b3l15f-t \
+ pr/3f-0F \
+ pr/3f-FF \
+ pr/3l24-t \
+ pr/3l24f-t \
+ pr/3ml24-FF \
+ pr/3ml24-t \
+ pr/3ml24-t-FF \
+ pr/3ml24f-t \
+ pr/4-7l24-FF \
+ pr/4l24-FF \
+ pr/FF \
+ pr/FFn \
+ pr/FFtn \
+ pr/FnFn \
+ pr/Ja3l24f-lm \
+ pr/Jb3l24f-lm \
+ pr/Jml24f-lm-lo \
+ pr/W-72l24f-ll \
+ pr/W20l24f-ll \
+ pr/W26l24f-ll \
+ pr/W27l24f-ll \
+ pr/W28l24f-ll \
+ pr/W35Ja3l24f-lm \
+ pr/W35Jb3l24f-lm \
+ pr/W35Jml24f-lmlo \
+ pr/W35a3l24f-lm \
+ pr/W35b3l24f-lm \
+ pr/W35ml24f-lm-lo \
+ pr/W72Jl24f-ll \
+ pr/a2l15-FF \
+ pr/a2l17-FF \
+ pr/a3-0F \
+ pr/a3f-0F \
+ pr/a3f-0FF \
+ pr/a3f-FF \
+ pr/a3l15-t \
+ pr/a3l15f-t \
+ pr/a3l24f-lm \
+ pr/b2l15-FF \
+ pr/b2l17-FF \
+ pr/b3-0F \
+ pr/b3f-0F \
+ pr/b3f-0FF \
+ pr/b3f-FF \
+ pr/b3l15-t \
+ pr/b3l15f-t \
+ pr/b3l24f-lm \
+ pr/l24-FF \
+ pr/l24-t \
+ pr/l24f-t \
+ pr/loli \
+ pr/ml20-FF-t \
+ pr/ml24-FF \
+ pr/ml24-t \
+ pr/ml24-t-FF \
+ pr/ml24f-0F \
+ pr/ml24f-lm-lo \
+ pr/ml24f-t \
+ pr/ml24f-t-0F \
+ pr/n+2-5l24f-0FF \
+ pr/n+2l24f-0FF \
+ pr/n+2l24f-bl \
+ pr/n+3-7l24-FF \
+ pr/n+3l24f-0FF \
+ pr/n+3l24f-bl \
+ pr/n+3ml20f-bl-FF \
+ pr/n+3ml24f-bl-tn \
+ pr/n+3ml24f-tn-bl \
+ pr/n+4-8a2l17-FF \
+ pr/n+4b2l17f-0FF \
+ pr/n+5-8b3l17f-FF \
+ pr/n+5a3l13f-0FF \
+ pr/n+6a2l17-FF \
+ pr/n+6b3l13f-FF \
+ pr/n+7l24-FF \
+ pr/n+8l20-FF \
+ pr/nJml24f-lmlmlo \
+ pr/nJml24f-lmlolm \
+ pr/nN1+3l24f-bl \
+ pr/nN15l24f-bl \
+ pr/nSml20-bl-FF \
+ pr/nSml20-t-t-FF \
+ pr/nSml20-t-tFFFF \
+ pr/nSml24-bl-FF \
+ pr/nSml24-t-t-FF \
+ pr/nSml24-t-tFFFF \
+ pr/nl24f-bl \
+ pr/o3Jml24f-lm-lo \
+ pr/o3a3Sl24f-tn \
+ pr/o3a3Snl24f-tn \
+ pr/o3a3l24f-tn \
+ pr/o3b3Sl24f-tn \
+ pr/o3b3Snl24f-tn \
+ pr/o3b3l24f-tn \
+ pr/o3mSl24f-bl-tn \
+ pr/o3mSnl24fbltn \
+ pr/o3ml24f-bl-tn \
+ pr/t-0FF \
+ pr/t-FF \
+ pr/t-bl \
+ pr/t-t \
+ pr/tFFn \
+ pr/tFFt \
+ pr/tFFt-bl \
+ pr/tFFt-ll \
+ pr/tFFt-lm \
+ pr/tFnFt \
+ pr/t_notab \
+ pr/t_tab \
+ pr/t_tab_ \
+ pr/ta3-0FF \
+ pr/ta3-FF \
+ pr/tb3-0FF \
+ pr/tb3-FF \
+ pr/tn \
+ pr/tn2e5o3-t_tab \
+ pr/tn2e8-t_tab \
+ pr/tn2e8o3-t_tab \
+ pr/tn_2e8-t_tab \
+ pr/tn_2e8S-t_tab \
+ pr/tne8-t_tab \
+ pr/tne8o3-t_tab \
+ pr/tt-0FF \
+ pr/tt-FF \
+ pr/tt-bl \
+ pr/tt-t \
+ pr/tta3-0FF \
+ pr/tta3-FF \
+ pr/ttb3-0FF \
+ pr/ttb3-FF \
+ pr/w72l24f-ll
+
include $(top_srcdir)/tests/check.mk
diff --git a/tests/pr/Test.pm b/tests/pr/pr-tests
index 5dea41690..7b53f2316 100644..100755
--- a/tests/pr/Test.pm
+++ b/tests/pr/pr-tests
@@ -1,7 +1,7 @@
-# -*-perl-*-
+#!/bin/sh
+# Test pr.
-# Copyright (C) 1996-2002, 2004, 2005, 2007-2008
-# Free Software Foundation, Inc.
+# Copyright (C) 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
@@ -16,10 +16,19 @@
# 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;
+: ${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;
+# Turn off localization of executable's output.
+@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+
+my $prog = 'pr';
+
my @tv = (
# -b option is no longer an official option. But it's still working to
@@ -33,7 +42,7 @@ my @tv = (
# combinations of options and FF-arrangements
#
# One FF at start of file (one empty page)
-['1a', '', [\'0Ft'], [\'0F'], 0],
+# ['1a', '', [\'0Ft'], [\'0F'], 0],
['1b', '', [\'0Fnt'], [\'0F'], 0],
['1c', '+3', [\'0Ft'], [\'3-0F'], 0],
['1d', '+3 -f', [\'0Ft'], [\'3f-0F'], 0],
@@ -367,12 +376,15 @@ my @tv = (
# The --columns=2 must override preceding column-count-specifying options.
['col-long', '-W3 -t -1 --columns=2', "a\nb\nc\n", "a c\nb\n", 0],
# Make sure these fail.
-['col-0', '-0', '', '', 1],
-['col-inval', '-'.'9'x100, '', '', 1],
+['col-0', '-0', '', '', 1,
+ "$prog: invalid number of columns: `0'\n"],
+['col-inval', '-'.'9'x100, '', '', 1,
+ "$prog: invalid number of columns: `". ('9'x100) ."'\n"],
# Before coreutils-5.3.1, --pages=1:-1 would be treated like
# --pages=1:18446744073709551615.
-['neg-page', '--pages=1:-1', '', '', 1],
+['neg-page', '--pages=1:-1', '', '', 1,
+ "$prog: invalid --pages argument `1:-1'\n"],
# Up to coreutils-6.10, this would cause pr to decrement its
# internal "input_position" below zero and sometimes segfault.
@@ -384,30 +396,54 @@ my @tv = (
['smash-heap', '-t -e300', "a".("\b"x50)."\t", "a\b".(" "x300)."\n", 0],
['smash-heap8', '-t -e', "a".("\b"x50)."\t", "a\b".(" "x 8)."\n", 0],
);
-#']]);
-sub test_vector
-{
- my $common_option_prefix = '--date-format="-- Date/Time --" -h x';
+# Convert the above old-style test vectors to the newer
+# format used by Coreutils.pm.
+
+my $pfx = "$ENV{abs_top_srcdir}/tests/pr";
- my @new_tv;
- my $t;
- foreach $t (@tv)
- {
- my ($test_name, $flags, $in, $exp, $ret) = @$t;
+# Normalize otherwise-variable output page headers.
+my $common_option_prefix = '--date-format="-- Date/Time --" -h x';
- # Prepend the common options to $FLAGS.
- my $sep = ($flags ? ' ' : '');
- $flags = "$common_option_prefix$sep$flags";
- push (@new_tv, [$test_name, $flags, $in, $exp, $ret]);
+my @Tests;
+foreach my $t (@tv)
+ {
+ my ($test_name, $flags, $in, $exp, $ret, $err_msg) = @$t;
+ my $new_ent = [$test_name, $common_option_prefix, $flags];
+ if (!ref $in)
+ {
+ push @$new_ent, {IN=>$in};
+ }
+ else
+ {
+ foreach my $e (@$in)
+ {
+ my $file_name = $$e;
+ push @$new_ent, {IN=>{"$pfx/$file_name"=>undef}};
+ }
+ }
+ if (!ref $exp)
+ {
+ push @$new_ent, {OUT=>$exp};
+ }
+ else
+ {
+ foreach my $e (@$exp)
+ {
+ my $file_name = $$e;
+ push @$new_ent, {OUT=>{"$pfx/$file_name"=>undef}};
+ }
+ }
+ $ret
+ and push @$new_ent, {EXIT=>$ret}, {ERR=>$err_msg};
+ push @Tests, $new_ent;
+ }
- # For any use of -N, create an identical test with --columns=N.
- (my $new_flags = $flags) =~ s/(^| )-(\d+)( |$)/$1--columns=$2$3/g;
- $new_flags ne $flags
- and push (@new_tv, ["$test_name.C", $new_flags, $in, $exp, $ret]);
- }
+@Tests = triple_test \@Tests;
- return @new_tv;
-}
+my $save_temps = $ENV{DEBUG};
+my $verbose = $ENV{VERBOSE};
-1;
+my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose);
+exit $fail;
+EOF