*** empty log message ***
[coreutils.git] / tests / fmt / basic
blobbbc7db2e713ba2642234054ca2431ef40bee20c5
1 #!/bin/sh
2 # -*- perl -*-
4 : ${PERL=perl}
5 : ${srcdir=.}
7 $PERL -e 1 > /dev/null 2>&1 || {
8 echo 1>&2 "$0: configure didn't find a usable version of Perl," \
9 "so can't run this test"
10 exit 77
13 # Export this to avoid hassles when run in a UTF-8 locale,
14 # since we use 8-bit characters below, and those values are
15 # interpolated into strings (to perform substitution) in Fetish.pm.
16 LC_ALL=C
17 export LC_ALL
19 exec $PERL -w -I$srcdir/.. -MFetish -- - <<\EOF
20 require 5.003;
21 use strict;
23 (my $program_name = $0) =~ s|.*/||;
25 my @Tests =
27 ['8-bit-pfx', qw (-p 'ç'),
28 {IN=> "ça\nçb\n"},
29 {OUT=>"ça b\n"}],
30 ['wide-1', '-32768', {IN=> "a\n"}, {OUT=>"a\n"}],
31 ['wide-2', '-2147483647', {IN=> "a\n"}, {OUT=>"a\n"}],
32 ['bad-suffix', '-72x', {IN=> ''},
33 {ERR => "fmt: invalid width option: `-72x'\n"}, {EXIT => 1}],
34 ['no-file', 'no-such-file',
35 {ERR => "fmt: cannot open `no-such-file' for reading:"
36 . " No such file or directory\n"}, {EXIT => 1}],
37 ['obs-1', '-c -72',
38 {ERR => "fmt: invalid option -- 7; -WIDTH is recognized only when it"
39 . " is the first\noption; use -w N instead\n"
40 . "Try `fmt --help' for more information.\n" }, {EXIT => 1}],
43 my $save_temps = $ENV{DEBUG};
44 my $verbose = $ENV{VERBOSE};
46 my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
47 my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
48 exit $fail;
49 EOF