[nginx-tests] Tests: avoid changing non-localized $TODO.

Maxim Dounin mdounin at mdounin.ru
Fri May 31 03:25:38 UTC 2024


details:   http://freenginx.org/hg/nginx-tests/rev/0e2b14c75232
branches:  
changeset: 1981:0e2b14c75232
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Fri May 31 06:22:48 2024 +0300
description:
Tests: avoid changing non-localized $TODO.

This ensures that there will be no unrelated effects if the variable
is actually changed, such as seen on sanitizer tests in 910:49579dd88e3f
(reverted by this change).

diffstat:

 lib/Test/Nginx.pm |  18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diffs (33 lines):

diff --git a/lib/Test/Nginx.pm b/lib/Test/Nginx.pm
--- a/lib/Test/Nginx.pm
+++ b/lib/Test/Nginx.pm
@@ -69,21 +69,19 @@ sub DESTROY {
 
 		my @alerts = $self->read_file('error.log') =~ /.+\[alert\].+/gm;
 
-		if ($^O eq 'solaris') {
-			$Test::Nginx::TODO = 'alerts' if @alerts
-				&& ! grep { $_ !~ /phantom event/ } @alerts;
-		}
-		if ($^O eq 'MSWin32') {
-			my $re = qr/CloseHandle|TerminateProcess/;
-			$Test::Nginx::TODO = 'alerts' if @alerts
-				&& ! grep { $_ !~ $re } @alerts;
-		}
+		local $Test::Nginx::TODO = 'alerts' if @alerts
+			&& $^O eq 'solaris'
+			&& ! grep { $_ !~ /phantom event/ } @alerts;
+
+		local $Test::Nginx::TODO = 'alerts' if @alerts
+			&& $^O eq 'MSWin32'
+			&& ! grep { $_ !~ qr/CloseHandle|TerminateProcess/ }
+				@alerts;
 
 		Test::More::is(join("\n", @alerts), '', 'no alerts');
 	}
 
 	if (Test::More->builder->expected_tests) {
-		local $Test::Nginx::TODO;
 		my $errors = $self->read_file('error.log');
 		$errors = join "\n", $errors =~ /.+Sanitizer.+/gm;
 		Test::More::is($errors, '', 'no sanitizer errors');



More information about the nginx-devel mailing list