[tools] testbot: GetTaskURL() should load URI::Escape only when needed.

Francois Gouget fgouget at codeweavers.com
Tue Apr 5 11:17:30 CDT 2022


Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
The build VM does not have URI::Escape and this dependency caused the
build to fail (Reconfig.pl which uses Utils.pm failed to start).
There is really no compeling reason to install URI::Escape on the
build VM so I decided to tweak GetTaskURL() to only import URI::Escape
when needed which should not happen in the VM code.

What this really shows is that GetTaskURL() probably does not belong in
Utils but I'm not sure where else to put it. So that patch will at
least fix the immediate issue. Since GetTaskURL() depends closely on
the web side some place in WineTestBot::CGI may seem logical. But it's
actually used by non-CGI scripts and having them use CGI::something
would be wrong. Maybe the Tasks module is the least bad option though
that's another place that should really not depend on URI::escape.
---
 testbot/lib/WineTestBot/Utils.pm | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/testbot/lib/WineTestBot/Utils.pm b/testbot/lib/WineTestBot/Utils.pm
index 13529c323..cf749310d 100644
--- a/testbot/lib/WineTestBot/Utils.pm
+++ b/testbot/lib/WineTestBot/Utils.pm
@@ -34,7 +34,6 @@ our @EXPORT = qw(SecureConnection MakeSecureURL GetTaskURL GenerateRandomString
                  BatchQuote ShQuote ShArgv2Cmd);
 
 use Fcntl qw(O_CREAT O_EXCL O_WRONLY);
-use URI::Escape;
 
 use WineTestBot::Config;
 
@@ -89,7 +88,11 @@ sub GetTaskURL($$$;$$)
   my $StepTask = 100 * $StepNo + $TaskNo;
   my $URL = "/JobDetails.pl?Key=$JobId";
   $URL .= "&s$StepTask=1" if ($ShowScreenshot);
-  $URL .= "&f$StepTask=". uri_escape($LogName) if ($LogName);
+  if (defined $LogName)
+  {
+    require URI::Escape;
+    $URL .= "&f$StepTask=". URI::Escape::uri_escape($LogName);
+  }
   return "$URL#k$StepTask";
 }
 
-- 
2.30.2



More information about the wine-devel mailing list