From: Jim Meyering Date: Sun, 26 Jan 1997 03:12:41 +0000 (+0000) Subject: Interpret `input arg is a hash X-Git-Tag: TEXTUTILS-1_21a~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=239899ae58d7bbf4c63a6ef1a6b297b372ceb572;p=thirdparty%2Fcoreutils.git 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. --- diff --git a/tests/cut/mk-script.pl b/tests/cut/mk-script.pl index 60a90d5b06..ded8914216 100644 --- a/tests/cut/mk-script.pl +++ b/tests/cut/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 <&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 < \@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 <&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 < \@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 <&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 < \@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 <&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 <