Changeset 503 for trunk/src/gmake/tests/test_driver.pl
- Timestamp:
- Sep 15, 2006, 7:09:38 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmake/tests/test_driver.pl
r281 r503 1 1 #!/usr/bin/perl 2 2 # -*-perl-*- 3 3 # 4 4 # Modification history: 5 5 # Written 91-12-02 through 92-01-01 by Stephen McGee. 6 6 # 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 8 24 9 25 # Test driver routines used by a number of test suites, including 10 26 # those for SCS, make, roll_dir, and scan_deps (?). 11 27 # 12 28 # this routine controls the whole mess; each test suite sets up a few 13 29 # variables and then calls &toplevel, which does all the real work. 14 30 15 # $Id: test_driver.pl,v 1.1 4 2005/02/28 07:48:23psmith Exp $31 # $Id: test_driver.pl,v 1.19 2006/03/10 02:20:45 psmith Exp $ 16 32 17 33 … … 33 49 $test_passed = 1; 34 50 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 62 sub 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 35 78 sub toplevel 36 79 { 37 # Get a clean environment38 39 %makeENV = ();40 41 80 # Pull in benign variables from the user's environment 42 81 # … … 58 97 %origENV = %ENV; 59 98 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(); 69 100 70 101 $| = 1; # unbuffered output … … 134 165 opendir (SCRIPTDIR, $scriptpath) 135 166 || &error ("Couldn't opendir $scriptpath: $!\n"); 136 @dirs = grep (!/^(\. \.?|CVS|RCS)$/, readdir (SCRIPTDIR) );167 @dirs = grep (!/^(\..*|CVS|RCS)$/, readdir (SCRIPTDIR) ); 137 168 closedir (SCRIPTDIR); 138 169 foreach $dir (@dirs) 139 170 { 140 next if ($dir =~ /^\.\.?$/ || $dir eq 'CVS' || $dir eq 'RCS' 141 || ! -d "$scriptpath/$dir"); 171 next if ($dir =~ /^(\..*|CVS|RCS)$/ || ! -d "$scriptpath/$dir"); 142 172 push (@rmdirs, $dir); 143 173 mkdir ("$workpath/$dir", 0777) … … 145 175 opendir (SCRIPTDIR, "$scriptpath/$dir") 146 176 || &error ("Couldn't opendir $scriptpath/$dir: $!\n"); 147 @files = grep (!/^(\. \.?|CVS|RCS)$/, readdir (SCRIPTDIR) );177 @files = grep (!/^(\..*|CVS|RCS|.*~)$/, readdir (SCRIPTDIR) ); 148 178 closedir (SCRIPTDIR); 149 179 foreach $test (@files) 150 180 { 151 next if $test =~ /~$/ || -d $test;181 -d $test and next; 152 182 push (@TESTS, "$dir/$test"); 153 183 } … … 398 428 $baseext = 'b'; 399 429 $extext = ''; 400 } 401 else { 430 } else { 402 431 $logext = 'log'; 403 432 $diffext = 'diff'; … … 430 459 { 431 460 $suite_passed = 0; 432 if (length ($@)) 433 { 461 if (length ($@)) { 434 462 warn "\n*** Test died ($testname): $@\n"; 435 } 436 else 437 { 463 } else { 438 464 warn "\n*** Couldn't run $perl_testname\n"; 439 465 } … … 461 487 } 462 488 } 463 elsif ( $code > 0) {489 elsif (!defined $code || $code > 0) { 464 490 $status = "FAILED ($tests_passed/$tests_run passed)"; 465 491 } … … 745 771 local ($code); 746 772 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 747 778 print "\nrun_command: @_\n" if $debug; 748 779 $code = system @_; … … 761 792 local ($filename) = shift; 762 793 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(); 763 799 764 800 &attach_default_output ($filename);
Note:
See TracChangeset
for help on using the changeset viewer.