From: Francois Gouget Subject: [PATCH 3/4] testbot: Add _CreateTestInfo() to reduce code duplication in PatchUtils. Message-Id: Date: Fri, 21 Sep 2018 10:35:30 +0200 (CEST) In-Reply-To: <9167ac781d3fc158e51fcdec88a3058b22bfcaa0.1537518914.git.fgouget@codeweavers.com> References: <9167ac781d3fc158e51fcdec88a3058b22bfcaa0.1537518914.git.fgouget@codeweavers.com> _CreateTestInfo() creates the initial $Impacts->{Tests} structure for GetPachImpacts(). Signed-off-by: Francois Gouget --- testbot/lib/WineTestBot/PatchUtils.pm | 64 ++++++++++++++------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/testbot/lib/WineTestBot/PatchUtils.pm b/testbot/lib/WineTestBot/PatchUtils.pm index 7c57b2c85..04aea183b 100644 --- a/testbot/lib/WineTestBot/PatchUtils.pm +++ b/testbot/lib/WineTestBot/PatchUtils.pm @@ -150,6 +150,31 @@ my $IgnoredPathsRe = join('|', 'tools/winemaker/', ); +sub _CreateTestInfo($$$) +{ + my ($Impacts, $Root, $Dir) = @_; + + my $Module = ($Root eq "programs") ? "$Dir.exe" : $Dir; + $Impacts->{BuildModules}->{$Module} = 1; + $Impacts->{IsWinePatch} = 1; + + my $Tests = $Impacts->{Tests}; + if (!$Tests->{$Module}) + { + $Tests->{$Module} = { + "Module" => $Module, + "Path" => "$Root/$Dir/tests", + "ExeBase" => "${Module}_test", + }; + foreach my $File (keys %{$_TestList->{$Module}}) + { + $Tests->{$Module}->{Files}->{$File} = 0; # not modified + } + } + + return $Module; +} + sub _HandleFile($$$) { my ($Impacts, $FilePath, $Change) = @_; @@ -168,43 +193,23 @@ sub _HandleFile($$$) if ($FilePath =~ m~^(dlls|programs)/([^/]+)/tests/([^/\s]+)$~) { my ($Root, $Dir, $File) = ($1, $2, $3); - my $Module = ($Root eq "programs") ? "$Dir.exe" : $Dir; - $Impacts->{BuildModules}->{$Module} = 1; - $Impacts->{TestBuild} = 1; - $Impacts->{IsWinePatch} = 1; - my $Tests = $Impacts->{Tests}; - if (!$Tests->{$Module}) - { - $Tests->{$Module} = { - "Module" => $Module, - "Path" => "$Root/$Dir/tests", - "ExeBase" => "${Module}_test", - }; - } + my $Module = _CreateTestInfo($Impacts, $Root, $Dir); + $Impacts->{TestBuild} = 1; + $Impacts->{Tests}->{$Module}->{Files}->{$File} = $Change; if ($File eq "Makefile.in" and $Change ne "modify") { # This adds / removes a directory $Impacts->{MakeMakefiles} = 1; } - - if (!$Tests->{$Module}->{Files}) - { - foreach my $File (keys %{$_TestList->{$Module}}) - { - $Tests->{$Module}->{Files}->{$File} = 0; # not modified - } - } - $Tests->{$Module}->{Files}->{$File} = $Change; } elsif ($FilePath =~ m~^(dlls|programs)/([^/]+)/([^/\s]+)$~) { my ($Root, $Dir, $File) = ($1, $2, $3); - my $Module = ($Root eq "programs") ? "$Dir.exe" : $Dir; - $Impacts->{BuildModules}->{$Module} = 1; + + my $Module = _CreateTestInfo($Impacts, $Root, $Dir); $Impacts->{ModuleBuild} = 1; - $Impacts->{IsWinePatch} = 1; if ($File eq "Makefile.in" and $Change ne "modify") { @@ -300,13 +305,10 @@ sub GetPatchImpacts($;$) foreach my $PastInfo (values %{$PastImpacts->{Tests}}) { - if ($PastInfo->{Files}) + foreach my $File (keys %{$PastInfo->{Files}}) { - foreach my $File (keys %{$PastInfo->{Files}}) - { - _HandleFile($Impacts, "$PastInfo->{Path}/$File", - $PastInfo->{Files}->{$File} eq "rm" ? "rm" : 0); - } + _HandleFile($Impacts, "$PastInfo->{Path}/$File", + $PastInfo->{Files}->{$File} eq "rm" ? "rm" : 0); } } } -- 2.18.0