From 47ce55cb24970b00161d833503e1ff9f669d5b62 Mon Sep 17 00:00:00 2001 From: Steve Hay Date: Thu, 29 Aug 2013 13:06:50 +0100 Subject: [PATCH] Prevent ExtUtils-CBuilder leaving test output on Windows The link function call in the have_compiler and have_cplusplus tests create a compilet.def file on Windows which is correctly recorded for cleaning up when the EU::CB object is destroyed, but if another one gets made in the meantime then ExtUtils::Mksymlists::Mksymlists moves the first one to compilet_def.old, which isn't recorded for cleaning up and gets left behind when the test script has finished. Using a new object each time, destroying the previous one first, prevents this. --- dist/ExtUtils-CBuilder/t/00-have-compiler.t | 55 ++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/dist/ExtUtils-CBuilder/t/00-have-compiler.t b/dist/ExtUtils-CBuilder/t/00-have-compiler.t index 581a214..ffb1b04 100644 --- a/dist/ExtUtils-CBuilder/t/00-have-compiler.t +++ b/dist/ExtUtils-CBuilder/t/00-have-compiler.t @@ -23,25 +23,29 @@ require_ok "ExtUtils::CBuilder"; my $b = eval { ExtUtils::CBuilder->new(quiet => 1) }; ok( $b, "got CBuilder object" ) or diag $@; -my $bogus_path = 'djaadjfkadjkfajdf'; -my $run_perl = "$perl -e1 --"; # test missing compiler -$b->{config}{cc} = $bogus_path; -$b->{config}{ld} = $bogus_path; - -$b->{have_cc} = undef; -is( $b->have_compiler, 0, "have_compiler: fake missing cc" ); -$b->{have_cxx} = undef; -is( $b->have_cplusplus, 0, "have_cplusplus: fake missing c++" ); +{ +my $b1 = ExtUtils::CBuilder->new(quiet => 1); +configure_fake_missing_compilers($b1); +is( $b1->have_compiler, 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++" ); +} # test found compiler -$b->{config}{cc} = $run_perl; -$b->{config}{ld} = $run_perl; -$b->{config}{cxx} = $run_perl; -$b->{have_cc} = undef; -is( $b->have_compiler, 1, "have_compiler: fake present cc" ); -$b->{have_cxx} = undef; -is( $b->have_cplusplus, 1, "have_cpp_compiler: fake present c++" ); +{ +my $b3 = ExtUtils::CBuilder->new(quiet => 1); +configure_fake_present_compilers($b3); +is( $b3->have_compiler, 1, "have_compiler: fake present cc" ); +} +{ +my $b4 = ExtUtils::CBuilder->new(quiet => 1); +configure_fake_present_compilers($b4); +is( $b4->have_cplusplus, 1, "have_cpp_compiler: fake present c++" ); +} # test missing cpp compiler @@ -55,3 +59,22 @@ is( $b->have_cplusplus, 1, "have_cpp_compiler: fake present c++" ); pass( "OS type not yet listed for $^O" ); } } + +sub configure_fake_missing_compilers { + my $b = shift; + my $bogus_path = 'djaadjfkadjkfajdf'; + $b->{config}{cc} = $bogus_path; + $b->{config}{ld} = $bogus_path; + $b->{have_cc} = undef; + $b->{have_cxx} = undef; +} + +sub configure_fake_present_compilers { + my $b = shift; + my $run_perl = "$perl -e1 --"; + $b->{config}{cc} = $run_perl; + $b->{config}{ld} = $run_perl; + $b->{config}{cxx} = $run_perl; + $b->{have_cc} = undef; + $b->{have_cxx} = undef; +} -- 2.7.4