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

Report information
The Basics
Id:
98774
Status:
new
Priority:
Low/Low
Queue:

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

BugTracker
Severity:
(no value)
Broken in:
1.14
Fixed in:
(no value)

Attachments
CPAN-Inject-1.14-Expect-unknown-exception-while-loading-CPAN-configur.patch



Subject: 'Got expected error' t/02_main.t test fails if DNS resolution does not work
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Message-ID: <rt-4.0.18-1870-1410421460-1083.0-0-0@rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 768
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
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-1870-1410421460-1083.0-0-0@rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: API
References: <rt-4.0.18-1870-1410421460-1083.0-0-0@rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-32263-1410423892-1529.0-0-0@rt.cpan.org>
Message-ID: <rt-4.0.18-32263-1410423892-1586.98774-0-0@rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
From: ppisar@redhat.com
Content-Length: 1311
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.
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-1870-1410421460-1083.0-0-0@rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
X-RT-Interface: API
References: <rt-4.0.18-1870-1410421460-1083.0-0-0@rt.cpan.org>
Content-Type: multipart/mixed; boundary="----------=_1410425116-32263-3"
Message-ID: <rt-4.0.18-32263-1410425116-1992.0-0-0@rt.cpan.org>
Message-ID: <rt-4.0.18-32263-1410425116-837.98774-0-0@rt.cpan.org>
X-RT-Original-Encoding: utf-8
From: ppisar@redhat.com
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 942
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
MIME-Version: 1.0
Subject: CPAN-Inject-1.14-Expect-unknown-exception-while-loading-CPAN-configur.patch
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Type: text/x-patch; name="CPAN-Inject-1.14-Expect-unknown-exception-while-loading-CPAN-configur.patch"
Content-Disposition: inline; filename="CPAN-Inject-1.14-Expect-unknown-exception-while-loading-CPAN-configur.patch"
Content-Transfer-Encoding: binary
Content-Length: 2372
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


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.