From: Vincent Pit Date: Mon, 31 Aug 2009 16:02:57 +0000 (+0200) Subject: Put the chdir logic into the two new helpers _before_fork() and _after_fork() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9324df28556b263f20fee6f11794460ebd71f846;p=p5sagit%2Fp5-mst-13.2.git Put the chdir logic into the two new helpers _before_fork() and _after_fork() --- diff --git a/t/TEST b/t/TEST index d20f94e..ab543f8 100755 --- a/t/TEST +++ b/t/TEST @@ -242,6 +242,29 @@ sub _cmd { return $cmd; } +sub _before_fork { + my ($options) = @_; + + if ($options->{run_dir}) { + my $run_dir = $options->{run_dir}; + chdir $run_dir or die "Can't chdir to '$run_dir': $!"; + } + + return; +} + +sub _after_fork { + my ($options) = @_; + + if ($options->{return_dir}) { + my $return_dir = $options->{return_dir}; + chdir $return_dir + or die "Can't chdir from '$options->{run_dir}' to '$return_dir': $!"; + } + + return; +} + sub _run_test { my($harness, $test, $type) = @_; if (!defined $type) { @@ -253,20 +276,13 @@ sub _run_test { $test = $options->{test}; # Might have changed if we're in ext/Foo - if ($options->{run_dir}) { - my $run_dir = $options->{run_dir}; - chdir $run_dir or die "Can't chdir to '$run_dir': $!"; - } + _before_fork($options); my $cmd = _cmd($options, $type); open(my $results, "$cmd |") or print "can't run '$cmd': $!.\n"; - if ($options->{return_dir}) { - my $return_dir = $options->{return_dir}; - chdir $return_dir - or die "Can't chdir from '$options->{run_dir}' to '$return_dir': $!"; - } + _after_fork($options); # Our environment may force us to use UTF-8, but we can't be sure that # anything we're reading from will be generating (well formed) UTF-8