Skip to content

Commit

Permalink
Attempt to fix issue xsawyerx#47 with boilerplate creation
Browse files Browse the repository at this point in the history
NB: I cannot reproduce the bug report, so I don't know for sure if it fixes the bug.
  • Loading branch information
David.Pottage authored and chrestomanci committed Jan 27, 2015
1 parent 8fe92f1 commit d471cf3
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions lib/Module/Starter/Simple.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1080,11 +1080,12 @@ sub create_t {
my $self = shift;
my @modules = @_;

my ($t_files, $xt_files) = $self->t_guts(@modules);
my %t_files = $self->t_guts(@modules);
my %xt_files = $self->xt_guts(@modules);

my @files;
push @files, map { $self->_create_t('t', $_, $t_files->{$_}) } keys %$t_files;
push @files, map { $self->_create_t('xt', $_, $xt_files->{$_}) } keys %$xt_files;
push @files, map { $self->_create_t('t', $_, $t_files{$_}) } keys %t_files;
push @files, map { $self->_create_t('xt', $_, $xt_files{$_}) } keys %xt_files;

return @files;
}
Expand All @@ -1104,7 +1105,6 @@ sub t_guts {
my @modules = @_;

my %t_files;
my %xt_files;
my $minperl = $self->{minperl};
my $warnings = sprintf 'warnings%s;', ($self->{fatalize} ? " FATAL => 'all" : '');

Expand Down Expand Up @@ -1179,6 +1179,36 @@ $use_lines
diag( "Testing $main_module \$${main_module}::VERSION, Perl \$], \$^X" );
HERE

return %t_files;
}

=head2 xt_guts( @modules )
This method is called by create_t, and returns a description of the author
only *.t files to be created in the xt directory.
The return value is a hash of test files to create. Each key is a filename and
each value is the contents of that file.
=cut

sub xt_guts {
my $self = shift;
my @modules = @_;

my %xt_files;
my $minperl = $self->{minperl};
my $warnings = sprintf 'warnings%s;', ($self->{fatalize} ? " FATAL => 'all" : '');

my $header = <<"EOH";
#!perl -T
use $minperl;
use strict;
use $warnings
use Test::More;
EOH

my $module_boilerplate_tests;
$module_boilerplate_tests .=
" module_boilerplate_ok('".$self->_module_to_pm_file($_)."');\n" for @modules;
Expand Down Expand Up @@ -1237,7 +1267,7 @@ $module_boilerplate_tests
HERE

return( \%t_files, \%xt_files );
return %xt_files;
}

sub _create_t {
Expand Down

0 comments on commit d471cf3

Please sign in to comment.