Francois Gouget : testbot: Allow running the scripts using a relative path.

Alexandre Julliard julliard at winehq.org
Tue Dec 11 13:33:32 CST 2012


Module: tools
Branch: master
Commit: 1ea3c37de85bc505e9fdd843b7f96facfaca9780
URL:    http://source.winehq.org/git/tools.git/?a=commit;h=1ea3c37de85bc505e9fdd843b7f96facfaca9780

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Tue Dec 11 12:06:51 2012 +0100

testbot: Allow running the scripts using a relative path.

Just make sure to turn it into an absolute path before we use it for the Perl module include path and for the $::RootDir variable.

---

 testbot/bin/CheckForWinetestUpdate.pl |    8 +++++++-
 testbot/bin/Engine.pl                 |    8 +++++++-
 testbot/bin/Janitor.pl                |    8 +++++++-
 testbot/bin/PingEngine.pl             |    8 +++++++-
 testbot/bin/RevertVM.pl               |    8 +++++++-
 testbot/bin/WinePatchesMLSubmit.pl    |    8 +++++++-
 testbot/bin/WinePatchesWebGet.pl      |    8 +++++++-
 testbot/bin/WinePatchesWebNotify.pl   |    8 +++++++-
 testbot/bin/WineRunBuild.pl           |    8 +++++++-
 testbot/bin/WineRunReconfig.pl        |    8 +++++++-
 testbot/bin/WineRunTask.pl            |    8 +++++++-
 testbot/bin/WineSendLog.pl            |    8 +++++++-
 testbot/bin/build/Build.pl            |    8 +++++++-
 testbot/bin/build/Reconfig.pl         |    8 +++++++-
 testbot/lib/WineTestBot/Config.pm     |    8 ++++++++
 testbot/scripts/CheckWineTestBot.pl   |    8 +++++++-
 testbot/scripts/TestAgent             |    8 +++++++-
 17 files changed, 120 insertions(+), 16 deletions(-)

diff --git a/testbot/bin/CheckForWinetestUpdate.pl b/testbot/bin/CheckForWinetestUpdate.pl
index 89c828f..2e28cdc 100755
--- a/testbot/bin/CheckForWinetestUpdate.pl
+++ b/testbot/bin/CheckForWinetestUpdate.pl
@@ -24,7 +24,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/bin/Engine.pl b/testbot/bin/Engine.pl
index f9be03a..a26ac17 100755
--- a/testbot/bin/Engine.pl
+++ b/testbot/bin/Engine.pl
@@ -22,7 +22,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/bin/Janitor.pl b/testbot/bin/Janitor.pl
index 57aa172..0c8b77f 100755
--- a/testbot/bin/Janitor.pl
+++ b/testbot/bin/Janitor.pl
@@ -23,7 +23,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/bin/PingEngine.pl b/testbot/bin/PingEngine.pl
index ef43807..2fb1b70 100755
--- a/testbot/bin/PingEngine.pl
+++ b/testbot/bin/PingEngine.pl
@@ -22,7 +22,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/bin/RevertVM.pl b/testbot/bin/RevertVM.pl
index 8fbc22a..2d8bf71 100755
--- a/testbot/bin/RevertVM.pl
+++ b/testbot/bin/RevertVM.pl
@@ -25,7 +25,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/bin/WinePatchesMLSubmit.pl b/testbot/bin/WinePatchesMLSubmit.pl
index 7ee4ecf..ffc65cb 100755
--- a/testbot/bin/WinePatchesMLSubmit.pl
+++ b/testbot/bin/WinePatchesMLSubmit.pl
@@ -24,7 +24,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/bin/WinePatchesWebGet.pl b/testbot/bin/WinePatchesWebGet.pl
index ed84a50..85f7986 100755
--- a/testbot/bin/WinePatchesWebGet.pl
+++ b/testbot/bin/WinePatchesWebGet.pl
@@ -23,7 +23,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/bin/WinePatchesWebNotify.pl b/testbot/bin/WinePatchesWebNotify.pl
index 6940d76..0fd0318 100755
--- a/testbot/bin/WinePatchesWebNotify.pl
+++ b/testbot/bin/WinePatchesWebNotify.pl
@@ -23,7 +23,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/bin/WineRunBuild.pl b/testbot/bin/WineRunBuild.pl
index 40c46e4..9fd23a7 100755
--- a/testbot/bin/WineRunBuild.pl
+++ b/testbot/bin/WineRunBuild.pl
@@ -23,7 +23,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl
index 67bb07b..47ac72e 100755
--- a/testbot/bin/WineRunReconfig.pl
+++ b/testbot/bin/WineRunReconfig.pl
@@ -23,7 +23,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/bin/WineRunTask.pl b/testbot/bin/WineRunTask.pl
index b101aff..8e7aeff 100755
--- a/testbot/bin/WineRunTask.pl
+++ b/testbot/bin/WineRunTask.pl
@@ -22,7 +22,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/bin/WineSendLog.pl b/testbot/bin/WineSendLog.pl
index b039e2e..04e9009 100755
--- a/testbot/bin/WineSendLog.pl
+++ b/testbot/bin/WineSendLog.pl
@@ -23,7 +23,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/bin/build/Build.pl b/testbot/bin/build/Build.pl
index c2e53e6..8ecbd09 100755
--- a/testbot/bin/build/Build.pl
+++ b/testbot/bin/build/Build.pl
@@ -24,7 +24,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/bin/build/Reconfig.pl b/testbot/bin/build/Reconfig.pl
index 89296bc..cc8e76e 100755
--- a/testbot/bin/build/Reconfig.pl
+++ b/testbot/bin/build/Reconfig.pl
@@ -24,7 +24,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/lib/WineTestBot/Config.pm b/testbot/lib/WineTestBot/Config.pm
index 71cf1c6..9a16fe6 100644
--- a/testbot/lib/WineTestBot/Config.pm
+++ b/testbot/lib/WineTestBot/Config.pm
@@ -48,6 +48,14 @@ require Exporter;
              $JobPurgeDays $JobArchiveDays $WebHostName);
 @EXPORT_OK = qw($DbDataSource $DbUsername $DbPassword);
 
+if ($::RootDir !~ m=^/=)
+{
+    require File::Basename;
+    my $name0 = File::Basename::basename($0);
+    print STDERR "$name0:error: \$::RootDir must be set to an absolute path\n";
+    exit 1;
+}
+
 $LogDir = "$::RootDir/var";
 $DataDir = "$::RootDir/var";
 $BinDir = "$::RootDir/bin";
diff --git a/testbot/scripts/CheckWineTestBot.pl b/testbot/scripts/CheckWineTestBot.pl
index b749eff..6415dc3 100755
--- a/testbot/scripts/CheckWineTestBot.pl
+++ b/testbot/scripts/CheckWineTestBot.pl
@@ -22,7 +22,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";
diff --git a/testbot/scripts/TestAgent b/testbot/scripts/TestAgent
index db31a3d..b861ba2 100755
--- a/testbot/scripts/TestAgent
+++ b/testbot/scripts/TestAgent
@@ -23,7 +23,13 @@ use strict;
 
 sub BEGIN
 {
-  if ($0 =~ m=^(.*)/[^/]+/[^/]+$=)
+  if ($0 !~ m=^/=)
+  {
+    # Turn $0 into an absolute path so it can safely be used in @INC
+    require Cwd;
+    $0 = Cwd::cwd() . "/$0";
+  }
+  if ($0 =~ m=^(/.*)/[^/]+/[^/]+$=)
   {
     $::RootDir = $1;
     unshift @INC, "$::RootDir/lib";




More information about the wine-cvs mailing list