Ignore:
Timestamp:
Sep 15, 2006, 7:09:38 AM (19 years ago)
Author:
bird
Message:

Untested merge with GNU Make v3.81 (vendor/gnumake/2005-05-16 -> vendor/gnumake/current).

File:
1 edited

Legend:

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

    r281 r503  
    11#!/usr/bin/perl
    22# -*-perl-*-
    3 
     3#
    44# Modification history:
    55# Written 91-12-02 through 92-01-01 by Stephen McGee.
    66# Modified 92-02-11 through 92-02-22 by Chris Arthur to further generalize.
    7 # End of modification history
     7#
     8# Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
     9# 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
     10# This file is part of GNU Make.
     11#
     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.
     15#
     16# 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.
     19#
     20# 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
    824
    925# Test driver routines used by a number of test suites, including
    1026# those for SCS, make, roll_dir, and scan_deps (?).
    11 
     27#
    1228# this routine controls the whole mess; each test suite sets up a few
    1329# variables and then calls &toplevel, which does all the real work.
    1430
    15 # $Id: test_driver.pl,v 1.14 2005/02/28 07:48:23 psmith Exp $
     31# $Id: test_driver.pl,v 1.19 2006/03/10 02:20:45 psmith Exp $
    1632
    1733
     
    3349$test_passed = 1;
    3450
     51
     52# %makeENV is the cleaned-out environment.
     53%makeENV = ();
     54
     55# %extraENV are any extra environment variables the tests might want to set.
     56# These are RESET AFTER EVERY TEST!
     57%extraENV = ();
     58
     59# %origENV is the caller's original environment
     60%origENV = %ENV;
     61
     62sub resetENV
     63{
     64  # We used to say "%ENV = ();" but this doesn't work in Perl 5.000
     65  # through Perl 5.004.  It was fixed in Perl 5.004_01, but we don't
     66  # want to require that here, so just delete each one individually.
     67  foreach $v (keys %ENV) {
     68    delete $ENV{$v};
     69  }
     70
     71  %ENV = %makeENV;
     72  foreach $v (keys %extraENV) {
     73    $ENV{$v} = $extraENV{$v};
     74    delete $extraENV{$v};
     75  }
     76}
     77
    3578sub toplevel
    3679{
    37   # Get a clean environment
    38 
    39   %makeENV = ();
    40 
    4180  # Pull in benign variables from the user's environment
    4281  #
     
    5897  %origENV = %ENV;
    5998
    60   # We used to say "%ENV = ();" but this doesn't work in Perl 5.000
    61   # through Perl 5.004.  It was fixed in Perl 5.004_01, but we don't
    62   # want to require that here, so just delete each one individually.
    63 
    64   foreach $v (keys %ENV) {
    65     delete $ENV{$v};
    66   }
    67 
    68   %ENV = %makeENV;
     99  resetENV();
    69100
    70101  $| = 1;                     # unbuffered output
     
    134165    opendir (SCRIPTDIR, $scriptpath)
    135166        || &error ("Couldn't opendir $scriptpath: $!\n");
    136     @dirs = grep (!/^(\.\.?|CVS|RCS)$/, readdir (SCRIPTDIR) );
     167    @dirs = grep (!/^(\..*|CVS|RCS)$/, readdir (SCRIPTDIR) );
    137168    closedir (SCRIPTDIR);
    138169    foreach $dir (@dirs)
    139170    {
    140       next if ($dir =~ /^\.\.?$/ || $dir eq 'CVS' || $dir eq 'RCS'
    141                || ! -d "$scriptpath/$dir");
     171      next if ($dir =~ /^(\..*|CVS|RCS)$/ || ! -d "$scriptpath/$dir");
    142172      push (@rmdirs, $dir);
    143173      mkdir ("$workpath/$dir", 0777)
     
    145175      opendir (SCRIPTDIR, "$scriptpath/$dir")
    146176          || &error ("Couldn't opendir $scriptpath/$dir: $!\n");
    147       @files = grep (!/^(\.\.?|CVS|RCS)$/, readdir (SCRIPTDIR) );
     177      @files = grep (!/^(\..*|CVS|RCS|.*~)$/, readdir (SCRIPTDIR) );
    148178      closedir (SCRIPTDIR);
    149179      foreach $test (@files)
    150180      {
    151         next if $test =~ /~$/ || -d $test;
     181        -d $test and next;
    152182        push (@TESTS, "$dir/$test");
    153183      }
     
    398428      $baseext = 'b';
    399429      $extext = '';
    400    }
    401     else {
     430    } else {
    402431      $logext = 'log';
    403432      $diffext = 'diff';
     
    430459    {
    431460      $suite_passed = 0;
    432       if (length ($@))
    433       {
     461      if (length ($@)) {
    434462        warn "\n*** Test died ($testname): $@\n";
    435       }
    436       else
    437       {
     463      } else {
    438464        warn "\n*** Couldn't run $perl_testname\n";
    439465      }
     
    461487      }
    462488    }
    463     elsif ($code > 0) {
     489    elsif (!defined $code || $code > 0) {
    464490      $status = "FAILED ($tests_passed/$tests_run passed)";
    465491    }
     
    745771  local ($code);
    746772
     773  # We reset this before every invocation.  On Windows I think there is only
     774  # one environment, not one per process, so I think that variables set in
     775  # test scripts might leak into subsequent tests if this isn't reset--???
     776  resetENV();
     777
    747778  print "\nrun_command: @_\n" if $debug;
    748779  $code = system @_;
     
    761792  local ($filename) = shift;
    762793  local ($code);
     794
     795  # We reset this before every invocation.  On Windows I think there is only
     796  # one environment, not one per process, so I think that variables set in
     797  # test scripts might leak into subsequent tests if this isn't reset--???
     798  resetENV();
    763799
    764800  &attach_default_output ($filename);
Note: See TracChangeset for help on using the changeset viewer.