tests: Coreutils.pm: support running a program that is a shell built-in
authorJim Meyering <meyering@redhat.com>
Wed, 7 May 2008 23:22:37 +0000 (01:22 +0200)
committerJim Meyering <meyering@redhat.com>
Thu, 8 May 2008 07:12:43 +0000 (09:12 +0200)
* tests/Coreutils.pm (run_tests): Add support for running a
program like 'test', that is a shell built-in.

tests/Coreutils.pm

index e975965..2406dd1 100644 (file)
@@ -214,6 +214,11 @@ sub run_tests ($$$$$)
 {
   my ($program_name, $prog, $t_spec, $save_temps, $verbose) = @_;
 
+  # To indicate that $prog is a shell built-in, you'd make it a string 'ref'.
+  # E.g., call run_tests ($prog, \$prog, \@Tests, $save_temps, $verbose);
+  # If it's a ref, invoke it via "env":
+  my @prog = ref $prog ? ('env', $$prog) : $prog;
+
   # Warn about empty t_spec.
   # FIXME
 
@@ -260,7 +265,7 @@ sub run_tests ($$$$$)
   return 1 if $bad_test_name;
 
   # FIXME check exit status
-  system ($prog, '--version') if $verbose;
+  system (@prog, '--version') if $verbose;
 
   my @junk_files;
   my $fail = 0;
@@ -445,7 +450,7 @@ sub run_tests ($$$$$)
       $actual{OUT} = "$test_name.O";
       $actual{ERR} = "$test_name.E";
       push @junk_files, $actual{OUT}, $actual{ERR};
-      my @cmd = ($prog, @args, "> $actual{OUT}", "2> $actual{ERR}");
+      my @cmd = (@prog, @args, "> $actual{OUT}", "2> $actual{ERR}");
       $env_prefix
        and unshift @cmd, $env_prefix;
       defined $input_pipe_cmd