Skip Menu |

This queue is for tickets about the Dist-Zilla-Plugin-Perltidy CPAN distribution.

Report information
The Basics
Id: 88601
Status: resolved
Priority: 0/
Queue: Dist-Zilla-Plugin-Perltidy

People
Owner: Nobody in particular
Requestors: SHANTANU [...] cpan.org
Cc:
AdminCc:

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



Subject: The generated 00-compile.t test fails in the new revision with multiple warnings
t/00-compile.t ......... "my" variable $count masks earlier declaration in same statement at t/00-compile.t line 12. "my" variable $count masks earlier declaration in same scope at t/00-compile.t line 13. "my" variable $fail_on_warning masks earlier declaration in same scope at t/00-compile.t line 14. "my" variable $count masks earlier declaration in same scope at t/00-compile.t line 15. syntax error at t/00-compile.t line 7, near "use Test::More { " Global symbol "$test_more_version" requires explicit package name at t/00-compile.t line 7. syntax error at t/00-compile.t line 16, near "}" Global symbol "$needs_display" requires explicit package name at t/00-compile.t line 22. Global symbol "$fake_home" requires explicit package name at t/00-compile.t line 60. BEGIN not safe after errors--compilation aborted at t/00-compile.t line 69.
Subject: 00-compile.t
#!perl use strict; use warnings; use Test::More; use File::Find; use File::Temp qw{ tempdir }; my @modules; find( sub { return if $File::Find::name !~ /\.pm\z/; my $found = $File::Find::name; $found =~ s{^lib/}{}; $found =~ s{[/\\]}{::}g; $found =~ s/\.pm$//; # nothing to skip push @modules, $found; }, 'lib', ); sub _find_scripts { my $dir = shift @_; my @found_scripts = (); find( sub { return unless -f; my $found = $File::Find::name; # nothing to skip open my $FH, '<', $_ or do { note("Unable to open $found in ( $! ), skipping"); return; }; my $shebang = <$FH>; return unless $shebang =~ /^#!.*?\bperl\b\s*$/; push @found_scripts, $found; }, $dir, ); return @found_scripts; } my @scripts; do { push @scripts, _find_scripts($_) if -d $_ } for qw{ bin script scripts }; my $plan = scalar(@modules) + scalar(@scripts); $plan ? ( plan tests => $plan ) : ( plan skip_all => "no tests to run" ); { # fake home for cpan-testers local $ENV{HOME} = tempdir( CLEANUP => 1 ); like( qx{ $^X -Ilib -e "require $_; print '$_ ok'" }, qr/^\s*$_ ok/s, "$_ loaded ok" ) for sort @modules; SKIP: { eval "use Test::Script 1.05; 1;"; skip "Test::Script needed to test script compilation", scalar(@scripts) if $@; foreach my $file (@scripts) { my $script = $file; $script =~ s!.*/!!; script_compiles( $file, "$script script compiles" ); } } }
That version of the test did not get produced with versions 2.026, 2.027, 2.028, 2.029. What version of the plugin did you use to get this?
On Wed Sep 11 00:00:06 2013, ETHER wrote: Show quoted text
> That version of the test did not get produced with versions 2.026, > 2.027, 2.028, 2.029. What version of the plugin did you use to get > this?
Apologies for the late reply, I follow issues better at github, I got this message again in 2.037. Thanks, -Shan
On Sun Nov 24 22:26:41 2013, SHANTANU wrote: Show quoted text
> On Wed Sep 11 00:00:06 2013, ETHER wrote:
> > That version of the test did not get produced with versions 2.026, > > 2.027, 2.028, 2.029. What version of the plugin did you use to get > > this?
> > > Apologies for the late reply, I follow issues better at github, > I got this message again in 2.037. > Thanks, > -Shan
Subject: 00-compile.t
use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.037 use Test::More { { $test_more_version || '' } } tests => { { my $count = @module_filenames + @script_filenames; $count += 1 if $fail_on_warning eq 'all'; $count .= ' + ($ENV{AUTHOR_TESTING} ? 1 : 0)' if $fail_on_warning eq 'author'; $count; } }; { { $needs_display ? <<'CODE' BEGIN { # Skip all tests if you need a display for this test and $ENV{DISPLAY} is not set if( not $ENV{DISPLAY} and not $^O eq 'MSWin32' ) { plan skip_all => 'Needs DISPLAY'; exit 0; } } CODE : '' } } my @module_files = ( { { join( ",\n", map { " '" . $_ . "'" } map { s/'/\\'/g; $_ } sort @module_filenames ) } } ); { { @script_filenames ? 'my @scripts = (' . "\n" . join( ",\n", map { " '" . $_ . "'" } map { s/'/\\'/g; $_ } sort @script_filenames ) . "\n" . ');' : '' } } { { $fake_home ? <<'CODE' # fake home for cpan-testers use File::Temp; local $ENV{HOME} = File::Temp::tempdir( CLEANUP => 1 ); CODE : '# no fake home requested'; } } my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; use File::Spec; use IPC::Open3; use IO::Handle; my @warnings; for my $lib (@module_files) { # see L<perlfaq8/How can I capture STDERR from an external command?> open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my $stderr = IO::Handle->new; my $pid = open3( $stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]" ); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid( $pid, 0 ); is( $?, 0, "$lib loaded ok" ); if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } { { @script_filenames ? <<'CODE' foreach my $file (@scripts) { SKIP: { open my $fh, '<', $file or warn("Unable to open $file: $!"), next; my $line = <$fh>; close $fh and skip("$file isn't perl", 1) unless $line =~ /^#!.*?\bperl\b\s*(.*)$/; my @flags = $1 ? split(/\s+/, $1) : (); open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, @flags, '-c', $file); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$file compiled ok"); # in older perls, -c output is simply the file portion of the path being tested if (@_warnings = grep { !/\bsyntax OK$/ } grep { chomp; $_ ne (File::Spec->splitpath($file))[2] } @_warnings) { warn @_warnings; push @warnings, @_warnings; } } } CODE : ''; } } { { ( $fail_on_warning ne 'none' ? q{is(scalar(@warnings), 0, 'no warnings found')} : '# no warning checks' ) . ( $fail_on_warning eq 'author' ? ' if $ENV{AUTHOR_TESTING};' : ';' ) } } { { $bail_out_on_fail ? 'BAIL_OUT("Compilation problems") if !Test::More->builder->is_passing;' : ''; } }
Show quoted text
> Apologies for the late reply, I follow issues better at github, > I got this message again in 2.037.
Can you send me the output of 'perl -V'?
On 2013-11-25 09:48:53, ETHER wrote: Show quoted text
>
> > Apologies for the late reply, I follow issues better at github, > > I got this message again in 2.037.
> > Can you send me the output of 'perl -V'?
...and also the exact error message you get when you run the code that you just included above -- and the command you used to invoke it. thanks!
Subject: [rt.cpan.org #88601]
Date: Sun, 1 Dec 2013 15:59:32 -0500
To: bug-Dist-Zilla-Plugin-Test-Compile [...] rt.cpan.org
From: Noel Maddy <zhtwnpanta [...] gmail.com>
I ran into this bug as well. It only occurs if the PerlTidy plugin is listed before Test::Compile in dist.ini. If the Test::Compile plugin is listed before PerlTidy in dist.ini, everything works fine. Somehow, it looks like perltidy is being run on the template from the __DATA__ section, separating the curly brackets, so that when the template is applied the template vars are not being expanded. Versions: perl 5.16.3 Dist::ZIlla 5.006 Dist::Zilla::Plugin::PerlTidy 0.13 Dist::Zilla::Plugin::Test::Compile 2.038
Ahh, I see so maybe a warning in the module would be the appropriate solution ? Thanks, -Shan On Sun Dec 01 15:59:43 2013, zhtwnpanta@gmail.com wrote: Show quoted text
> I ran into this bug as well. It only occurs if the PerlTidy plugin is > listed before Test::Compile in dist.ini. > > If the Test::Compile plugin is listed before PerlTidy in dist.ini, > everything works fine. > > Somehow, it looks like perltidy is being run on the template from the > __DATA__ section, separating the curly brackets, so that when the template > is applied the template vars are not being expanded. > > Versions: > > perl 5.16.3 > Dist::ZIlla 5.006 > Dist::Zilla::Plugin::PerlTidy 0.13 > Dist::Zilla::Plugin::Test::Compile 2.038
RT-Send-CC: zhtwnpanta [...] gmail.com
On 2013-12-03 19:54:29, SHANTANU wrote: Show quoted text
> Ahh, > I see so maybe a warning in the module would be the appropriate solution ? > Thanks, > -Shan > On Sun Dec 01 15:59:43 2013, zhtwnpanta@gmail.com wrote:
> > I ran into this bug as well. It only occurs if the PerlTidy plugin is > > listed before Test::Compile in dist.ini. > > > > If the Test::Compile plugin is listed before PerlTidy in dist.ini, > > everything works fine. > > > > Somehow, it looks like perltidy is being run on the template from the > > __DATA__ section, separating the curly brackets, so that when the template > > is applied the template vars are not being expanded.
This is a problem with the [PerlTidy] plugin -- it should be skipping __DATA__ sections. I've moved this ticket to that queue.
I made one line change to skip perltidy Test::Compile file. return if $file->name and $file->name eq 't/00-compile.t'; # simply skip Dist::Zilla::Plugin::Test::Compile (RT 88601) for now it should just work. Thanks