[Tools 2/3] testbot: Rerun all of a module's test units when a non-C file is modified.
Francois Gouget
fgouget at codeweavers.com
Sun Apr 2 18:50:23 CDT 2017
This typically happens when a resource file is modified or a test unit
is deleted.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
This should fix bugs 31789 and 42179:
https://bugs.winehq.org/show_bug.cgi?id=31789
https://bugs.winehq.org/show_bug.cgi?id=42179
testbot/bin/WineRunReconfig.pl | 12 ++++++
testbot/bin/build/Reconfig.pl | 5 +++
testbot/lib/WineTestBot/Patches.pm | 87 +++++++++++++++++++++++++++++++-------
3 files changed, 89 insertions(+), 15 deletions(-)
diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl
index 151c80f5..737d26f1 100755
--- a/testbot/bin/WineRunReconfig.pl
+++ b/testbot/bin/WineRunReconfig.pl
@@ -370,6 +370,18 @@ elsif (!defined $TAError)
{
$TAError = "An error occurred while retrieving the reconfig log: ". $TA->GetLastError();
}
+
+Debug(Elapsed($Start), " Retrieving the updated test list '$TaskDir/testlist.txt'\n");
+if ($TA->GetFile("testlist.txt", "$TaskDir/testlist.txt"))
+{
+ use File::Copy;
+ copy "$TaskDir/testlist.txt", "$DataDir/latest/testlist.txt";
+}
+elsif (!defined $TAError)
+{
+ $TAError = "An error occurred while retrieving the test list: ". $TA->GetLastError();
+}
+
$TA->Disconnect();
# Report the reconfig errors even though they may have been caused by
diff --git a/testbot/bin/build/Reconfig.pl b/testbot/bin/build/Reconfig.pl
index 81a487f8..ec7f05f5 100755
--- a/testbot/bin/build/Reconfig.pl
+++ b/testbot/bin/build/Reconfig.pl
@@ -67,6 +67,11 @@ sub GitPull()
return !1;
}
+ system("( cd $DataDir/wine && ".
+ " ls dlls/*/tests/*.c programs/*/tests/*.c | ".
+ " egrep -v '/testlist.c\$' >../testlist.txt ".
+ ") >>$LogDir/Reconfig.log 2>&1");
+
return 1;
}
diff --git a/testbot/lib/WineTestBot/Patches.pm b/testbot/lib/WineTestBot/Patches.pm
index 48f21567..d7987d6c 100644
--- a/testbot/lib/WineTestBot/Patches.pm
+++ b/testbot/lib/WineTestBot/Patches.pm
@@ -103,6 +103,37 @@ sub FromSubmission($$)
$self->Disposition("Processing");
}
+
+=pod
+=over 12
+
+=item C<GetTestList()>
+
+Returns a hashtable containing the list of the source files for a given module.
+This structure is built from the latest/testlist.txt file.
+
+=back
+=cut
+
+sub GetTestList()
+{
+ my $TestList = {};
+ if (open(my $File, "<", "$DataDir/latest/testlist.txt"))
+ {
+ while (my $TestFileName = <$File>)
+ {
+ chomp $TestFileName;
+ if ($TestFileName =~ m~^(?:dlls|programs)/([^/]+)/tests/[^/]+\.c$~)
+ {
+ my $Module = $1;
+ push @{$TestList->{$Module}}, $TestFileName;
+ }
+ }
+ close($File);
+ }
+ return $TestList;
+}
+
=pod
=over 12
@@ -126,28 +157,29 @@ sub Submit($$$)
my ($self, $PatchFileName, $IsSet) = @_;
# See also OnSubmit() in web/Submit.pl
- my %Modules;
+ my (%Modules, %Deleted);
if (open(BODY, "<$DataDir/patches/" . $self->Id))
{
- my $Line;
+ my ($Line, $Modified);
while (defined($Line = <BODY>))
{
- if ($Line =~ m~^\+\+\+ .*/(dlls|programs)/([^/]+)/tests/([^/\s]+)~)
+ if ($Line =~ m~^\-\-\- .*/((?:dlls|programs)/[^/]+/tests/[^/\s]+)~)
+ {
+ $Modified = $1;
+ }
+ elsif ($Line =~ m~^\+\+\+ .*/(dlls|programs)/([^/]+)/tests/([^/\s]+)~)
{
my ($FileType, $Module, $Unit) = ("patch$1", $2, $3);
$Unit = "" if ($Unit !~ s/\.c$//);
- if ($Unit)
- {
- if (defined($Modules{$Module}{""}))
- {
- delete($Modules{$Module}{""});
- }
- $Modules{$Module}{$Unit} = $FileType;
- }
- elsif (! defined($Modules{$Module}))
- {
- $Modules{$Module}{""} = $FileType;
- }
+ $Modules{$Module}{$Unit} = $FileType;
+ }
+ elsif ($Line =~ m~^\+\+\+ /dev/null~ and defined $Modified)
+ {
+ $Deleted{$Modified} = 1;
+ }
+ else
+ {
+ $Modified = undef;
}
}
close BODY;
@@ -175,6 +207,31 @@ sub Submit($$$)
$User = GetBatchUser();
}
+ my $TestList;
+ foreach my $Module (keys %Modules)
+ {
+ next if (!defined $Modules{$Module}{""});
+
+ # The patch modifies non-C files so rerun all that module's test units
+ $TestList = GetTestList() if (!$TestList);
+ next if (!defined $TestList->{$Module});
+
+ # If we don't find which tests to rerun then run the module test
+ # executable without argument. It probably won't work but will make the
+ # issue clearer to the developer.
+ my $FileType = $Modules{$Module}{""};
+ foreach my $TestFileName (@{$TestList->{$Module}})
+ {
+ if (!$Deleted{$TestFileName} and
+ $TestFileName =~ m~^(?:dlls|programs)/\Q$Module\E/tests/([^/]+)\.c$~)
+ {
+ my $Unit = $1;
+ $Modules{$Module}{$Unit} = $FileType;
+ delete $Modules{$Module}{""};
+ }
+ }
+ }
+
my $Disposition = "Submitted job ";
my $First = 1;
foreach my $Module (keys %Modules)
--
2.11.0
More information about the wine-patches
mailing list