Ignore:
Timestamp:
Oct 29, 2008, 1:37:51 AM (17 years ago)
Author:
bird
Message:

Merged in current GNU Make code (CVS from 2008-10-28). Ref #55.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/tests/test_driver.pl

    r1973 r1993  
    77#
    88# Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
    9 # 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
     9# 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
    1010# This file is part of GNU Make.
    1111#
    12 # GNU Make is free software; you can redistribute it and/or modify it under the
    13 # terms of the GNU General Public License as published by the Free Software
    14 # Foundation; either version 2, or (at your option) any later version.
     12# GNU Make is free software; you can redistribute it and/or modify it under
     13# the terms of the GNU General Public License as published by the Free Software
     14# Foundation; either version 3 of the License, or (at your option) any later
     15# version.
    1516#
    1617# GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
    17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
    18 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     18# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     19# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
     20# details.
    1921#
    2022# You should have received a copy of the GNU General Public License along with
    21 # GNU Make; see the file COPYING.  If not, write to the Free Software
    22 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     23# this program.  If not, see <http://www.gnu.org/licenses/>.
    2324
    2425
     
    2930# variables and then calls &toplevel, which does all the real work.
    3031
    31 # $Id: test_driver.pl,v 1.21 2007/03/20 03:02:26 psmith Exp $
     32# $Id: test_driver.pl,v 1.24 2007/11/04 21:54:02 psmith Exp $
    3233
    3334
     
    4849# Yeesh.  This whole test environment is such a hack!
    4950$test_passed = 1;
     51
     52
     53# Timeout in seconds.  If the test takes longer than this we'll fail it.
     54$test_timeout = 5;
    5055
    5156
     
    681686  } else {
    682687    # See if it is a slash or CRLF problem
    683     local ($answer_mod) = $answer;
     688    local ($answer_mod, $slurp_mod) = ($answer, $slurp);
    684689
    685690    $answer_mod =~ tr,\\,/,;
    686691    $answer_mod =~ s,\r\n,\n,gs;
    687692
    688     $slurp =~ tr,\\,/,;
    689     $slurp =~ s,\r\n,\n,gs;
    690 
    691     $answer_matched = ($slurp eq $answer_mod);
     693    $slurp_mod =~ tr,\\,/,;
     694    $slurp_mod =~ s,\r\n,\n,gs;
     695
     696    $answer_matched = ($slurp_mod eq $answer_mod);
     697
     698    # If it still doesn't match, see if the answer might be a regex.
     699    if (!$answer_matched && $answer =~ m,^/(.+)/$,) {
     700      $answer_matched = ($slurp =~ /$1/);
     701      if (!$answer_matched && $answer_mod =~ m,^/(.+)/$,) {
     702          $answer_matched = ($slurp_mod =~ /$1/);
     703      }
     704    }
    692705  }
    693706
     
    790803}
    791804
    792 # run one command (passed as a list of arg 0 - n), returning 0 on success
    793 # and nonzero on failure.
    794 
    795 sub run_command
    796 {
    797   local ($code);
     805# This runs a command without any debugging info.
     806sub _run_command
     807{
     808  my $code;
    798809
    799810  # We reset this before every invocation.  On Windows I think there is only
     
    802813  resetENV();
    803814
     815  eval {
     816      local $SIG{ALRM} = sub { die "timeout\n"; };
     817      alarm $test_timeout;
     818      $code = system @_;
     819      alarm 0;
     820  };
     821  if ($@) {
     822      # The eval failed.  If it wasn't SIGALRM then die.
     823      $@ eq "timeout\n" or die;
     824
     825      # Timed out.  Resend the alarm to our process group to kill the children.
     826      $SIG{ALRM} = 'IGNORE';
     827      kill -14, $$;
     828      $code = 14;
     829  }
     830
     831  return $code;
     832}
     833
     834# run one command (passed as a list of arg 0 - n), returning 0 on success
     835# and nonzero on failure.
     836
     837sub run_command
     838{
    804839  print "\nrun_command: @_\n" if $debug;
    805   $code = system @_;
    806   print "run_command: \"@_\" returned $code.\n" if $debug;
     840  my $code = _run_command(@_);
     841  print "run_command returned $code.\n" if $debug;
    807842
    808843  return $code;
     
    816851sub run_command_with_output
    817852{
    818   local ($filename) = shift;
    819   local ($code);
    820 
    821   # We reset this before every invocation.  On Windows I think there is only
    822   # one environment, not one per process, so I think that variables set in
    823   # test scripts might leak into subsequent tests if this isn't reset--???
    824   resetENV();
    825 
     853  my $filename = shift;
     854
     855  print "\nrun_command_with_output($filename): @_\n" if $debug;
    826856  &attach_default_output ($filename);
    827   $code = system @_;
     857  my $code = _run_command(@_);
    828858  &detach_default_output;
    829 
    830   print "run_command_with_output: '@_' returned $code.\n" if $debug;
     859  print "run_command_with_output returned $code.\n" if $debug;
    831860
    832861  return $code;
Note: See TracChangeset for help on using the changeset viewer.