Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to fix issue #47 with boilerplate creation #48

Merged
merged 1 commit into from
Jan 30, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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