[tools] winetest/build-patterns: Show regressions identified in related bugs.

Francois Gouget fgouget at codeweavers.com
Tue May 18 08:19:08 CDT 2021


If a commit has been identified as causing a bug related to a test, show
and highlight that commit even if it is older than the oldest build.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 winetest/build-patterns | 98 +++++++++++++++++++++++++++++++----------
 winetest/report.css     |  4 ++
 2 files changed, 79 insertions(+), 23 deletions(-)

diff --git a/winetest/build-patterns b/winetest/build-patterns
index 3c9b8aa84..aacbb5217 100755
--- a/winetest/build-patterns
+++ b/winetest/build-patterns
@@ -766,14 +766,35 @@ if (open(my $fh, "-|", $cmd))
 #
 # - desc
 #   The bug's one-line description.
+#
+# - regression
+#   The bug's "Regression SHA1" field. If set this identifies the Git commit
+#   causing the bug.
 my %bugs;
 
 my $old_build_date = $sortedbuilds[0]->{date};
 my $mid_build_date = $sortedbuilds[int(@sortedbuilds/2)]->{date};
 
-sub create_bug($$$)
+sub create_bug($$$$)
 {
-    my ($bugid, $mtime, $desc) = @_;
+    my ($bugid, $mtime, $regression, $desc) = @_;
+
+    my $commit;
+    if ($regression)
+    {
+        $commit = $commits{$regression};
+        if (!$commit)
+        {
+            my ($date, $summary) = get_build_info($regression);
+            $commits{$regression} = $commit = {
+                index => - at sortedbuilds, # not sorted
+                id => $regression,
+                date => $date,
+                build => $sortedbuilds[0],
+                summary => $summary,
+            };
+        }
+    }
 
     my $t = Time::Piece->strptime($mtime, "%Y-%m-%d %H:%M:%S");
     return {
@@ -782,10 +803,11 @@ sub create_bug($$$)
         class => $t < $old_build_date ? "bugold" :
                  $t < $mid_build_date ? "buginactive" : "bugactive",
         desc => $desc,
+        regression => $commit,
     };
 }
 
-$cmd = "wget -qO- '$bugweb/buglist.cgi?product=Wine&product=Wine-Testbot&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=NEEDINFO&keywords=source%2Ctestcase&keywords_type=allwords&rep_platform=x86&rep_platform=x86-64&columnlist=changeddate%2Cshort_desc&query_format=advanced&ctype=csv'";
+$cmd = "wget -qO- '$bugweb/buglist.cgi?product=Wine&product=Wine-Testbot&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=NEEDINFO&keywords=source%2Ctestcase&keywords_type=allwords&rep_platform=x86&rep_platform=x86-64&columnlist=changeddate%2Ccf_regression_sha1sum%2Cshort_desc&query_format=advanced&ctype=csv'";
 if (open(my $fh, "-|", $cmd))
 {
     <$fh>;  # skip the header line
@@ -799,15 +821,16 @@ if (open(my $fh, "-|", $cmd))
             next;
         }
 
-        my ($bugid, $mtime, $desc) = $csv->fields();
+        my ($bugid, $mtime, $commitid, $desc) = $csv->fields();
         my $teststr = $desc;
         while ($teststr =~ s~\b([_.a-z0-9-]+)(?:/tests/|/|:)([_a-z0-9]+)\b~ ~)
         {
             my ($module, $unit) = ($1, $2);
             my $test = $tests{"$module:$unit"};
             next if (!$test);
-            $bugs{$bugid} ||= create_bug($bugid, $mtime, $desc);
+            $bugs{$bugid} ||= create_bug($bugid, $mtime, $commitid, $desc);
             push @{$test->{bugs}}, $bugs{$bugid};
+            $test->{regressions}->{$commitid} = $commits{$commitid};
         }
     }
     close($fh);
@@ -820,6 +843,10 @@ if (open(my $fh, "-|", $cmd))
         foreach my $bug (sort { $a->{mtime} <=> $b->{mtime} } @{$test->{bugs}})
         {
             $test->{desc} .= "<a href='$bugweb/show_bug.cgi?id=$bug->{id}'>$bug->{id}</a> <span class='$bug->{class}'>$bug->{desc}</span>";
+            if ($bug->{regression})
+            {
+                $test->{desc} .= " (<a href='$gitweb/commitdiff/$bug->{regression}->{id}'>bisected</a>)";
+            }
             $test->{desc} .= "<br>";
         }
         $test->{desc} .= "</p>";
@@ -1069,6 +1096,7 @@ sub index2symbol($)
 }
 
 my %scope_descs = (
+    R => "Caused a test regression",
     U => "Modifies this test",
     t => "Modifies a test resource (maybe for another test)",
     m => "Modifies the module",
@@ -1091,11 +1119,16 @@ sub write_commits($$)
         }
 
         my $symbol = index2symbol($i++);
-        my ($ucount, $tcount, $tmcount) = (0, 0, 0);
+        my ($rcount, $sumcount, $tcount, $detcount) = (0, 0, 0, 0);
         foreach my $commit (sort { $a->{index} <=> $b->{index} } values %$buildcommits)
         {
             my $scope = "m";
-            if ($path2commits{$test->{source}}->{$commit->{id}})
+            if ($test->{regressions}->{$commit->{id}})
+            {
+                $scope = "R";
+                $rcount++;
+            }
+            elsif ($path2commits{$test->{source}}->{$commit->{id}})
             {
                 $scope = "U";
             }
@@ -1115,29 +1148,38 @@ sub write_commits($$)
                                $gitweb, $commit->{id},
                                short_date($build->{date}),
                                $commit->{summary});
-            if ($scope eq "U")
+            if ($scope eq "R" or $scope eq "U")
             {
-                push @udescs, ($ucount ? "\n  " : "\n$symbol."), $desc;
-                $ucount++;
+                push @udescs, ($sumcount ? "\n  " : "\n$symbol."), $desc;
+                $sumcount++;
             }
             else
             {
-                push @tmdescs, ($tmcount ? "  " : "$symbol."), $desc, "\n";
-                $tmcount++;
+                push @tmdescs, ($detcount ? "  " : "$symbol."), $desc, "\n";
+                $detcount++;
             }
         }
-        push @udescs, " <i>[+$tmcount in details]</i>" if ($ucount and $tmcount);
-
-        my @impacts;
-        push @impacts, "this test" if ($ucount);
-        push @impacts, "test resources" if ($tcount);
-        push @impacts, "the module" if ($tmcount > $tcount);
-        my $scope = $ucount ? "U" : $tcount ? "t" : "m";
-        my $count = $ucount + $tmcount;
-        printf $html "<a class='commit%s' title='%s : %s commit%s to %s'>%s</a>",
+        push @udescs, " <i>[+$detcount in details]</i>" if ($sumcount and $detcount);
+
+        my @desc;
+        push @desc, "this test" if ($sumcount > $rcount);
+        push @desc, "test resources" if ($tcount);
+        push @desc, "the module" if ($detcount > $tcount);
+        if (@desc)
+        {
+            my $count = $sumcount + $detcount - $rcount;
+            @desc = ( sprintf("%s commit%s to %s", $count,
+                              $count > 1 ? "s" : "", join(", ", @desc)) );
+        }
+        if ($rcount)
+        {
+            unshift @desc, sprintf("%s regression%s", $rcount,
+                                   $rcount > 1 ? "s" : "");
+        }
+        my $scope = $rcount ? "R" : $sumcount ? "U" : $tcount ? "t" : "m";
+        printf $html "<a class='commit%s' title='%s : %s'>%s</a>",
                      $scope, short_date($build->{date}),
-                     $count, $count > 1 ? "s" : "",
-                     join(", ", @impacts), $symbol;
+                     join(", ", @desc), $symbol;
     }
     print $html "</div> <i>← potentially related commits</i>\n";
 
@@ -1255,6 +1297,16 @@ EOF
         $test->{colors} = {};
         $test->{commits} = {};
 
+        # The regression commits may only impact the results in Wine.
+        # Add them even if only reporting on the Windows results.
+        foreach my $bug (@{$test->{bugs}})
+        {
+            my $commit = $bug->{regression};
+            next if (!$commit);
+            my $buildname = $commit->{build}->{name};
+            $test->{commits}->{$buildname}->{$commit->{id}} = $commit;
+        }
+
         my $has_wine_failures;
         my $first = @sortedbuilds;
         my $last = -1;
diff --git a/winetest/report.css b/winetest/report.css
index 05ee035a4..80be53dbe 100644
--- a/winetest/report.css
+++ b/winetest/report.css
@@ -118,6 +118,10 @@ div.pattern :hover   { color: black; text-decoration: underline; }
     background-color: #80aaff;
 }
 
+.commitR {
+    color: #cc0000;
+    font-weight: bold;
+}
 .commitU {
     font-weight: bold;
 }
-- 
2.20.1



More information about the wine-devel mailing list