]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
runtests.pl: cleanups
authorFabian Keil <fk@fabiankeil.de>
Thu, 15 Nov 2012 14:57:29 +0000 (15:57 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 8 Feb 2021 23:28:29 +0000 (00:28 +0100)
- show the summarized test result in the last line of the report
- do not use $_ after mapping it to a named variable
  Doing that makes the code harder to follow.
- log the restraints sorted by the number of their occurrences
- fix language when logging restraints that only occured once
- let runhttpserver() use $TESTDIR instead of $srcdir
  ... so it works if a non-default $TESTDIR is being used.

tests/runtests.pl

index 8af6bfa97c6a0057d533171db77b16050790add6..70eb867cd02a21371dbbbedbaf959211ec43eeac 100755 (executable)
@@ -1583,7 +1583,7 @@ sub runhttpserver {
     } else {
         $flags .= "--ipv$ipvnum --port 0 ";
     }
-    $flags .= "--srcdir \"$srcdir\"";
+    $flags .= "--srcdir \"$TESTDIR/..\"";
 
     my $cmd = "$exe $flags";
     my ($httppid, $pid2) = startnew($cmd, $pidfile, 15, 0);
@@ -5957,25 +5957,6 @@ my $all = $total + $skipped;
 
 runtimestats($lasttest);
 
-if($total) {
-    logmsg sprintf("TESTDONE: $ok tests out of $total reported OK: %d%%\n",
-                   $ok/$total*100);
-
-    if($ok != $total) {
-        logmsg "\nTESTFAIL: These test cases failed: $failed\n\n";
-    }
-}
-else {
-    logmsg "\nTESTFAIL: No tests were performed\n\n";
-    if(scalar(keys %enabled_keywords)) {
-        logmsg "TESTFAIL: Nothing matched these keywords: ";
-        for(keys %enabled_keywords) {
-            logmsg "$_ ";
-        }
-        logmsg "\n";
-    }
-}
-
 if($all) {
     logmsg "TESTDONE: $all tests were considered during ".
         sprintf("%.0f", $sofar) ." seconds.\n";
@@ -5983,30 +5964,58 @@ if($all) {
 
 if($skipped && !$short) {
     my $s=0;
+    # Temporary hash to print the restraints sorted by the number
+    # of their occurences
+    my %restraints;
     logmsg "TESTINFO: $skipped tests were skipped due to these restraints:\n";
 
     for(keys %skipped) {
         my $r = $_;
-        printf "TESTINFO: \"%s\" %d times (", $r, $skipped{$_};
+        my $skip_count = $skipped{$r};
+        my $log_line = sprintf("TESTINFO: \"%s\" %d time%s (", $r, $skip_count,
+                           ($skip_count == 1) ? "" : "s");
 
-        # now show all test case numbers that had this reason for being
+        # now gather all test case numbers that had this reason for being
         # skipped
         my $c=0;
         my $max = 9;
         for(0 .. scalar @teststat) {
             my $t = $_;
-            if($teststat[$_] && ($teststat[$_] eq $r)) {
+            if($teststat[$t] && ($teststat[$t] eq $r)) {
                 if($c < $max) {
-                    logmsg ", " if($c);
-                    logmsg $_;
+                    $log_line .= ", " if($c);
+                    $log_line .= $t;
                 }
                 $c++;
             }
         }
         if($c > $max) {
-            logmsg " and ".($c-$max)." more";
+            $log_line .= " and ".($c-$max)." more";
         }
-        logmsg ")\n";
+        $log_line .= ")\n";
+        $restraints{$log_line} = $skip_count;
+    }
+    foreach my $log_line (sort {$restraints{$b} <=> $restraints{$a}} keys %restraints) {
+        logmsg $log_line;
+    }
+}
+
+if($total) {
+    logmsg sprintf("TESTDONE: $ok tests out of $total reported OK: %d%%\n",
+                   $ok/$total*100);
+
+    if($ok != $total) {
+        logmsg "\nTESTFAIL: These test cases failed: $failed\n\n";
+    }
+}
+else {
+    logmsg "\nTESTFAIL: No tests were performed\n\n";
+    if(scalar(keys %enabled_keywords)) {
+        logmsg "TESTFAIL: Nothing matched these keywords: ";
+        for(keys %enabled_keywords) {
+            logmsg "$_ ";
+        }
+        logmsg "\n";
     }
 }