summaryrefslogtreecommitdiff
path: root/tests/ls-2
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1998-08-16 01:28:55 +0000
committerJim Meyering <jim@meyering.net>1998-08-16 01:28:55 +0000
commitbddb246b90a66b6c121ba3dcb72b9e0f68a6f24a (patch)
tree701f914b019a6a1497ccbc218a84acf16095fa4d /tests/ls-2
parente646635206283e677f92170b35b318dc66b59042 (diff)
downloadcoreutils-bddb246b90a66b6c121ba3dcb72b9e0f68a6f24a.tar.xz
*** empty log message ***
Diffstat (limited to 'tests/ls-2')
-rw-r--r--tests/ls-2/Fetish.pm22
1 files changed, 14 insertions, 8 deletions
diff --git a/tests/ls-2/Fetish.pm b/tests/ls-2/Fetish.pm
index 15978dc0e..37c3402bd 100644
--- a/tests/ls-2/Fetish.pm
+++ b/tests/ls-2/Fetish.pm
@@ -12,14 +12,14 @@ use FileHandle;
use File::Compare qw(compare);
@ISA = qw(Exporter);
-($VERSION = '$Revision: 1.6 $ ') =~ tr/[0-9].//cd;
+($VERSION = '$Revision: 1.7 $ ') =~ tr/[0-9].//cd;
@EXPORT = qw (run_tests);
my @Types = qw (IN OUT ERR EXIT);
my %Types = map {$_ => 1} @Types;
my %Zero_one_type = map {$_ => 1} qw (OUT ERR EXIT);
-
my $srcdir = $ENV{srcdir};
+my $Global_count = 1;
# A file spec: a scalar or a reference to a single-keyed hash
# ================
@@ -39,6 +39,10 @@ my $srcdir = $ENV{srcdir};
# {OUT => 'data'} put data in a temp file and compare it to stdout from cmd
# {OUT => {'filename'=>undef}} compare contents of existing filename to
# stdout from cmd
+# {OUT => {'filename'=>[$CTOR, $DTOR]}} $CTOR and $DTOR are references to
+# functions, each which is passed the single argument `filename'.
+# $CTOR must create `filename'.
+# DTOR may be omitted in which case `sub{unlink @_[0]}' is used.
# Ditto for `ERR', but compare with stderr
# {EXIT => N} expect exit status of cmd to be N
#
@@ -49,7 +53,8 @@ my $srcdir = $ENV{srcdir};
# on stdout (or stderr).
# If the EXIT-keyed one is omitted, then expect the exit status to be zero.
-my $Global_count = 1;
+# FIXME: Make sure that no junkfile is also listed as a
+# non-junkfile (i.e. with undef for contents)
sub _shell_quote ($)
{
@@ -58,9 +63,9 @@ sub _shell_quote ($)
return "'$string'";
}
-sub _create_file ($$$$$)
+sub _create_file ($$$$)
{
- my ($program_name, $test_name, $type, $file_name, $data) = @_;
+ my ($program_name, $test_name, $file_name, $data) = @_;
my $file;
if (defined $file_name)
{
@@ -74,7 +79,6 @@ sub _create_file ($$$$$)
# The test spec gave a string.
# Write it to a temp file and return tempfile name.
- #warn "writing $type `$data' to $file\n";
my $fh = new FileHandle "> $file";
die "$program_name: $file: $!\n" if ! $fh;
print $fh $data;
@@ -124,6 +128,7 @@ sub run_tests ($$$$$)
my $test_name = shift @$t;
my $expect = {};
+ # FIXME: maybe don't reset this.
$Global_count = 1;
my @args;
my $io_spec;
@@ -181,7 +186,7 @@ sub run_tests ($$$$$)
my $is_junk_file = (! defined $file_name
|| ($type eq 'IN' && defined $contents));
- my $file = _create_file ($program_name, $test_name, $type,
+ my $file = _create_file ($program_name, $test_name,
$file_name, $contents);
if ($type eq 'IN')
{
@@ -214,7 +219,7 @@ sub run_tests ($$$$$)
{
if (!exists $expect->{$eo})
{
- $expect->{$eo} = _create_file ($program_name, $test_name, $eo,
+ $expect->{$eo} = _create_file ($program_name, $test_name,
undef, '');
push @junk_files, $expect->{$eo};
}
@@ -260,6 +265,7 @@ sub run_tests ($$$$$)
}
}
+ # FIXME: maybe unlink files inside the big foreach loop?
unlink @junk_files if ! $save_temps;
return $fail;