[Tools] winetest: Add some structure to the scripts.

Francois Gouget fgouget at codeweavers.com
Wed May 24 18:13:47 CDT 2017


As far as the behavior is concerned this is a no-op.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 winetest/build-errors |   8 +++-
 winetest/build-index  |  84 +++++++++++++++++++++++------------
 winetest/dissect      | 106 +++++++++++++++++++++++++++++++-------------
 winetest/gather       | 120 ++++++++++++++++++++++++++++++++------------------
 4 files changed, 215 insertions(+), 103 deletions(-)

diff --git a/winetest/build-errors b/winetest/build-errors
index a719fb50..b5625032 100755
--- a/winetest/build-errors
+++ b/winetest/build-errors
@@ -37,6 +37,10 @@ use vars qw/$workdir/;
 require "winetest.conf";
 
 
+#
+# Common helpers
+#
+
 use POSIX qw(locale_h strftime);
 setlocale(LC_ALL, "C");
 
@@ -47,7 +51,9 @@ sub long_date($)
 }
 
 
-# generate a table of the errors encountered during processing
+#
+# Generate a table of the errors encountered during processing
+#
 
 chdir($workdir) or die "could not chdir to the work directory: $!";
 
diff --git a/winetest/build-index b/winetest/build-index
index d301f98d..770ca9a6 100755
--- a/winetest/build-index
+++ b/winetest/build-index
@@ -38,6 +38,10 @@ use vars qw/$workdir $gitdir $gitweb/;
 require "winetest.conf";
 
 
+#
+# Common helpers
+#
+
 $ENV{GIT_DIR} = $gitdir;
 
 sub get_build_info($)
@@ -70,6 +74,8 @@ sub short_date($)
 }
 
 
+# This should match the definitions in gather
+
 my %w95     = (name => "Win95");
 my %w98     = (name => "Win98");
 my %me      = (name => "Me");
@@ -95,9 +101,11 @@ my @groups = (\%w95, \%w98, \%me, \%nt3, \%nt4, \%w2k, \%xp, \%w2k3, \%vista, \%
               \%unknown, \%linux, \%mac, \%bsd, \%solaris, \%wine);
 
 
-chdir($workdir) or die "could not chdir to the work directory: $!";
+#
+# Grab the build list and archive the old results
+#
 
-# read the test data dir
+chdir($workdir) or die "could not chdir to the work directory: $!";
 
 my @builds;
 my @too_old;
@@ -125,32 +133,16 @@ closedir(DIR);
 @builds = sort { $b->{date} <=> $a->{date} } @builds;
 
 # remove the too old results
-foreach my $build (@too_old) { rename "data/$build", "old-data/$build"; }
-
-# count how many test runs we have for each version
-
-my %versions = ();
-
-foreach my $build (@builds)
+foreach my $build (@too_old)
 {
-    my %build_ver = ();
-    if (open TOTAL, "data/$build->{name}/total.txt" )
-    {
-        while (<TOTAL>)
-        {
-            if (/^([A-Za-z0-9]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)(?:\s+(\d+))?/)
-            {
-                my ($name, $runs, $tests, $errors, $todos, $successes) = ($1, $2, $3, $4, $5, $6);
-                $versions{$name}++;
-                $build_ver{$name} = [ $runs, $tests, $errors, $todos, $successes ];
-            }
-        }
-        close TOTAL;
-    }
-    $build->{versions} = \%build_ver;
+    rename "data/$build", "old-data/$build";
 }
 
-# load summary files
+
+#
+# Read each build's summary.txt file
+# This gets us the statistics for the global per-test-unit index.
+#
 
 my %alltests = ();
 
@@ -166,7 +158,10 @@ foreach my $build (@builds)
     close SUM;
 }
 
-# build the tests linked list
+
+#
+# Link the build the test units together
+#
 
 my $prev;
 foreach my $test (sort keys %alltests)
@@ -176,7 +171,10 @@ foreach my $test (sort keys %alltests)
     $prev = $test;
 }
 
-# output the html files for individual test runs
+
+#
+# Write the test unit index pages
+#
 
 foreach my $test (keys %alltests)
 {
@@ -245,6 +243,38 @@ EOF
     rename "data/tests/$test.html.new", "data/tests/$test.html" or unlink "data/tests/$test.html.new";
 }
 
+
+#
+# Read each build's total.txt file
+# This gets us the statistics for the main index page.
+#
+
+my %versions = ();
+
+foreach my $build (@builds)
+{
+    my %build_ver = ();
+    if (open TOTAL, "data/$build->{name}/total.txt" )
+    {
+        while (<TOTAL>)
+        {
+            if (/^([A-Za-z0-9]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)(?:\s+(\d+))?/)
+            {
+                my ($name, $runs, $tests, $errors, $todos, $successes) = ($1, $2, $3, $4, $5, $6);
+                $versions{$name}++;
+                $build_ver{$name} = [ $runs, $tests, $errors, $todos, $successes ];
+            }
+        }
+        close TOTAL;
+    }
+    $build->{versions} = \%build_ver;
+}
+
+
+#
+# Write the global index page
+#
+
 open OUT, ">data/index.html.new" or die "cannot create 'data/index.html.new'";
 
 print OUT <<"EOF";
diff --git a/winetest/dissect b/winetest/dissect
index f94c621f..05565985 100755
--- a/winetest/dissect
+++ b/winetest/dissect
@@ -60,6 +60,10 @@ my $minimum_report_version=4;
 my $summary_version=4;
 
 
+#
+# Common helpers
+#
+
 $ENV{GIT_DIR} = $gitdir;
 
 sub get_build_info($)
@@ -92,12 +96,32 @@ sub short_date($)
 }
 
 
-use File::Temp qw/tempdir/;
-use Errno qw/ENOTEMPTY/;
+#
+# Command line processing
+#
+
+chdir($workdir) or die "could not chdir to the work directory: $!";
 
+my ($update, $report);
+if (defined $ARGV[0] and $ARGV[0] eq "--update") {
+    $report = $ARGV[1];
+    $update = 1;
+} else {
+    ($report, undef) = glob "queue/rep*/report";
+}
+exit 2 unless (defined $report && -f $report);
+
+my $tmpdir = $report;
+$tmpdir =~ s|^(.+)/report$|$1|;
+
+
+#
+# Check the report version, build id and tag
+#
 
-my ($update, $tmpdir, $tag);
+use File::Temp qw/tempdir/;
 
+my $tag;
 sub mydie(@)
 {
     my $label = $tag ? $tag : "<notag>";
@@ -117,29 +141,6 @@ sub mydie(@)
     exit 1;
 }
 
-my @boxes;
-
-sub create_box($$$)
-{
-    my ($id, $class, $title) = @_;
-    my $box = { id => $id, class => $class, title => $title, data => "" };
-    push @boxes, $box;
-    return $box;
-}
-
-chdir($workdir) or die "could not chdir to the work directory: $!";
-
-my $report;
-if (defined $ARGV[0] and $ARGV[0] eq "--update") {
-    $report = $ARGV[1];
-    $update = 1;
-} else {
-    ($report, undef) = glob "queue/rep*/report";
-}
-exit 2 unless (defined $report && -f $report);
-
-($tmpdir = $report) =~ s|^(.+)/report$|$1|;
-
 open IN, "<:raw", $report or mydie "unable to open '$report' for reading: $!\n";
 open SUM, ">$tmpdir/summary.txt" or mydie "unable to open '$tmpdir/summary.txt' for writing: $!\n";
 
@@ -164,13 +165,27 @@ my $archive = "winetest-$shortbuild.exe";
 my ($date, $_subject) = get_build_info($testbuild);
 my $short_date = short_date($date);
 
-
 $_ = <IN>;
 if (/^Archive: /) { $_ = <IN>; }  # ignore Archive header
 
 /^Tag: ([-.0-9a-zA-Z]*)\r?$/ or mydie "no tag line: $_";
 $tag = $1;
 
+
+#
+# Parse and check the report header
+#
+
+my @boxes;
+
+sub create_box($$$)
+{
+    my ($id, $class, $title) = @_;
+    my $box = { id => $id, class => $class, title => $title, data => "" };
+    push @boxes, $box;
+    return $box;
+}
+
 $_ = <IN>;
 /^Build info:\r?$/ or mydie "no Build info header: $_";
 my $box = create_box( "version", "version", "$tag $short_date information" );
@@ -287,6 +302,11 @@ if ($wine_build) {
     $merge_base eq $testbuild or mydie "wine build '$wine_build' not a descendant of build $testbuild\n";
 }
 
+
+#
+# Parse the 'Dll info' section
+#
+
 my $user_skips = 0;
 my $failed_tests = 0;
 my %dllinfo;
@@ -309,6 +329,11 @@ while ($_ = <IN>) {
     }
 }
 
+
+#
+# Parse the tests output
+#
+
 /^Test output:/ or mydie "no test header: $_";
 my ($dll, $unit, $source, $rev, $result);
 my ($lines,$total, $todo, $failed, $skipped);
@@ -394,7 +419,10 @@ if (defined $dll) {
 close SUM or mydie "error writing to '$tmpdir/summary.txt': $!\n";
 close IN;
 
-# fill the dllinfo box
+
+#
+# Generate the 'DLL version' section of the info box
+#
 
 $box->{data} .= "<table class=\"output\">\n";
 foreach my $dll (sort keys %dllinfo)
@@ -432,7 +460,10 @@ foreach my $dll (sort keys %dllinfo)
 }
 $box->{data} .= "</table>";
 
-# add the prev/next links to all the boxes
+
+#
+# Link the boxes together
+#
 
 for (my $i = 0; $i <= $#boxes; $i++)
 {
@@ -440,7 +471,10 @@ for (my $i = 0; $i <= $#boxes; $i++)
     $boxes[$i]->{next} = $boxes[$i+1]->{id} if $i < $#boxes;
 }
 
-# create the global report.html file
+
+#
+# Create the 'full report' page
+#
 
 open REPORT, ">$tmpdir/report.html" or mydie "unable to open '$tmpdir/report.html' for writing: $!\n";
 
@@ -462,7 +496,10 @@ for (my $i = 0; $i <= $#boxes; $i++)
 print REPORT end_html();
 close REPORT or mydie "error writing to '$tmpdir/report.html': $!\n";
 
-# create individual html files for all boxes
+
+#
+# Create the information and individual test unit pages
+#
 
 for (my $i = 0; $i <= $#boxes; $i++)
 {
@@ -483,6 +520,13 @@ for (my $i = 0; $i <= $#boxes; $i++)
     close FILE or mydie "error writing to '$tmpdir/$boxes[$i]->{id}.html': $!\n";
 }
 
+
+#
+# Move the files into place
+#
+
+use Errno qw/ENOTEMPTY/;
+
 my $builddir = "data/$testbuild";
 if (!$update) {
     foreach my $dir ("data", $builddir) {
diff --git a/winetest/gather b/winetest/gather
index b11db9e2..86f2a732 100755
--- a/winetest/gather
+++ b/winetest/gather
@@ -55,6 +55,10 @@ $name0 =~ s+^.*/++;
 my $summary_version=4;
 
 
+#
+# Common helpers
+#
+
 $ENV{GIT_DIR} = $gitdir;
 
 sub get_build_info($)
@@ -129,6 +133,8 @@ sub short_date($)
 #  errors        The number of unit tests with errors.
 #  todos         The number of unit tests with no error but todos.
 
+# This should match the definitions in build-index
+
 my %w95     = (name => "Win95");
 my %w98     = (name => "Win98");
 my %me      = (name => "Me");
@@ -149,15 +155,20 @@ my %bsd     = (name => "BSD");
 my %solaris = (name => "Solaris");
 my %wine    = (name => "Wine");
 
+# Define the order of version groups in the summary
+my @groups = (\%w95, \%w98, \%me, \%nt3, \%nt4, \%w2k, \%xp, \%w2k3, \%vista, \%w2k8, \%win7, \%win8, \%win10,
+              \%unknown, \%linux, \%mac, \%bsd, \%solaris, \%wine);
+
 # Map dissect's IDs to the above hashes
 my %idmap = (95=>\%w95, 98=>\%w98, me=>\%me, nt3=>\%nt3, nt4=>\%nt4, 2000=>\%w2k,
              xp=>\%xp, 2003=>\%w2k3, vista=>\%vista, 2008=>\%w2k8, win7=>\%win7, win8=>\%win8, win10=>\%win10,
              unknown=>\%unknown, wine=>\%wine, linux=>\%linux, mac=>\%mac, bsd=>\%bsd,
              solaris=>\%solaris);
 
-# Define the order of version groups in the summary
-my @groups = (\%w95, \%w98, \%me, \%nt3, \%nt4, \%w2k, \%xp, \%w2k3, \%vista, \%w2k8, \%win7, \%win8, \%win10,
-              \%unknown, \%linux, \%mac, \%bsd, \%solaris, \%wine);
+
+#
+# Pick a build to work on
+#
 
 
 chdir($workdir) or die "could not chdir to the work directory: $!";
@@ -168,7 +179,10 @@ exit 2 unless defined $outdated;
 (my $release = $build) =~ s/^(\d+).*$/$1/;
 my ($date, $_subject) = get_build_info($build);
 
-# Read in the data
+
+#
+# Read the summaries of all the build's reports
+#
 
 my %alltests;                   # union of test names
 foreach my $file (glob "data/$build/*/summary.txt") {
@@ -239,6 +253,11 @@ foreach my $file (glob "data/$build/*/summary.txt") {
     push @{$group->{reports}}, $report;
 }
 
+
+#
+# Merge the test results
+#
+
 sub merge_min_max($$$)
 {
     my ($merged, $result, $field)=@_;
@@ -366,7 +385,10 @@ foreach my $group (@groups) {
     }
 }
 
-# Write out the tables
+
+#
+# Write the data/BUILD/index*.html files
+#
 
 sub percent($$)
 {
@@ -458,13 +480,6 @@ my $header_footer=build_header_footer(\@groups);
 my $short_build = substr($build,0,12);
 my $short_date = short_date($date);
 
-sub min_to_max($)
-{
-    my ($minmax)=@_;
-    return $minmax->[0] if ($minmax->[0] == $minmax->[1]);
-    return "$minmax->[0] to $minmax->[1]";
-}
-
 sub get_result_class($)
 {
     my ($result) = @_;
@@ -486,6 +501,13 @@ sub get_result_class($)
     return "note";
 }
 
+sub min_to_max($)
+{
+    my ($minmax)=@_;
+    return $minmax->[0] if ($minmax->[0] == $minmax->[1]);
+    return "$minmax->[0] to $minmax->[1]";
+}
+
 sub get_result_title($$)
 {
     my ($testname, $result) = @_;
@@ -606,35 +628,7 @@ sub test_links($$)
            "</td>";
 }
 
-sub build_totals($)
-{
-    my ($reports)=@_;
-
-    if (!open TOTAL, ">data/$build/total.txt.new")
-    {
-        print STDERR "$name0:error: unable to open 'data/$build/total.txt.new' for writing: $!\n";
-        return;
-    }
-    my $unit_count=scalar(keys %alltests);
-    foreach my $rep (@{$reports}) {
-        my $report=$rep;
-        my $report_count = 0;
-        if (exists $report->{reports}) {
-            $report_count = @{$report->{reports}};
-            if ($report_count == 1) {
-                $report = $report->{reports}->[0];
-            }
-        } elsif (exists $report->{name}) {
-            # Ignore groups with no reports
-            next;
-        }
-        printf TOTAL "%s %u %u %u %u %u\n", $report->{group}->{name}, $report_count, $unit_count, $report->{errors}, $report->{todos}, $report->{successes};
-    }
-    close TOTAL;
-    rename "data/$build/total.txt.new", "data/$build/total.txt" or unlink "data/$build/total.txt.new";
-}
-
-sub output_table($)
+sub write_build_index_and_summary($)
 {
     my ($group) = @_;
     my ($group_name, $header_footer, $title, $filename);
@@ -750,6 +744,44 @@ EOF
 }
 
 
+#
+# Write the data/BUILD/totals.txt file
+# This provides the statistics for the main index page.
+#
+
+sub write_totals($)
+{
+    my ($reports)=@_;
+
+    if (!open TOTAL, ">data/$build/total.txt.new")
+    {
+        print STDERR "$name0:error: unable to open 'data/$build/total.txt.new' for writing: $!\n";
+        return;
+    }
+    my $unit_count=scalar(keys %alltests);
+    foreach my $rep (@{$reports}) {
+        my $report=$rep;
+        my $report_count = 0;
+        if (exists $report->{reports}) {
+            $report_count = @{$report->{reports}};
+            if ($report_count == 1) {
+                $report = $report->{reports}->[0];
+            }
+        } elsif (exists $report->{name}) {
+            # Ignore groups with no reports
+            next;
+        }
+        printf TOTAL "%s %u %u %u %u %u\n", $report->{group}->{name}, $report_count, $unit_count, $report->{errors}, $report->{todos}, $report->{successes};
+    }
+    close TOTAL;
+    rename "data/$build/total.txt.new", "data/$build/total.txt" or unlink "data/$build/total.txt.new";
+}
+
+
+#
+# Actually generate the build's files
+#
+
 if (!open SUMMARY, ">data/$build/summary.txt.new")
 {
   print STDERR "$name0:error: unable to open 'data/$build/summary.txt.new' for writing: $!\n";
@@ -759,15 +791,15 @@ if (!open SUMMARY, ">data/$build/summary.txt.new")
 # Take the groups with multiple reports
 foreach my $group (@groups) {
     next unless exists $group->{reports} && @{$group->{reports}} > 1;
-    output_table( $group );
+    write_build_index_and_summary( $group );
 }
 
-output_table(undef);
+write_build_index_and_summary(undef);
 
 close SUMMARY;
 rename "data/$build/summary.txt.new", "data/$build/summary.txt" or unlink "data/$build/summary.txt.new";
 
-build_totals(\@groups);
+write_totals(\@groups);
 
 DONE:
 if (!unlink $outdated) {
-- 
2.11.0



More information about the wine-patches mailing list