summaryrefslogtreecommitdiff
path: root/tests/head
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-01-26 03:12:41 +0000
committerJim Meyering <jim@meyering.net>1997-01-26 03:12:41 +0000
commit239899ae58d7bbf4c63a6ef1a6b297b372ceb572 (patch)
tree62370a171dead0060ef0462932425d6aa8ac5d3e /tests/head
parent2a3863e2b86fc754a14adfdc83af744ce6fca773 (diff)
downloadcoreutils-239899ae58d7bbf4c63a6ef1a6b297b372ceb572.tar.xz
Interpret `input arg is a hash
reference' as meaning that the tested program will read no input. Most of the tests for the date program use this feature. Also for date, the generated script now reflects specification (in Test.pm) of default and per-test environment settings.
Diffstat (limited to 'tests/head')
-rw-r--r--tests/head/mk-script.pl33
1 files changed, 26 insertions, 7 deletions
diff --git a/tests/head/mk-script.pl b/tests/head/mk-script.pl
index 60a90d5b0..ded891421 100644
--- a/tests/head/mk-script.pl
+++ b/tests/head/mk-script.pl
@@ -37,6 +37,7 @@ sub validate
# the top level variable to the actual string literal.
# If $SPEC is a literal Perl string (not a reference), then treat $SPEC
# as the contents of a file.
+# If $SPEC is a hash reference, then there are no inputs.
# If $SPEC is an array reference, consider each element of the array.
# If the element is a string reference, treat the string as the name of
# an existing file. Otherwise, the element must be a string and is treated
@@ -58,9 +59,20 @@ sub spec_to_list ($$$)
my @explicit_file;
my @maint_gen_file;
my @content_string;
+
+ # If SPEC is a hash reference, return empty lists.
+ if (ref $spec eq 'HASH')
+ {
+ assert ($type eq 'in');
+ return {
+ EXPLICIT => \@explicit_file,
+ MAINT_GEN => \@maint_gen_file
+ };
+ }
+
if (ref $spec)
{
- assert (ref $spec eq 'ARRAY');
+ assert (ref $spec eq 'ARRAY' || ref $spec eq 'HASH');
my $file_spec;
foreach $file_spec (@$spec)
{
@@ -225,27 +237,34 @@ foreach $test_vector (Test::test_vector ())
? '< ' : '');
my $z = $Test::common_option_prefix if defined $Test::common_option_prefix;
$z ||= '';
+ my $env = $Test::env{$test_name} || $Test::default_env || [''];
my $cmd = "\$xx $z$flags $redirect_stdin" . join (' ', @srcdir_rel_in_file)
. " > $out 2> $err_output";
- print <<EOF;
-$cmd
+ my $e;
+ foreach $e (@$env)
+ {
+ my $t_name = ($e ? "$test_name($e)" : $test_name);
+ my $e_cmd = ($e ? "$e " : '');
+ print <<EOF;
+$e_cmd$cmd
code=\$?
if test \$code != $e_ret_code ; then
- \$echo Test $test_name failed: $xx return code \$code differs from expected value $e_ret_code 1>&2
+ \$echo "Test $t_name failed: $xx return code \$code differs from expected value $e_ret_code" 1>&2
errors=`expr \$errors + 1`
else
cmp $out $exp_name
case \$? in
- 0) if test "\$VERBOSE" ; then \$echo passed $test_name; fi ;; # equal files
- 1) \$echo Test $test_name failed: files $out and $exp_name differ 1>&2;
+ 0) if test "\$VERBOSE" ; then \$echo "passed $t_name"; fi ;;
+ 1) \$echo "Test $t_name failed: files $out and $exp_name differ" 1>&2;
errors=`expr \$errors + 1` ;;
- 2) \$echo Test $test_name may have failed. 1>&2;
+ 2) \$echo "Test $t_name may have failed." 1>&2;
\$echo The command \"cmp $out $exp_name\" failed. 1>&2 ;
errors=`expr \$errors + 1` ;;
esac
fi
test -s $err_output || rm -f $err_output
EOF
+ }
}
my $n_tests = Test::test_vector ();
print <<EOF2 ;