[PATCH] Tests: better binary path handling on Windows

Maxim Dounin mdounin at mdounin.ru
Wed Aug 7 01:44:22 UTC 2024


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1722994681 -10800
#      Wed Aug 07 04:38:01 2024 +0300
# Node ID 73eca33514672f9c17aeb47ae7bcdf06ac15f77d
# Parent  a8c4d48a4073e5ec6745e4bddd2d4a844af3c0b7
Tests: better binary path handling on Windows.

The ".exe" extension is no longer required, and testing is allowed if
it is omitted.

Additionally, forward slashes in the binary path are automatically replaced
with reverse slashes, since CMD cannot properly handle relative paths with
forward slashes, and such paths previously resulted in various issues,
including non-working $t->has() and $t->has_version().

In particular, with these changes the default binary path, which is
"../nginx/objs/nginx", works properly, and testing can be done without
any additional options.

diff -r a8c4d48a4073 -r 73eca3351467 lib/Test/Nginx.pm
--- a/lib/Test/Nginx.pm	Thu Jul 18 19:40:19 2024 +0300
+++ b/lib/Test/Nginx.pm	Wed Aug 07 04:38:01 2024 +0300
@@ -49,8 +49,10 @@ sub new {
 		or die "Can't create temp directory: $!\n";
 	$self->{_testdir} =~ s!\\!/!g if $^O eq 'MSWin32';
 
+	$NGINX =~ s!/!\\!g if $^O eq 'MSWin32';
+
 	Test::More::BAIL_OUT("no $NGINX binary found")
-		unless -x $NGINX;
+		unless -x $NGINX or ($^O eq 'MSWin32' and -x "$NGINX.exe");
 
 	return $self;
 }



More information about the nginx-devel mailing list