Fix breakage with Perl::Tidy ≥ 20120619 (CPAN RT#77977)

This commit is contained in:
Paul Howarth 2012-07-10 15:52:45 +01:00
parent 4231ce765d
commit 7ebd378dc3
2 changed files with 52 additions and 3 deletions

View File

@ -0,0 +1,41 @@
See https://rt.cpan.org/Public/Bug/Display.html?id=77977
--- lib/Perl/Critic/Policy/CodeLayout/RequireTidyCode.pm (revision 4123)
+++ lib/Perl/Critic/Policy/CodeLayout/RequireTidyCode.pm (working copy)
@@ -12,6 +12,7 @@
use warnings;
use English qw(-no_match_vars);
+use IO::String qw< >;
use Readonly;
use Perl::Tidy qw< >;
@@ -49,7 +50,8 @@
# Set configuration if defined
if (defined $self->{_perltidyrc} && $self->{_perltidyrc} eq $EMPTY) {
- $self->{_perltidyrc} = \$EMPTY;
+ my $rc = $EMPTY;
+ $self->{_perltidyrc} = \$rc;
}
return $TRUE;
@@ -92,10 +94,16 @@
# Trap Perl::Tidy errors, just in case it dies
my $eval_worked = eval {
+ # Perl::Tidy 20120619 no longer accepts a scalar reference for stdio.
+ my $handle = IO::String->new( $stderr );
+ # Since Perl::Tidy 20120619 modifies $source, we make a copy so
+ # we can get a good comparison. Doing an s/// on $source after the
+ # fact appears not to work with the previous Perl::Tidy.
+ my $source_copy = $source;
Perl::Tidy::perltidy(
- source => \$source,
+ source => \$source_copy,
destination => \$dest,
- stderr => \$stderr,
+ stderr => $handle,
defined $self->{_perltidyrc} ? (perltidyrc => $self->{_perltidyrc}) : (),
);
1;

View File

@ -1,11 +1,12 @@
Name: perl-Perl-Critic
Version: 1.117
Release: 7%{?dist}
Release: 8%{?dist}
Summary: Critique Perl source code for best-practices
Group: Development/Libraries
License: GPL+ or Artistic
URL: http://search.cpan.org/dist/Perl-Critic/
Source0: http://search.cpan.org/CPAN/authors/id/T/TH/THALJEF/Perl-Critic-%{version}.tar.gz
Patch2: Perl-Critic-1.117-tidy.patch
BuildArch: noarch
# Build process
@ -116,8 +117,12 @@ of Perl code were mixed directly in the test script. That sucked.
%prep
%setup -q -n Perl-Critic-%{version}
# Fix breakage with Perl::Tidy ≥ 20120619 (CPAN RT#77977)
%patch2
# Drop Test::Kwalitee tests in RHEL ≥ 7
%if 0%{?rhel} >= 7
# Drop Test::Kwalitee tests in RHEL >= 7
rm xt/author/95_kwalitee.t
sed -i -e '/^xt\/author\/95_kwalitee.t$/ d' MANIFEST
%endif
@ -148,6 +153,9 @@ LC_ALL=en_US ./Build %{!?perl_bootstrap:author}test
%{_mandir}/man3/Test::Perl::Critic::Policy.3pm*
%changelog
* Tue Jul 10 2012 Paul Howarth <paul@city-fan.org> - 1.117-8
- fix breakage with Perl::Tidy 20120619 (CPAN RT#77977)
* Tue Jul 10 2012 Petr Pisar <ppisar@redhat.com> - 1.117-7
- Perl 5.16 re-rebuild of bootstrapped packages
@ -158,7 +166,7 @@ LC_ALL=en_US ./Build %{!?perl_bootstrap:author}test
- conditionalize aspell
* Tue Apr 24 2012 Petr Pisar <ppisar@redhat.com> - 1.117-4
- Do not use Test::Kwalitee on RHEL >= 7
- do not use Test::Kwalitee on RHEL 7
* Tue Feb 28 2012 Paul Howarth <paul@city-fan.org> - 1.117-3
- spec clean-up