Francois Gouget : testbot/UpdateTaskLogs: Simplify logging and deleting files.
Alexandre Julliard
julliard at winehq.org
Mon Feb 3 15:05:26 CST 2020
Module: tools
Branch: master
Commit: 86a73ca90badf726ba72fe2791f1c9a77a4d6067
URL: https://source.winehq.org/git/tools.git/?a=commit;h=86a73ca90badf726ba72fe2791f1c9a77a4d6067
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Fri Jan 31 13:15:31 2020 +0100
testbot/UpdateTaskLogs: Simplify logging and deleting files.
The files may be in a Step directory so add support for those in
Path2TaskKey().
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
testbot/bin/UpdateTaskLogs | 55 +++++++++++++++++++---------------------------
1 file changed, 22 insertions(+), 33 deletions(-)
diff --git a/testbot/bin/UpdateTaskLogs b/testbot/bin/UpdateTaskLogs
index d9369d8..bbcab7d 100755
--- a/testbot/bin/UpdateTaskLogs
+++ b/testbot/bin/UpdateTaskLogs
@@ -180,10 +180,25 @@ sub Path2TaskKey($)
return "latest" if (!defined $Path);
return "latest" if ($Path =~ m~/latest(?:/|$)~);
- $Path =~ s~^.*/jobs/(\d+/\d+/\d+)(/.*)?$~$1~;
+ $Path =~ s~^.*/jobs/(\d+/\d+(?:/\d+)?)(/.*)?$~$1~;
return $Path;
}
+sub Delete($;$)
+{
+ my ($Path, $Label) = @_;
+
+ return 0 if (!-f $Path);
+
+ my $Name = basename($Path);
+ $Label = defined $Label ? " $Label" : "";
+ Debug(Path2TaskKey($Path) .": Deleting$Label $Name\n");
+ return 0 if (unlink $Path);
+
+ Error "Could not delete $Path: $!\n";
+ return 1;
+}
+
sub BuildErrFile($$$$)
{
my ($Dir, $ReportName, $IsWineTest, $TaskTimedOut) = @_;
@@ -286,25 +301,10 @@ sub ProcessTaskLogs($$$)
# Save this report to latest/ in case it's not already present there
# (this would be the case for the oldest tasks with --rebuild)
$Rc += DoUpdateLatestReport($Task, $ReportName, $RefReportPath);
-
- Debug(TaskKeyStr($Task) .": Deleting ../$RefReportName\n");
- }
- foreach my $Suffix ("", ".err")
- {
- if (!unlink "$RefReportPath$Suffix" and -e "$RefReportPath$Suffix")
- {
- Error "Could not delete '$RefReportPath$Suffix': $!\n";
- $Rc = 1;
- }
- }
-
- next if (!-f "$TaskDir/$ReportName.err");
- Debug(TaskKeyStr($Task) .": Deleting $ReportName.err\n");
- if (!unlink "$TaskDir/$ReportName.err")
- {
- Error "Could not delete '$ReportName.err': $!\n";
- $Rc = 1;
}
+ $Rc += Delete($RefReportPath);
+ $Rc += Delete("$RefReportPath.err");
+ $Rc += Delete("$TaskDir/$ReportName.err");
}
}
@@ -402,23 +402,12 @@ sub ProcessLatestReports()
if ($OptDelete or $OptRebuild)
{
# Delete the reports that should be deleted / rebuilt
- foreach my $Suffix ("", ".err")
- {
- next if (!-f "$LatestReportPath$Suffix");
- Debug("latest: Deleting $RefReportName$Suffix\n");
- next if (unlink "$LatestReportPath$Suffix");
- Error "Could not delete '$LatestReportPath$Suffix': $!\n";
- $Rc = 1;
- }
+ $Rc += Delete($LatestReportPath);
+ $Rc += Delete("$LatestReportPath.err");
}
elsif (!-f "$LatestReportPath")
{
- Debug("latest: Deleting orphaned $RefReportName.err\n");
- if (!unlink "$LatestReportPath.err")
- {
- Error "Could not delete orphaned '$LatestReportPath.err': $!\n";
- $Rc = 1;
- }
+ $Rc += Delete("$LatestReportPath.err", "orphaned");
}
elsif (!$OptDelete and !-f "$LatestReportPath.err")
{
More information about the wine-cvs
mailing list