Welcome! Log In Create A New Profile

Advanced

[PATCH] Tests: fixed try_run() to remove temporary directory on failure

Sergey Kandaurov
September 06, 2022 09:54AM
# HG changeset patch
# User Sergey Kandaurov <pluknet@nginx.com>
# Date 1662472340 -14400
# Tue Sep 06 17:52:20 2022 +0400
# Node ID 7eb87eaf06f4b9161cfe298f195947dbddedd01d
# Parent 78fe648d54a79822a72f3a5f8cc79651b3b1f5a7
Tests: fixed try_run() to remove temporary directory on failure.

Keeping the file handle pointing to the "stderr" file prevented removal
of the temporary directory on win32 if execution aborted in run().
The fix is to move safe file operations surrounding run() out of the
eval block such that the state of file handles is consistent.
Fixes a1874249496d.

diff -r 78fe648d54a7 -r 7eb87eaf06f4 lib/Test/Nginx.pm
--- a/lib/Test/Nginx.pm Tue Aug 30 17:24:16 2022 +0400
+++ b/lib/Test/Nginx.pm Tue Sep 06 17:52:20 2022 +0400
@@ -290,8 +290,9 @@ sub has_daemon($) {
sub try_run($$) {
my ($self, $message) = @_;

+ open OLDERR, ">&", \*STDERR;
+
eval {
- open OLDERR, ">&", \*STDERR;
open NEWERR, ">", $self->{_testdir} . '/stderr'
or die "Can't open stderr: $!";
close STDERR;
@@ -299,10 +300,10 @@ sub try_run($$) {
close NEWERR;

$self->run();
+ };

- close STDERR;
- open STDERR, ">&", \*OLDERR;
- };
+ close STDERR;
+ open STDERR, ">&", \*OLDERR;

return $self unless $@;


_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[PATCH] Tests: fixed try_run() to remove temporary directory on failure

Sergey Kandaurov 418 September 06, 2022 09:54AM

Re: [PATCH] Tests: fixed try_run() to remove temporary directory on failure

Maxim Dounin 112 September 06, 2022 09:48PM

Re: [PATCH] Tests: fixed try_run() to remove temporary directory on failure

Sergey Kandaurov 106 September 16, 2022 01:04PM

Re: [PATCH] Tests: fixed try_run() to remove temporary directory on failure

Maxim Dounin 142 September 17, 2022 01:52PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 185
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready