Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37531592
en ru br
Репозитории ALT

Группа :: Разработка/Perl
Пакет: perl-CPAN-Inject

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: 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
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin