[perl-CPAN-Inject] Expect an error if DNS does not work

Petr Pisar ppisar at fedoraproject.org
Thu Sep 11 08:45:34 UTC 2014


commit 7fc3da260f4bb4cf0a2e233553704e7cfdc85ac8
Author: Petr Písař <ppisar at redhat.com>
Date:   Thu Sep 11 10:42:16 2014 +0200

    Expect an error if DNS does not work

 ...own-exception-while-loading-CPAN-configur.patch |   81 ++++++++++++++++++++
 perl-CPAN-Inject.spec                              |    8 ++-
 2 files changed, 88 insertions(+), 1 deletions(-)
---
diff --git a/CPAN-Inject-1.14-Expect-unknown-exception-while-loading-CPAN-configur.patch b/CPAN-Inject-1.14-Expect-unknown-exception-while-loading-CPAN-configur.patch
new file mode 100644
index 0000000..dc454b1
--- /dev/null
+++ b/CPAN-Inject-1.14-Expect-unknown-exception-while-loading-CPAN-configur.patch
@@ -0,0 +1,81 @@
+From 1fd98154c60e0ab1d03f703f23b6775aed2bfc68 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar at 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 at 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
+
diff --git a/perl-CPAN-Inject.spec b/perl-CPAN-Inject.spec
index 1c61d6e..7319c64 100644
--- a/perl-CPAN-Inject.spec
+++ b/perl-CPAN-Inject.spec
@@ -1,6 +1,6 @@
 Name:           perl-CPAN-Inject
 Version:        1.14
-Release:        7%{?dist}
+Release:        8%{?dist}
 Summary:        Base class for injecting distributions into CPAN sources
 License:        GPL+ or Artistic
 Group:          Development/Libraries
@@ -8,6 +8,8 @@ URL:            http://search.cpan.org/dist/CPAN-Inject/
 Source0:        http://www.cpan.org/authors/id/P/PS/PSHANGOV/CPAN-Inject-%{version}.tar.gz
 # Work around CPAN bug mangling working directory, bug #1084093, CPAN RT#94963
 Patch0:         CPAN-Inject-1.14-Restore-working-directory-after-loading-CPAN-configu.patch
+# Expect en error if DNS does not work, bug #1138562, CPAN RT#98774
+Patch1:         CPAN-Inject-1.14-Expect-unknown-exception-while-loading-CPAN-configur.patch
 BuildArch:      noarch
 BuildRequires:  perl(CPAN) >= 1.36
 BuildRequires:  perl(CPAN::Checksums) >= 1.05
@@ -44,6 +46,7 @@ created to add additional distributions into a minicpan mirror.
 %prep
 %setup -q -n CPAN-Inject-%{version}
 %patch0 -p1
+%patch1 -p1
 
 # Remove bundled libraries
 rm -r inc
@@ -72,6 +75,9 @@ make test </dev/null
 %{_mandir}/man3/*
 
 %changelog
+* Thu Sep 11 2014 Petr Pisar <ppisar at redhat.com> - 1.14-8
+- Expect an error if DNS does not work (bug #1138562)
+
 * Mon Sep 01 2014 Jitka Plesnikova <jplesnik at redhat.com> - 1.14-7
 - Perl 5.20 rebuild
 



More information about the perl-devel mailing list