Skip Menu |

This queue is for tickets about the CPAN-Inject CPAN distribution.

Report information
The Basics
Id: 98774
Status: new
Priority: 0/
Queue: CPAN-Inject

People
Owner: Nobody in particular
Requestors: ppisar [...] redhat.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.14
Fixed in: (no value)



Subject: 'Got expected error' t/02_main.t test fails if DNS resolution does not work
If DNS resolution does not work, t/02_main.t fails a test: PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'inc', 'blib/lib', 'blib/arch')" t/*.t t/01_compile.t .. ok curl: (6) Could not resolve host: www.cpan.org curl: (6) Could not resolve host: www.cpan.org curl: (6) Could not resolve host: www.cpan.org curl: (6) Could not resolve host: www.cpan.org # Failed test 'Got expected error' # at t/02_main.t line 80. # ' # ' # doesn't match '(?^:(The directory .* does not exist|The sources directory is not owned by the current user))' # Looks like you failed 1 test of 24. t/02_main.t ..... Dubious, test returned 1 (wstat 256, 0x100) Failed 1/24 subtests
From: ppisar [...] redhat.com
Dne Čt 11.zář.2014 03:44:20, ppisar napsal(a): Show quoted text
> If DNS resolution does not work, t/02_main.t fails a test: > > PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "- > MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, > 'inc', 'blib/lib', 'blib/arch')" t/*.t > t/01_compile.t .. ok > curl: (6) Could not resolve host: www.cpan.org > curl: (6) Could not resolve host: www.cpan.org > curl: (6) Could not resolve host: www.cpan.org > curl: (6) Could not resolve host: www.cpan.org > # Failed test 'Got expected error' > # at t/02_main.t line 80. > # ' > # ' > # doesn't match '(?^:(The directory .* does not exist|The sources > directory is not owned by the current user))' > # Looks like you failed 1 test of 24. > t/02_main.t ..... > Dubious, test returned 1 (wstat 256, 0x100) > Failed 1/24 subtests
CPAN::HandleConfig->load() dies in this case somewhere deep without setting meaningful exception value. Then t/02_main.t checks for the exception value and expects only two specific exceptions. While CPAN could set better message, this is, in my opinion, still bogus CPAN::Inject test. Either the test should be removed, or the from_cpan_config() should raise better exception ("CPAN could not load its configuration") if CPAN does not provide any.
From: ppisar [...] redhat.com
Dne Čt 11.zář.2014 03:44:20, ppisar napsal(a): Show quoted text
> If DNS resolution does not work, t/02_main.t fails a test: > > PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "- > MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, > 'inc', 'blib/lib', 'blib/arch')" t/*.t > t/01_compile.t .. ok > curl: (6) Could not resolve host: www.cpan.org > curl: (6) Could not resolve host: www.cpan.org > curl: (6) Could not resolve host: www.cpan.org > curl: (6) Could not resolve host: www.cpan.org > # Failed test 'Got expected error' > # at t/02_main.t line 80. > # ' > # ' > # doesn't match '(?^:(The directory .* does not exist|The sources > directory is not owned by the current user))' > # Looks like you failed 1 test of 24. > t/02_main.t ..... > Dubious, test returned 1 (wstat 256, 0x100) > Failed 1/24 subtests
Attached patch removes the bogus test and improves the exception message. -- Petr
Subject: CPAN-Inject-1.14-Expect-unknown-exception-while-loading-CPAN-configur.patch
From 1fd98154c60e0ab1d03f703f23b6775aed2bfc68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com> Date: Thu, 11 Sep 2014 10:35:29 +0200 Subject: [PATCH] Expect unknown exception while loading CPAN configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If DNS resolution does not work, CPAN run for the first time could not load its configuration and returns different exception than t/02_main.t expects. This patch removes the bogus test and wrappes the exception to provide better explanation pointing to the CPAN as the culprit. CPAN RT#98774 Signed-off-by: Petr Písař <ppisar@redhat.com> --- lib/CPAN/Inject.pm | 13 +++++++++---- t/02_main.t | 11 ++--------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/CPAN/Inject.pm b/lib/CPAN/Inject.pm index 86cf9ea..89fb120 100644 --- a/lib/CPAN/Inject.pm +++ b/lib/CPAN/Inject.pm @@ -209,12 +209,17 @@ sub from_cpan_config { require Cwd; my $origin_working_directory = Cwd::getcwd; - # Support for different mechanisms depending on the version - # of CPAN that is in use. - if ( defined $CPAN::HandleConfig::VERSION ) { + eval { + # Support for different mechanisms depending on the version + # of CPAN that is in use. + if ( defined $CPAN::HandleConfig::VERSION ) { CPAN::HandleConfig->load; - } else { + } else { CPAN::Config->load; + } + }; + if ($@) { + die "CPAN could not load its configuration: $@"; } # Restore working directory in case CPAN has changed it, RT#94963 diff --git a/t/02_main.t b/t/02_main.t index 4686a7e..3e1b7a6 100644 --- a/t/02_main.t +++ b/t/02_main.t @@ -8,7 +8,7 @@ BEGIN { $^W = 1; } -use Test::More tests => 24; +use Test::More tests => 23; use File::Spec::Functions ':ALL'; use File::Remove 'remove'; use CPAN::Inject; @@ -76,14 +76,7 @@ SCOPE: { ); }; SKIP: { - skip( "Current user owns CPAN::Config", 1 ) unless $@; - like($@, - qr/(The directory .* does not exist|The sources directory is not owned by the current user)/, - 'Got expected error', - ); - } - SKIP: { - skip( "Current user does not own CPAN::Config", 2 ) if $@; + skip( "Error while loading CPAN configuration ($@)", 2 ) if $@; isa_ok( $cpan, 'CPAN::Inject' ); is( $cpan->author, 'ADAMK', '->author ok' ); } -- 1.9.3