summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-11-24 15:21:43 +0000
committerDavid Mitchell <davem@iabyn.com>2015-11-24 15:21:43 +0000
commit581ae9ba6515c52ef07fba2c6af86ede294a5ffe (patch)
tree7556c395feddad2cf2bb3ae6d500afe4fc856cc5
parent5fa8ae49d7be89da729f5ba1d985d9ef25aefcbd (diff)
downloadperl-581ae9ba6515c52ef07fba2c6af86ede294a5ffe.tar.gz
ExtUtils::CBuilder: silence noisy test
00-have-compiler.t deliberately does something that tries to fork and exec a non-existent file. Stop spurious 'Can't exec "djaadjfkadjkfajdf"' appearing on stderr by temporaily closing it before running the relevant tests.
-rw-r--r--dist/ExtUtils-CBuilder/t/00-have-compiler.t32
1 files changed, 26 insertions, 6 deletions
diff --git a/dist/ExtUtils-CBuilder/t/00-have-compiler.t b/dist/ExtUtils-CBuilder/t/00-have-compiler.t
index 1661812f93..1073277fd1 100644
--- a/dist/ExtUtils-CBuilder/t/00-have-compiler.t
+++ b/dist/ExtUtils-CBuilder/t/00-have-compiler.t
@@ -26,14 +26,34 @@ ok( $b, "got CBuilder object" ) or diag $@;
# test missing compiler
{
-my $b1 = ExtUtils::CBuilder->new(quiet => 1);
-configure_fake_missing_compilers($b1);
-is( $b1->have_compiler, 0, "have_compiler: fake missing cc" );
+
+ my $b1 = ExtUtils::CBuilder->new(quiet => 1);
+
+ configure_fake_missing_compilers($b1);
+
+ # This will fork a child that will print
+ # 'Can't exec "djaadjfkadjkfajdf"'
+ # or similar on STDERR; so make sure fd2 is temporarily closed before
+ # the fork
+ open(my $orig_err, ">&", \*STDERR) or die "Can't dup STDERR: $!";
+ close(STDERR);
+ my $res = $b1->have_compiler;
+ open(STDERR, ">&", $orig_err) or die "Can't dup \$orig_err $!";
+ close($orig_err);
+
+ is($res, 0, "have_compiler: fake missing cc" );
}
{
-my $b2 = ExtUtils::CBuilder->new(quiet => 1);
-configure_fake_missing_compilers($b2);
-is( $b2->have_cplusplus, 0, "have_cplusplus: fake missing c++" );
+ my $b2 = ExtUtils::CBuilder->new(quiet => 1);
+ configure_fake_missing_compilers($b2);
+
+ open(my $orig_err, ">&", \*STDERR) or die "Can't dup STDERR: $!";
+ close(STDERR);
+ my $res = $b2->have_cplusplus;
+ open(STDERR, ">&", $orig_err) or die "Can't dup \$orig_err $!";
+ close($orig_err);
+
+ is($res, 0, "have_cplusplus: fake missing c++" );
}
# test found compiler