]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Clean up some tests for use on Windows.
authorPaul Smith <psmith@gnu.org>
Sat, 5 Oct 2013 23:30:48 +0000 (19:30 -0400)
committerPaul Smith <psmith@gnu.org>
Sat, 5 Oct 2013 23:30:48 +0000 (19:30 -0400)
tests/ChangeLog
tests/scripts/features/default_names
tests/scripts/features/jobserver
tests/test_driver.pl

index 0ff50339b77e42af76d72485bf3e15fd7553422a..af7d08760b57d80a5040e8f47b46d926eb926be6 100644 (file)
@@ -1,5 +1,10 @@
 2013-10-05  Paul Smith  <psmith@gnu.org>
 
+       * test_driver.pl (run_all_tests): Rewrite to be more clear.
+       * scripts/features/jobserver: Avoid using $ENV{HOME} as it doesn't
+       exist everywhere.
+       * scripts/features/default_names: End with 1;
+
        * scripts/features/loadapi: Use new calling signatures.  Verify
        the NOEXPAND flag works.  Test with all valid function name
        characters.
index 4ce90e5f8049c7e17becf3d858ef3d4f0b543c9f..2e838806e8e9b75398da9e62430606293ff19946 100644 (file)
@@ -40,3 +40,5 @@ if ($case_sensitive) {
     compare_output("It chose Makefile\n",&get_logfile(1));
     unlink("Makefile");
 }
+
+1;
index f2c67870234e8f60817f2869418c8a1019ab4a3e..cedd4b341583f712f767bd3ad79775cca6fbce36 100644 (file)
@@ -43,10 +43,10 @@ unlink('inc.mk');
 # Or Red Hat bug https://bugzilla.redhat.com/show_bug.cgi?id=885474
 
 open(MAKEFILE,"> Makefile2");
-print MAKEFILE <<EOF;
-vpath %.c $ENV{HOME}/
+print MAKEFILE '
+vpath %.c ../
 foo:
-EOF
+';
 close(MAKEFILE);
 
 run_make_test(q!
index 457341b184841699caeac940eac358ed75797d7f..ee74db4aa3a9447ee91dbe7d80e4bb5443121f85 100644 (file)
@@ -202,7 +202,7 @@ sub toplevel
 
   print "\n";
 
-  &run_each_test;
+  run_all_tests();
 
   foreach $dir (@rmdirs)
   {
@@ -415,128 +415,133 @@ sub print_banner
   print "\n";
 }
 
-sub run_each_test
+sub run_all_tests
 {
-  $categories_run = 0;
+    $categories_run = 0;
+
+    foreach $testname (sort @TESTS) {
+        $suite_passed = 1;       # reset by test on failure
+        $num_of_logfiles = 0;
+        $num_of_tmpfiles = 0;
+        $description = "";
+        $details = "";
+        $old_makefile = undef;
+        $testname =~ s/^$scriptpath$pathsep//;
+        $perl_testname = "$scriptpath$pathsep$testname";
+        $testname =~ s/(\.pl|\.perl)$//;
+        $testpath = "$workpath$pathsep$testname";
+        # Leave enough space in the extensions to append a number, even
+        # though it needs to fit into 8+3 limits.
+        if ($short_filenames) {
+            $logext = 'l';
+            $diffext = 'd';
+            $baseext = 'b';
+            $runext = 'r';
+            $extext = '';
+        } else {
+            $logext = 'log';
+            $diffext = 'diff';
+            $baseext = 'base';
+            $runext = 'run';
+            $extext = '.';
+        }
+        $log_filename = "$testpath.$logext";
+        $diff_filename = "$testpath.$diffext";
+        $base_filename = "$testpath.$baseext";
+        $run_filename = "$testpath.$runext";
+        $tmp_filename = "$testpath.$tmpfilesuffix";
 
-  foreach $testname (sort @TESTS)
-  {
-    ++$categories_run;
-    $suite_passed = 1;       # reset by test on failure
-    $num_of_logfiles = 0;
-    $num_of_tmpfiles = 0;
-    $description = "";
-    $details = "";
-    $old_makefile = undef;
-    $testname =~ s/^$scriptpath$pathsep//;
-    $perl_testname = "$scriptpath$pathsep$testname";
-    $testname =~ s/(\.pl|\.perl)$//;
-    $testpath = "$workpath$pathsep$testname";
-    # Leave enough space in the extensions to append a number, even
-    # though it needs to fit into 8+3 limits.
-    if ($short_filenames) {
-      $logext = 'l';
-      $diffext = 'd';
-      $baseext = 'b';
-      $runext = 'r';
-      $extext = '';
-    } else {
-      $logext = 'log';
-      $diffext = 'diff';
-      $baseext = 'base';
-      $runext = 'run';
-      $extext = '.';
-    }
-    $log_filename = "$testpath.$logext";
-    $diff_filename = "$testpath.$diffext";
-    $base_filename = "$testpath.$baseext";
-    $run_filename = "$testpath.$runext";
-    $tmp_filename = "$testpath.$tmpfilesuffix";
+        setup_for_test();
 
-    &setup_for_test;          # suite-defined
+        $output = "........................................................ ";
 
-    $output = "........................................................ ";
+        substr($output,0,length($testname)) = "$testname ";
 
-    substr($output,0,length($testname)) = "$testname ";
+        print $output;
 
-    print $output;
+        $tests_run = 0;
+        $tests_passed = 0;
 
-    # Run the actual test!
-    $tests_run = 0;
-    $tests_passed = 0;
+        # Run the test!
+        $code = do $perl_testname;
 
-    $code = do $perl_testname;
+        ++$categories_run;
+        $total_tests_run += $tests_run;
+        $total_tests_passed += $tests_passed;
 
-    $total_tests_run += $tests_run;
-    $total_tests_passed += $tests_passed;
+        # How did it go?
+        if (!defined($code)) {
+            # Failed to parse or called die
+            if (length ($@)) {
+                warn "\n*** Test died ($testname): $@\n";
+            } else {
+                warn "\n*** Couldn't parse $perl_testname\n";
+            }
+            $status = "FAILED ($tests_passed/$tests_run passed)";
+        }
 
-    # How did it go?
-    if (!defined($code))
-    {
-      $suite_passed = 0;
-      if (length ($@)) {
-        warn "\n*** Test died ($testname): $@\n";
-      } else {
-        warn "\n*** Couldn't run $perl_testname\n";
-      }
-    }
-    elsif ($code == -1) {
-      $suite_passed = 0;
-    }
-    elsif ($code != 1 && $code != -1) {
-      $suite_passed = 0;
-      warn "\n*** Test returned $code\n";
-    }
+        elsif ($tests_run == 0) {
+            # Nothing was done!!
+            $status = "FAILED (no tests found!)";
+        }
 
-    if ($suite_passed) {
-      ++$categories_passed;
-      $status = "ok     ($tests_passed passed)";
-      for ($i = $num_of_tmpfiles; $i; $i--)
-      {
-        &rmfiles ($tmp_filename . &num_suffix ($i) );
-      }
+        elsif ($code == -1) {
+            # Skipped... not supported
+            $status = "N/A";
+            --$categories_run;
+        }
 
-      for ($i = $num_of_logfiles ? $num_of_logfiles : 1; $i; $i--)
-      {
-        &rmfiles ($log_filename . &num_suffix ($i) );
-        &rmfiles ($base_filename . &num_suffix ($i) );
-      }
-    }
-    elsif (!defined $code || $code > 0) {
-      $status = "FAILED ($tests_passed/$tests_run passed)";
-    }
-    elsif ($code < 0) {
-      $status = "N/A";
-      --$categories_run;
-    }
+        elsif ($code != 1) {
+            # Bad result... this shouldn't really happen.  Usually means that
+            # the suite forgot to end with "1;".
+            warn "\n*** Test returned $code\n";
+            $status = "FAILED ($tests_passed/$tests_run passed)";
+        }
 
-    # If the verbose option has been specified, then a short description
-    # of each test is printed before displaying the results of each test
-    # describing WHAT is being tested.
+        elsif ($tests_run > $tests_passed) {
+            # Lose!
+            $status = "FAILED ($tests_passed/$tests_run passed)";
+        }
 
-    if ($verbose)
-    {
-      if ($detail)
-      {
-        print "\nWHAT IS BEING TESTED\n";
-        print "--------------------";
-      }
-      print "\n\n$description\n\n";
-    }
+        else {
+            # Win!
+            ++$categories_passed;
+            $status = "ok     ($tests_passed passed)";
+
+            # Clean up
+            for ($i = $num_of_tmpfiles; $i; $i--) {
+                rmfiles($tmp_filename . num_suffix($i));
+            }
+            for ($i = $num_of_logfiles ? $num_of_logfiles : 1; $i; $i--) {
+                rmfiles($log_filename . num_suffix($i));
+                rmfiles($base_filename . num_suffix($i));
+            }
+        }
 
-    # If the detail option has been specified, then the details of HOW
-    # the test is testing what it says it is testing in the verbose output
-    # will be displayed here before the results of the test are displayed.
+        # If the verbose option has been specified, then a short description
+        # of each test is printed before displaying the results of each test
+        # describing WHAT is being tested.
 
-    if ($detail)
-    {
-      print "\nHOW IT IS TESTED\n";
-      print "----------------";
-      print "\n\n$details\n\n";
-    }
+        if ($verbose) {
+            if ($detail) {
+                print "\nWHAT IS BEING TESTED\n";
+                print "--------------------";
+            }
+            print "\n\n$description\n\n";
+        }
 
-    print "$status\n";
-  }
+        # If the detail option has been specified, then the details of HOW
+        # the test is testing what it says it is testing in the verbose output
+        # will be displayed here before the results of the test are displayed.
+
+        if ($detail) {
+            print "\nHOW IT IS TESTED\n";
+            print "----------------";
+            print "\n\n$details\n\n";
+        }
+
+        print "$status\n";
+    }
 }
 
 # If the keep flag is not set, this subroutine deletes all filenames that
@@ -713,7 +718,6 @@ sub compare_output
     &run_command_with_output(&get_difffile,$command);
   }
 
-  $suite_passed = 0;
   return 0;
 }