Francois Gouget : testbot/build: Simplify logging.

Alexandre Julliard julliard at winehq.org
Wed Jun 13 14:00:26 CDT 2018


Module: tools
Branch: master
Commit: 89f704eba7d29e5dc78e109a6a779cda1385d6ee
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=89f704eba7d29e5dc78e109a6a779cda1385d6ee

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Wed Jun 13 11:44:59 2018 +0200

testbot/build: Simplify logging.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/bin/build/Build.pl    | 29 ++++++++++++-----------------
 testbot/bin/build/Reconfig.pl | 33 ++++++++++++++-------------------
 2 files changed, 26 insertions(+), 36 deletions(-)

diff --git a/testbot/bin/build/Build.pl b/testbot/bin/build/Build.pl
index 001f5eb..3fe0e14 100755
--- a/testbot/bin/build/Build.pl
+++ b/testbot/bin/build/Build.pl
@@ -43,32 +43,27 @@ sub BEGIN
 use WineTestBot::Config;
 use WineTestBot::PatchUtils;
 
+my $LogFileName = "$LogDir/Build.log";
+
 sub InfoMsg(@)
 {
   my $OldUMask = umask(002);
-  if (open LOGFILE, ">>$LogDir/Build.log")
+  if (open(my $Log, ">>", $LogFileName))
   {
-    print LOGFILE @_;
-    close LOGFILE;
+    print $Log @_;
+    close($Log);
   }
   umask($OldUMask);
 }
 
 sub LogMsg(@)
 {
-  my $OldUMask = umask(002);
-  if (open LOGFILE, ">>$LogDir/Build.log")
-  {
-    print LOGFILE "Build: ", @_;
-    close LOGFILE;
-  }
-  umask($OldUMask);
+  InfoMsg "Build: ", @_;
 }
 
 sub FatalError(@)
 {
   LogMsg @_;
-
   exit 1;
 }
 
@@ -92,7 +87,7 @@ sub ApplyPatch($)
   system("( cd $DataDir/wine && set -x && " .
          "  git apply --verbose $PatchFile && " .
          "  git add -A " .
-         ") >> $LogDir/Build.log 2>&1");
+         ") >>$LogFileName 2>&1");
   if ($? != 0)
   {
     LogMsg "Patch failed to apply\n";
@@ -105,7 +100,7 @@ sub ApplyPatch($)
     InfoMsg "\nRunning make_makefiles\n";
     system("( cd $DataDir/wine && set -x && " .
            " ./tools/make_makefiles " .
-           ") >> $LogDir/Build.log 2>&1");
+           ") >>$LogFileName 2>&1");
     if ($? != 0)
     {
       LogMsg "make_makefiles failed\n";
@@ -118,7 +113,7 @@ sub ApplyPatch($)
     InfoMsg "\nRunning autoconf\n";
     system("( cd $DataDir/wine && set -x && " .
            "  autoconf " .
-           ") >>$LogDir/Build.log 2>&1");
+           ") >>$LogFileName 2>&1");
     if ($? != 0)
     {
       LogMsg "Autoconf failed\n";
@@ -136,7 +131,7 @@ sub BuildNative()
   InfoMsg "\nRebuilding native tools\n";
   system("( cd $DataDir/build-native && set -x && " .
          "  time make -j$ncpus __tooldeps__ " .
-         ") >>$LogDir/Build.log 2>&1");
+         ") >>$LogFileName 2>&1");
   if ($? != 0)
   {
     LogMsg "Rebuild of native tools failed\n";
@@ -162,7 +157,7 @@ sub BuildTestExecutables($$)
   InfoMsg "\nBuilding the $Bits-bit test executable(s)\n";
   system("( cd $DataDir/build-mingw$Bits && set -x && " .
          "  time make -j$ncpus ". join(" ", sort @BuildDirs) .
-         ") >>$LogDir/Build.log 2>&1");
+         ") >>$LogFileName 2>&1");
   if ($? != 0)
   {
     LogMsg "Rebuild of $Bits-bit crossbuild failed\n";
@@ -186,7 +181,7 @@ $ENV{PATH} = "/usr/lib/ccache:/usr/bin:/bin";
 delete $ENV{ENV};
 
 # Start with a clean logfile
-unlink("$LogDir/Build.log");
+unlink($LogFileName);
 
 my ($PatchFile, $BitIndicators);
 if (@ARGV == 2)
diff --git a/testbot/bin/build/Reconfig.pl b/testbot/bin/build/Reconfig.pl
index 63fb01b..706da25 100755
--- a/testbot/bin/build/Reconfig.pl
+++ b/testbot/bin/build/Reconfig.pl
@@ -42,32 +42,27 @@ sub BEGIN
 
 use WineTestBot::Config;
 
+my $LogFileName = "$LogDir/Reconfig.log";
+
 sub InfoMsg(@)
 {
   my $OldUMask = umask(002);
-  if (open LOGFILE, ">>$LogDir/Reconfig.log")
+  if (open(my $Log, ">>", $LogFileName))
   {
-    print LOGFILE @_;
-    close LOGFILE;
+    print $Log @_;
+    close($Log);
   }
   umask($OldUMask);
 }
 
 sub LogMsg(@)
 {
-  my $OldUMask = umask(002);
-  if (open LOGFILE, ">>$LogDir/Reconfig.log")
-  {
-    print LOGFILE "Reconfig: ", @_;
-    close LOGFILE;
-  }
-  umask($OldUMask);
+  InfoMsg "Reconfig: ", @_;
 }
 
 sub FatalError(@)
 {
   LogMsg @_;
-
   exit 1;
 }
 
@@ -92,7 +87,7 @@ sub BuildTestAgentd()
     InfoMsg "\nBuilding the native testagentd\n";
     system("( cd $::RootDir/src/testagentd && set -x && " .
            "  time make -j$ncpus build " .
-           ") >>$LogDir/Reconfig.log 2>&1");
+           ") >>$LogFileName 2>&1");
     if ($? != 0)
     {
       LogMsg "Build testagentd failed\n";
@@ -103,7 +98,7 @@ sub BuildTestAgentd()
   InfoMsg "\nRebuilding the Windows TestAgentd\n";
   system("( cd $::RootDir/src/testagentd && set -x && " .
          "  time make -j$ncpus iso " .
-         ") >>$LogDir/Reconfig.log 2>&1");
+         ") >>$LogFileName 2>&1");
   if ($? != 0)
   {
     LogMsg "Build winetestbot.iso failed\n";
@@ -118,7 +113,7 @@ sub BuildTestLauncher()
   InfoMsg "\nRebuilding TestLauncher\n";
   system("( cd $::RootDir/src/TestLauncher && set -x && " .
          "  time make -j$ncpus" .
-         ") >>$LogDir/Reconfig.log 2>&1");
+         ") >>$LogFileName 2>&1");
   if ($? != 0)
   {
     LogMsg "Build TestLauncher failed\n";
@@ -131,7 +126,7 @@ sub BuildTestLauncher()
 sub GitPull()
 {
   InfoMsg "Updating the Wine source\n";
-  system("cd $DataDir/wine && git pull >> $LogDir/Reconfig.log 2>&1");
+  system("cd $DataDir/wine && git pull >>$LogFileName 2>&1");
   if ($? != 0)
   {
     LogMsg "Git pull failed\n";
@@ -167,7 +162,7 @@ sub BuildNative()
          "  rm -rf * && " .
          "  time ../wine/configure --enable-win64 --without-x --without-freetype --disable-winetest && " .
          "  time make -j$ncpus __tooldeps__ " .
-         ") >>$LogDir/Reconfig.log 2>&1");
+         ") >>$LogFileName 2>&1");
 
   if ($? != 0)
   {
@@ -191,7 +186,7 @@ sub BuildCross($)
          "  rm -rf * && " .
          "  time ../wine/configure --host=$Host --with-wine-tools=../build-native --without-x --without-freetype --disable-winetest && " .
          "  time make -j$ncpus buildtests" .
-         ") >>$LogDir/Reconfig.log 2>&1");
+         ") >>$LogFileName 2>&1");
   if ($? != 0)
   {
     LogMsg "Build cross ($Bits bits) failed\n";
@@ -204,8 +199,8 @@ sub BuildCross($)
 $ENV{PATH} = "/usr/lib/ccache:/usr/bin:/bin";
 delete $ENV{ENV};
 
-# Start with clean logfile
-unlink("$LogDir/Reconfig.log");
+# Start with a clean logfile
+unlink($LogFileName);
 
 if (! -d "$DataDir/staging" and ! mkdir "$DataDir/staging")
 {




More information about the wine-cvs mailing list