diff --git a/lib/Module/Install.pod b/lib/Module/Install.pod index 5c084f7..c6398e6 100644 --- a/lib/Module/Install.pod +++ b/lib/Module/Install.pod @@ -202,9 +202,7 @@ version scanning tools. The C command specifies the license for the distribution. -Most often this value will be C<'perl'>, meaning I<"the same as for Perl -itself">. Other allowed values include C<'gpl'>, C<'lgpl'>, C<'bsd'>, -C<'MIT'>, and C<'artistic'>. +Most often this value will be C<'perl'>, meaning I<"the same terms as the perl 5 programming language system itself">. Other allowed values include C<'apache'>, C<'artistic'>, C<'artistic_2'>, C<'bsd'>, C<'gpl'>, C<'lgpl'>, C<'mit'> and C<'mozilla'>. This value is always considered a summary, and it is normal for authors to include a F file in the distribution, containing the full diff --git a/lib/Module/Install/Metadata.pm b/lib/Module/Install/Metadata.pm index a383e85..23d0249 100644 --- a/lib/Module/Install/Metadata.pm +++ b/lib/Module/Install/Metadata.pm @@ -452,42 +452,24 @@ sub author_from { #Stolen from M::B my %license_urls = ( - open_source => undef, - unrestricted => undef, - restrictive => undef, - unknown => undef, - -## from Software-License - should we be using S-L instead ? -# duplicates commeted out, see hack above ^^ -# open_source => 'http://www.gnu.org/licenses/agpl-3.0.txt', -# apache => 'http://www.apache.org/licenses/LICENSE-1.1', - apache => 'http://www.apache.org/licenses/LICENSE-2.0.txt', + +#from MI v1.06 + apache => undef, artistic => 'http://www.perlfoundation.org/artistic_license_1_0', artistic_2 => 'http://www.perlfoundation.org/artistic_license_2_0', bsd => 'http://opensource.org/licenses/BSD-3-Clause', -# unrestricted => 'http://creativecommons.org/publicdomain/zero/1.0/', -# open_source => 'http://www.freebsd.org/copyright/freebsd-license.html', -# open_source => 'http://www.gnu.org/licenses/fdl-1.2.txt', -# open_source => 'http://www.gnu.org/licenses/fdl-1.3.txt', -# gpl => 'http://www.gnu.org/licenses/old-licenses/gpl-1.0.txt', -# gpl => 'http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt', - gpl => 'http://www.gnu.org/licenses/gpl-3.0.txt', -# lgpl => 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt', - lgpl => 'http://www.gnu.org/licenses/lgpl-3.0.txt', + gpl => undef, + lgpl => undef, mit => 'http://www.opensource.org/licenses/mit-license.php', -# mozilla => 'http://www.mozilla.org/MPL/MPL-1.0.txt', -# mozilla => 'http://www.mozilla.org/MPL/MPL-1.1.txt', - mozilla => 'http://www.mozilla.org/MPL/2.0/index.txt', -# restrictive => '', -# open_source => 'http://www.openssl.org/source/license.html', + mozilla => undef, + open_source => undef, perl => 'http://dev.perl.org/licenses/', -# open_source => 'http://www.opensource.org/licenses/postgresql', -# open_source => 'http://trolltech.com/products/qt/licenses/licensing/qpl', -# unrestricted => 'http://h71000.www7.hp.com/doc/83final/BA554_90007/apcs02.html', -# open_source => 'http://www.openoffice.org/licenses/sissl_license.html', -# open_source => 'http://www.zlib.net/zlib_license.html', + unrestricted => undef, + restrictive => undef, +# unknown => undef, ); + sub license { my $self = shift; return $self->{values}->{license} unless @_; @@ -495,12 +477,17 @@ sub license { 'Did not provide a value to license()' ); $license = __extract_license($license) || lc $license; + + # test for valid meta license name + _valid_license($license); + $self->{values}->{license} = $license; # Automatically fill in license URLs if ( $license_urls{$license} ) { $self->resources( license => $license_urls{$license} ); - } + return 1; + } return 1; } @@ -524,14 +511,6 @@ sub _extract_license { sub __extract_license { my $license_text = shift or return; my @phrases = ( - '(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1, - '(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1, - - # the following are relied on by the test system even if they are wrong :( - '(?:Free)?BSD license' => 'bsd', 1, - 'Artistic license 2\.0' => 'artistic_2', 1, - 'LGPL' => 'lgpl', 1, - 'MIT' => 'mit', 1, ## from Software-License 'The GNU Affero General Public License, Version 3, November 2007' => 'open_source', 1, @@ -540,7 +519,7 @@ sub __extract_license { 'The Artistic License 1.0' => 'artistic', 1, 'The Artistic License 2.0 (GPL Compatible)' => 'artistic_2', 1, 'The (three-clause) BSD License' => 'bsd', 1, - 'CC0 License' => 'unrestricted', 1, + 'CC0 License' => 'unrestricted', 1, 'The (two-clause) FreeBSD License' => 'open_source', 1, 'GNU Free Documentation License v1.2' => 'open_source', 1, 'GNU Free Documentation License v1.3' => 'open_source', 1, @@ -565,7 +544,10 @@ sub __extract_license { while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) { $pattern =~ s#\s+#\\s+#gs; - if ( $license_text =~ /\b$pattern\b/i ) { + $pattern =~ s#\(#\\(\\s*#gs; + $pattern =~ s#\)#\\)\\s*#gs; + + if ( $license_text =~ m/\b$pattern\b/i ) { return $license; } } @@ -582,6 +564,31 @@ sub license_from { } } +sub _valid_license { + my $license = shift; + + my %meta_licenses = ( + apache => 1, + artistic => 1, + artistic_2 => 1, + bsd => 1, + gpl => 1, + lgpl => 1, + mit => 1, + mozilla => 1, + open_source => 1, + perl => 1, + unrestricted => 1, + restrictive => 1, + ); + + if (not $meta_licenses{$license}) { + die("ERROR: license is not a recognised meta name - $license\n"); + return 0; + } + return 1,; +} + sub _extract_bugtracker { my @links = $_[0] =~ m#L<( https?\Q://rt.cpan.org/\E[^>]+| diff --git a/t/09_read.t b/t/09_read.t index 876dbce..32486f2 100644 --- a/t/09_read.t +++ b/t/09_read.t @@ -32,7 +32,7 @@ Foo Bar =head1 COPYRIGHT This program is free software; you can redistribute it and/or -modify it under the same terms as Perl itself. +modify it under the same terms as the perl 5 programming language system itself. END_POD diff --git a/t/10_test.t b/t/10_test.t index c8b39b6..4dc045e 100644 --- a/t/10_test.t +++ b/t/10_test.t @@ -26,7 +26,7 @@ no_index 'directory' => qw{ t xt share inc }; install_share 'eg'; keywords 'kw1','kw 2'; keywords 'kw3'; -license 'apache'; +license 'artistic_2'; WriteAll; END_DSL @@ -73,8 +73,8 @@ END_TEST "no_index: @{ $meta->{no_index}->{directory} }" ); - is($meta->{license},'apache','license'); - is($meta->{resources}->{license},'http://www.apache.org/licenses/LICENSE-2.0.txt','license URL'); + is($meta->{license},'artistic_2','license'); + is($meta->{resources}->{license},'http://www.perlfoundation.org/artistic_license_2_0','license URL'); my $makefile = makefile(); ok( -f $makefile, 'Makefile created' ); diff --git a/t/11_extraction.t b/t/11_extraction.t index a263d6d..7194cee 100644 --- a/t/11_extraction.t +++ b/t/11_extraction.t @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!perl use strict; BEGIN { @@ -6,7 +6,7 @@ BEGIN { $^W = 1; } -use Test::More tests => 16; +use Test::More tests => 26; require_ok( 'Module::Install::Metadata' ); @@ -80,7 +80,7 @@ SCOPE: { SCOPE: { - my $l=Module::Install::Metadata::_extract_license("=head1 Copyright\nunder the same terms as the perl programming language\n=cut\n"); + my $l=Module::Install::Metadata::_extract_license("=head1 Copyright\nunder the same terms as the perl 5 programming language system itself\n=cut\n"); is($l, 'perl', 'Perl license detected', ); } @@ -89,7 +89,7 @@ SCOPE: { my $text="=head1 LICENSE This is free software, you may use it and distribute it under -the same terms as Perl itself. +the same terms as the perl 5 programming language system itself. =head1 SEE ALSO @@ -105,7 +105,7 @@ test SCOPE: { my $text="=head1 COPYRIGHTS -This module is distributed under the same terms as Perl itself. +This module is distributed under the same terms as the perl 5 programming language system itself. =cut "; @@ -115,8 +115,14 @@ This module is distributed under the same terms as Perl itself. } SCOPE: { - my $l=Module::Install::Metadata::_extract_license("=head1 COPYRIGHT\nAs LGPL license\n=cut\n"); - is($l, 'lgpl', 'LGPL detected', + my $l=Module::Install::Metadata::_extract_license("=head1 COPYRIGHT\nThe GNU Lesser General Public License, Version 2.1, February 1999\n=cut\n"); + is($l, 'lgpl', 'LGPL license detected', + ); +} + +SCOPE: { + my $l=Module::Install::Metadata::_extract_license("=head1 COPYRIGHT\nThe GNU Lesser General Public License, Version 3, June 2007\n=cut\n"); + is($l, 'lgpl', 'LGPL license detected', ); } @@ -125,7 +131,7 @@ SCOPE: { =head1 COPYRIGHT AND LICENCE ... is free software; you can redistribute it and/or modify it under -the terms of Perl itself, that is to say, under the terms of either: +the same terms as the perl 5 programming language system itself, that is to say, under the terms of either: =over 4 @@ -147,6 +153,12 @@ EOT ); } +SCOPE: { + my $l=Module::Install::Metadata::_extract_license("=head1 LICENSE\nThe Artistic License 1.0\n=cut\n"); + is($l, 'artistic', 'Artistic license detected', + ); +} + SCOPE: { my $text=<<'EOT'; @@ -154,15 +166,62 @@ SCOPE: { Copyright (C) 2010 -This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://opensource.org/licenses/artistic-license-2.0.php. +This library is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0 (GPL Compatible) For details, see the full text of the license at http://opensource.org/licenses/artistic-license-2.0.php. =cut EOT my $l=Module::Install::Metadata::_extract_license($text); - is($l, 'artistic_2', 'Artistic 2.0 license detected', + is($l, 'artistic_2', 'Artistic license detected', + ); +} + +SCOPE: { + my $l=Module::Install::Metadata::_extract_license("=head1 LICENCE\nThe (three-clause) BSD License\n=cut\n"); + is($l, 'bsd', 'BSD license detected', + ); +} + +SCOPE: { + my $l=Module::Install::Metadata::_extract_license("=head1 LICENCE\nThe GNU General Public License, Version 1, February 1989\n=cut\n"); + is($l, 'gpl', 'GNU license detected', + ); +} + +SCOPE: { + my $l=Module::Install::Metadata::_extract_license("=head1 LICENsE\nThe GNU General Public License, Version 2, June 1991\n=cut\n"); + is($l, 'gpl', 'GNU license detected', ); } +SCOPE: { + my $l=Module::Install::Metadata::_extract_license("=head1 LICENCE\nThe GNU General Public License, Version 3, June 2007\n=cut\n"); + is($l, 'gpl', 'GNU license detected', + ); +} + +SCOPE: { + my $l=Module::Install::Metadata::_extract_license("=head1 LICENCE\nThe MIT (X11) License\n=cut\n"); + is($l, 'mit', 'MIT license detected', + ); +} + +SCOPE: { + my $l=Module::Install::Metadata::_extract_license("=head1 LICENCE\nThe Mozilla Public License 1.0\n=cut\n"); + is($l, 'mozilla', 'Mozilla license detected', + ); +} + +SCOPE: { + my $l=Module::Install::Metadata::_extract_license("=head1 LICENSE\nThe Mozilla Public License 1.1\n=cut\n"); + is($l, 'mozilla', 'Mozilla license detected', + ); +} + +SCOPE: { + my $l=Module::Install::Metadata::_extract_license("=head1 Copyright\nMozilla Public License Version 2.0\n=cut\n"); + is($l, 'mozilla', 'Mozilla license detected', + ); +} SCOPE: { diff --git a/t/24_multiple_license_blocks.t b/t/24_multiple_license_blocks.t index 191378f..427b06a 100644 --- a/t/24_multiple_license_blocks.t +++ b/t/24_multiple_license_blocks.t @@ -9,6 +9,7 @@ BEGIN { use Test::More tests => 3; use Module::Install::Metadata; + my %p = _setup(); for ( @@ -67,9 +68,8 @@ POD =head1 LICENCE This module is free software; you can redistribute it and/or modify it -under the -same terms as Perl itself, i.e. under the terms of either the GNU -General Public +under the same terms as the perl 5 programming language system itself, +i.e. under the terms of either the GNU General Public License or the Artistic License, as specified in the F file. POD diff --git a/t/27_build_requires_and_include.t b/t/27_build_requires_and_include.t index 80bd944..184c7d5 100644 --- a/t/27_build_requires_and_include.t +++ b/t/27_build_requires_and_include.t @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!perl use strict; BEGIN { diff --git a/t/40_license_apache.t b/t/40_license_apache.t new file mode 100644 index 0000000..b8e7d13 --- /dev/null +++ b/t/40_license_apache.t @@ -0,0 +1,85 @@ +#!perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More; +use t::lib::Test; +use YAML::Tiny (); + +plan tests => 14; + +SCOPE: { + ok( create_dist('Foo', { 'Makefile.PL' => <<'END_DSL' }), 'create_dist' ); +use inc::Module::Install 0.82; + +name 'Foo'; +license 'apache'; +author 'Foo Bar '; +all_from 'lib/Foo.pm'; +requires 'perl' => '5.008000'; +test_requires 'Test::More' => '0.86'; +no_index 'directory' => qw{ t xt share inc }; +install_share 'eg'; +keywords 'kw1','kw 2'; +keywords 'kw3'; + +WriteAll; +END_DSL + + unlink file('META.yml'); + unlink file('MYMETA.yml'); + ok( mkdir(dir('eg')), 'created eg/' ); + ok( add_file('eg/sample', 'This is a sample'), 'added sample' ); + ok( mkdir(dir('t')), 'created t/' ); + ok( add_file('t/01_comile.t', <<'END_TEST'), 'added test' ); +#!/usr/bin/perl + +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More tests => 2; + +ok( $] >= 5.005, 'Perl version is new enough' ); + +use_ok( 'Foo', 'Loaded Foo.pm' ); +END_TEST + + ok( build_dist(), 'build dist' ); + + my $metafile = file('META.yml'); + ok( -f $metafile, 'META.yml created' ); + + my $meta = YAML::Tiny::LoadFile($metafile); + + is_deeply( + [ sort @{ $meta->{no_index}->{directory} } ], + [ qw{ eg inc t } ], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + is_deeply( + $meta->{keywords}, + [ 'kw1','kw 2','kw3'], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + + is($meta->{license},'apache','license: apache'); + is($meta->{resources}->{license}, undef,'resources.license: URL'); + + my $makefile = makefile(); + ok( -f $makefile, 'Makefile created' ); + + my $content = _read($makefile); + ok( $content =~ /^#\s+PREREQ_PM/m, 'PREREQ_PM found' ); + + ok( kill_dist(), 'kill dist' ); +} diff --git a/t/41_license_artistic.t b/t/41_license_artistic.t new file mode 100644 index 0000000..3462df0 --- /dev/null +++ b/t/41_license_artistic.t @@ -0,0 +1,85 @@ +#!perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More; +use t::lib::Test; +use YAML::Tiny (); + +plan tests => 14; + +SCOPE: { + ok( create_dist('Foo', { 'Makefile.PL' => <<'END_DSL' }), 'create_dist' ); +use inc::Module::Install 0.82; + +name 'Foo'; +license 'artistic'; +author 'Foo Bar '; +all_from 'lib/Foo.pm'; +requires 'perl' => '5.008000'; +test_requires 'Test::More' => '0.86'; +no_index 'directory' => qw{ t xt share inc }; +install_share 'eg'; +keywords 'kw1','kw 2'; +keywords 'kw3'; + +WriteAll; +END_DSL + + unlink file('META.yml'); + unlink file('MYMETA.yml'); + ok( mkdir(dir('eg')), 'created eg/' ); + ok( add_file('eg/sample', 'This is a sample'), 'added sample' ); + ok( mkdir(dir('t')), 'created t/' ); + ok( add_file('t/01_comile.t', <<'END_TEST'), 'added test' ); +#!/usr/bin/perl + +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More tests => 2; + +ok( $] >= 5.005, 'Perl version is new enough' ); + +use_ok( 'Foo', 'Loaded Foo.pm' ); +END_TEST + + ok( build_dist(), 'build dist' ); + + my $metafile = file('META.yml'); + ok( -f $metafile, 'META.yml created' ); + + my $meta = YAML::Tiny::LoadFile($metafile); + + is_deeply( + [ sort @{ $meta->{no_index}->{directory} } ], + [ qw{ eg inc t } ], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + is_deeply( + $meta->{keywords}, + [ 'kw1','kw 2','kw3'], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + + is($meta->{license},'artistic','license: artistic'); + is($meta->{resources}->{license}, 'http://www.perlfoundation.org/artistic_license_1_0','resources.license: URL'); + + my $makefile = makefile(); + ok( -f $makefile, 'Makefile created' ); + + my $content = _read($makefile); + ok( $content =~ /^#\s+PREREQ_PM/m, 'PREREQ_PM found' ); + + ok( kill_dist(), 'kill dist' ); +} diff --git a/t/42_license_artistic_2.t b/t/42_license_artistic_2.t new file mode 100644 index 0000000..7b5fe45 --- /dev/null +++ b/t/42_license_artistic_2.t @@ -0,0 +1,85 @@ +#!perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More; +use t::lib::Test; +use YAML::Tiny (); + +plan tests => 14; + +SCOPE: { + ok( create_dist('Foo', { 'Makefile.PL' => <<'END_DSL' }), 'create_dist' ); +use inc::Module::Install 0.82; + +name 'Foo'; +license 'artistic_2'; +author 'Foo Bar '; +all_from 'lib/Foo.pm'; +requires 'perl' => '5.008000'; +test_requires 'Test::More' => '0.86'; +no_index 'directory' => qw{ t xt share inc }; +install_share 'eg'; +keywords 'kw1','kw 2'; +keywords 'kw3'; + +WriteAll; +END_DSL + + unlink file('META.yml'); + unlink file('MYMETA.yml'); + ok( mkdir(dir('eg')), 'created eg/' ); + ok( add_file('eg/sample', 'This is a sample'), 'added sample' ); + ok( mkdir(dir('t')), 'created t/' ); + ok( add_file('t/01_comile.t', <<'END_TEST'), 'added test' ); +#!/usr/bin/perl + +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More tests => 2; + +ok( $] >= 5.005, 'Perl version is new enough' ); + +use_ok( 'Foo', 'Loaded Foo.pm' ); +END_TEST + + ok( build_dist(), 'build dist' ); + + my $metafile = file('META.yml'); + ok( -f $metafile, 'META.yml created' ); + + my $meta = YAML::Tiny::LoadFile($metafile); + + is_deeply( + [ sort @{ $meta->{no_index}->{directory} } ], + [ qw{ eg inc t } ], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + is_deeply( + $meta->{keywords}, + [ 'kw1','kw 2','kw3'], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + + is($meta->{license},'artistic_2','license: artistic_2'); + is($meta->{resources}->{license}, 'http://www.perlfoundation.org/artistic_license_2_0','resources.license: URL'); + + my $makefile = makefile(); + ok( -f $makefile, 'Makefile created' ); + + my $content = _read($makefile); + ok( $content =~ /^#\s+PREREQ_PM/m, 'PREREQ_PM found' ); + + ok( kill_dist(), 'kill dist' ); +} diff --git a/t/43_license_bsd.t b/t/43_license_bsd.t new file mode 100644 index 0000000..ccdd91c --- /dev/null +++ b/t/43_license_bsd.t @@ -0,0 +1,85 @@ +#!perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More; +use t::lib::Test; +use YAML::Tiny (); + +plan tests => 14; + +SCOPE: { + ok( create_dist('Foo', { 'Makefile.PL' => <<'END_DSL' }), 'create_dist' ); +use inc::Module::Install 0.82; + +name 'Foo'; +license 'bsd'; +author 'Foo Bar '; +all_from 'lib/Foo.pm'; +requires 'perl' => '5.008000'; +test_requires 'Test::More' => '0.86'; +no_index 'directory' => qw{ t xt share inc }; +install_share 'eg'; +keywords 'kw1','kw 2'; +keywords 'kw3'; + +WriteAll; +END_DSL + + unlink file('META.yml'); + unlink file('MYMETA.yml'); + ok( mkdir(dir('eg')), 'created eg/' ); + ok( add_file('eg/sample', 'This is a sample'), 'added sample' ); + ok( mkdir(dir('t')), 'created t/' ); + ok( add_file('t/01_comile.t', <<'END_TEST'), 'added test' ); +#!/usr/bin/perl + +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More tests => 2; + +ok( $] >= 5.005, 'Perl version is new enough' ); + +use_ok( 'Foo', 'Loaded Foo.pm' ); +END_TEST + + ok( build_dist(), 'build dist' ); + + my $metafile = file('META.yml'); + ok( -f $metafile, 'META.yml created' ); + + my $meta = YAML::Tiny::LoadFile($metafile); + + is_deeply( + [ sort @{ $meta->{no_index}->{directory} } ], + [ qw{ eg inc t } ], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + is_deeply( + $meta->{keywords}, + [ 'kw1','kw 2','kw3'], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + + is($meta->{license},'bsd','license: bsd'); + is($meta->{resources}->{license}, 'http://opensource.org/licenses/BSD-3-Clause','resources.license: URL'); + + my $makefile = makefile(); + ok( -f $makefile, 'Makefile created' ); + + my $content = _read($makefile); + ok( $content =~ /^#\s+PREREQ_PM/m, 'PREREQ_PM found' ); + + ok( kill_dist(), 'kill dist' ); +} diff --git a/t/44_license_gpl.t b/t/44_license_gpl.t new file mode 100644 index 0000000..166bedf --- /dev/null +++ b/t/44_license_gpl.t @@ -0,0 +1,85 @@ +#!perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More; +use t::lib::Test; +use YAML::Tiny (); + +plan tests => 14; + +SCOPE: { + ok( create_dist('Foo', { 'Makefile.PL' => <<'END_DSL' }), 'create_dist' ); +use inc::Module::Install 0.82; + +name 'Foo'; +license 'gpl'; +author 'Foo Bar '; +all_from 'lib/Foo.pm'; +requires 'perl' => '5.008000'; +test_requires 'Test::More' => '0.88'; +no_index 'directory' => qw{ t xt share inc }; +install_share 'eg'; +keywords 'kw1','kw 2'; +keywords 'kw3'; + +WriteAll; +END_DSL + + unlink file('META.yml'); + unlink file('MYMETA.yml'); + ok( mkdir(dir('eg')), 'created eg/' ); + ok( add_file('eg/sample', 'This is a sample'), 'added sample' ); + ok( mkdir(dir('t')), 'created t/' ); + ok( add_file('t/01_comile.t', <<'END_TEST'), 'added test' ); +#!/usr/bin/perl + +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More tests => 2; + +ok( $] >= 5.005, 'Perl version is new enough' ); + +use_ok( 'Foo', 'Loaded Foo.pm' ); +END_TEST + + ok( build_dist(), 'build dist' ); + + my $metafile = file('META.yml'); + ok( -f $metafile, 'META.yml created' ); + + my $meta = YAML::Tiny::LoadFile($metafile); + + is_deeply( + [ sort @{ $meta->{no_index}->{directory} } ], + [ qw{ eg inc t } ], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + is_deeply( + $meta->{keywords}, + [ 'kw1','kw 2','kw3'], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + + is($meta->{license},'gpl','license: gpl'); + is($meta->{resources}->{license}, undef,'resources.license: URL'); + + my $makefile = makefile(); + ok( -f $makefile, 'Makefile created' ); + + my $content = _read($makefile); + ok( $content =~ /^#\s+PREREQ_PM/m, 'PREREQ_PM found' ); + + ok( kill_dist(), 'kill dist' ); +} diff --git a/t/45_license_lgpl.t b/t/45_license_lgpl.t new file mode 100644 index 0000000..bc18288 --- /dev/null +++ b/t/45_license_lgpl.t @@ -0,0 +1,85 @@ +#!perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More; +use t::lib::Test; +use YAML::Tiny (); + +plan tests => 14; + +SCOPE: { + ok( create_dist('Foo', { 'Makefile.PL' => <<'END_DSL' }), 'create_dist' ); +use inc::Module::Install 0.82; + +name 'Foo'; +license 'lgpl'; +author 'Foo Bar '; +all_from 'lib/Foo.pm'; +requires 'perl' => '5.008000'; +test_requires 'Test::More' => '0.88'; +no_index 'directory' => qw{ t xt share inc }; +install_share 'eg'; +keywords 'kw1','kw 2'; +keywords 'kw3'; + +WriteAll; +END_DSL + + unlink file('META.yml'); + unlink file('MYMETA.yml'); + ok( mkdir(dir('eg')), 'created eg/' ); + ok( add_file('eg/sample', 'This is a sample'), 'added sample' ); + ok( mkdir(dir('t')), 'created t/' ); + ok( add_file('t/01_comile.t', <<'END_TEST'), 'added test' ); +#!/usr/bin/perl + +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More tests => 2; + +ok( $] >= 5.005, 'Perl version is new enough' ); + +use_ok( 'Foo', 'Loaded Foo.pm' ); +END_TEST + + ok( build_dist(), 'build dist' ); + + my $metafile = file('META.yml'); + ok( -f $metafile, 'META.yml created' ); + + my $meta = YAML::Tiny::LoadFile($metafile); + + is_deeply( + [ sort @{ $meta->{no_index}->{directory} } ], + [ qw{ eg inc t } ], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + is_deeply( + $meta->{keywords}, + [ 'kw1','kw 2','kw3'], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + + is($meta->{license},'lgpl','license: lgpl'); + is($meta->{resources}->{license}, undef,'resources.license: URL'); + + my $makefile = makefile(); + ok( -f $makefile, 'Makefile created' ); + + my $content = _read($makefile); + ok( $content =~ /^#\s+PREREQ_PM/m, 'PREREQ_PM found' ); + + ok( kill_dist(), 'kill dist' ); +} diff --git a/t/46_license_mit.t b/t/46_license_mit.t new file mode 100644 index 0000000..32c944b --- /dev/null +++ b/t/46_license_mit.t @@ -0,0 +1,85 @@ +#!perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More; +use t::lib::Test; +use YAML::Tiny (); + +plan tests => 14; + +SCOPE: { + ok( create_dist('Foo', { 'Makefile.PL' => <<'END_DSL' }), 'create_dist' ); +use inc::Module::Install 0.82; + +name 'Foo'; +license 'mit'; +author 'Foo Bar '; +all_from 'lib/Foo.pm'; +requires 'perl' => '5.008000'; +test_requires 'Test::More' => '0.86'; +no_index 'directory' => qw{ t xt share inc }; +install_share 'eg'; +keywords 'kw1','kw 2'; +keywords 'kw3'; + +WriteAll; +END_DSL + + unlink file('META.yml'); + unlink file('MYMETA.yml'); + ok( mkdir(dir('eg')), 'created eg/' ); + ok( add_file('eg/sample', 'This is a sample'), 'added sample' ); + ok( mkdir(dir('t')), 'created t/' ); + ok( add_file('t/01_comile.t', <<'END_TEST'), 'added test' ); +#!/usr/bin/perl + +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More tests => 2; + +ok( $] >= 5.005, 'Perl version is new enough' ); + +use_ok( 'Foo', 'Loaded Foo.pm' ); +END_TEST + + ok( build_dist(), 'build dist' ); + + my $metafile = file('META.yml'); + ok( -f $metafile, 'META.yml created' ); + + my $meta = YAML::Tiny::LoadFile($metafile); + + is_deeply( + [ sort @{ $meta->{no_index}->{directory} } ], + [ qw{ eg inc t } ], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + is_deeply( + $meta->{keywords}, + [ 'kw1','kw 2','kw3'], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + + is($meta->{license},'mit','license: mit'); + is($meta->{resources}->{license}, 'http://www.opensource.org/licenses/mit-license.php','resources.license: URL'); + + my $makefile = makefile(); + ok( -f $makefile, 'Makefile created' ); + + my $content = _read($makefile); + ok( $content =~ /^#\s+PREREQ_PM/m, 'PREREQ_PM found' ); + + ok( kill_dist(), 'kill dist' ); +} diff --git a/t/47_license_mozilla.t b/t/47_license_mozilla.t new file mode 100644 index 0000000..c046efa --- /dev/null +++ b/t/47_license_mozilla.t @@ -0,0 +1,85 @@ +#!perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More; +use t::lib::Test; +use YAML::Tiny (); + +plan tests => 14; + +SCOPE: { + ok( create_dist('Foo', { 'Makefile.PL' => <<'END_DSL' }), 'create_dist' ); +use inc::Module::Install 0.82; + +name 'Foo'; +license 'mozilla'; +author 'Foo Bar '; +all_from 'lib/Foo.pm'; +requires 'perl' => '5.008000'; +test_requires 'Test::More' => '0.88'; +no_index 'directory' => qw{ t xt share inc }; +install_share 'eg'; +keywords 'kw1','kw 2'; +keywords 'kw3'; + +WriteAll; +END_DSL + + unlink file('META.yml'); + unlink file('MYMETA.yml'); + ok( mkdir(dir('eg')), 'created eg/' ); + ok( add_file('eg/sample', 'This is a sample'), 'added sample' ); + ok( mkdir(dir('t')), 'created t/' ); + ok( add_file('t/01_comile.t', <<'END_TEST'), 'added test' ); +#!/usr/bin/perl + +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More tests => 2; + +ok( $] >= 5.005, 'Perl version is new enough' ); + +use_ok( 'Foo', 'Loaded Foo.pm' ); +END_TEST + + ok( build_dist(), 'build dist' ); + + my $metafile = file('META.yml'); + ok( -f $metafile, 'META.yml created' ); + + my $meta = YAML::Tiny::LoadFile($metafile); + + is_deeply( + [ sort @{ $meta->{no_index}->{directory} } ], + [ qw{ eg inc t } ], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + is_deeply( + $meta->{keywords}, + [ 'kw1','kw 2','kw3'], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + + is($meta->{license},'mozilla','license: mozilla'); + is($meta->{resources}->{license}, undef,'resources.license: URL'); + + my $makefile = makefile(); + ok( -f $makefile, 'Makefile created' ); + + my $content = _read($makefile); + ok( $content =~ /^#\s+PREREQ_PM/m, 'PREREQ_PM found' ); + + ok( kill_dist(), 'kill dist' ); +} diff --git a/t/48_license_open_source.t b/t/48_license_open_source.t new file mode 100644 index 0000000..a7b4f5c --- /dev/null +++ b/t/48_license_open_source.t @@ -0,0 +1,85 @@ +#!perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More; +use t::lib::Test; +use YAML::Tiny (); + +plan tests => 14; + +SCOPE: { + ok( create_dist('Foo', { 'Makefile.PL' => <<'END_DSL' }), 'create_dist' ); +use inc::Module::Install 0.82; + +name 'Foo'; +license 'open_source'; +author 'Foo Bar '; +all_from 'lib/Foo.pm'; +requires 'perl' => '5.008000'; +test_requires 'Test::More' => '0.88'; +no_index 'directory' => qw{ t xt share inc }; +install_share 'eg'; +keywords 'kw1','kw 2'; +keywords 'kw3'; + +WriteAll; +END_DSL + + unlink file('META.yml'); + unlink file('MYMETA.yml'); + ok( mkdir(dir('eg')), 'created eg/' ); + ok( add_file('eg/sample', 'This is a sample'), 'added sample' ); + ok( mkdir(dir('t')), 'created t/' ); + ok( add_file('t/01_comile.t', <<'END_TEST'), 'added test' ); +#!/usr/bin/perl + +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More tests => 2; + +ok( $] >= 5.005, 'Perl version is new enough' ); + +use_ok( 'Foo', 'Loaded Foo.pm' ); +END_TEST + + ok( build_dist(), 'build dist' ); + + my $metafile = file('META.yml'); + ok( -f $metafile, 'META.yml created' ); + + my $meta = YAML::Tiny::LoadFile($metafile); + + is_deeply( + [ sort @{ $meta->{no_index}->{directory} } ], + [ qw{ eg inc t } ], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + is_deeply( + $meta->{keywords}, + [ 'kw1','kw 2','kw3'], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + + is($meta->{license},'open_source','license: open_source'); + is($meta->{resources}->{license}, undef,'resources.license: URL'); + + my $makefile = makefile(); + ok( -f $makefile, 'Makefile created' ); + + my $content = _read($makefile); + ok( $content =~ /^#\s+PREREQ_PM/m, 'PREREQ_PM found' ); + + ok( kill_dist(), 'kill dist' ); +} diff --git a/t/49_license_perl.t b/t/49_license_perl.t new file mode 100644 index 0000000..426121e --- /dev/null +++ b/t/49_license_perl.t @@ -0,0 +1,85 @@ +#!perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More; +use t::lib::Test; +use YAML::Tiny (); + +plan tests => 14; + +SCOPE: { + ok( create_dist('Foo', { 'Makefile.PL' => <<'END_DSL' }), 'create_dist' ); +use inc::Module::Install 0.82; + +name 'Foo'; +license 'perl'; +author 'Foo Bar '; +all_from 'lib/Foo.pm'; +requires 'perl' => '5.008000'; +test_requires 'Test::More' => '0.86'; +no_index 'directory' => qw{ t xt share inc }; +install_share 'eg'; +keywords 'kw1','kw 2'; +keywords 'kw3'; + +WriteAll; +END_DSL + + unlink file('META.yml'); + unlink file('MYMETA.yml'); + ok( mkdir(dir('eg')), 'created eg/' ); + ok( add_file('eg/sample', 'This is a sample'), 'added sample' ); + ok( mkdir(dir('t')), 'created t/' ); + ok( add_file('t/01_comile.t', <<'END_TEST'), 'added test' ); +#!/usr/bin/perl + +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More tests => 2; + +ok( $] >= 5.005, 'Perl version is new enough' ); + +use_ok( 'Foo', 'Loaded Foo.pm' ); +END_TEST + + ok( build_dist(), 'build dist' ); + + my $metafile = file('META.yml'); + ok( -f $metafile, 'META.yml created' ); + + my $meta = YAML::Tiny::LoadFile($metafile); + + is_deeply( + [ sort @{ $meta->{no_index}->{directory} } ], + [ qw{ eg inc t } ], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + is_deeply( + $meta->{keywords}, + [ 'kw1','kw 2','kw3'], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + + is($meta->{license},'perl','license: perl'); + is($meta->{resources}->{license}, 'http://dev.perl.org/licenses/','resources.license: URL'); + + my $makefile = makefile(); + ok( -f $makefile, 'Makefile created' ); + + my $content = _read($makefile); + ok( $content =~ /^#\s+PREREQ_PM/m, 'PREREQ_PM found' ); + + ok( kill_dist(), 'kill dist' ); +} diff --git a/t/50_license_restrictive.t b/t/50_license_restrictive.t new file mode 100644 index 0000000..2e038ad --- /dev/null +++ b/t/50_license_restrictive.t @@ -0,0 +1,85 @@ +#!perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More; +use t::lib::Test; +use YAML::Tiny (); + +plan tests => 14; + +SCOPE: { + ok( create_dist('Foo', { 'Makefile.PL' => <<'END_DSL' }), 'create_dist' ); +use inc::Module::Install 0.82; + +name 'Foo'; +license 'restrictive'; +author 'Foo Bar '; +all_from 'lib/Foo.pm'; +requires 'perl' => '5.008000'; +test_requires 'Test::More' => '0.86'; +no_index 'directory' => qw{ t xt share inc }; +install_share 'eg'; +keywords 'kw1','kw 2'; +keywords 'kw3'; + +WriteAll; +END_DSL + + unlink file('META.yml'); + unlink file('MYMETA.yml'); + ok( mkdir(dir('eg')), 'created eg/' ); + ok( add_file('eg/sample', 'This is a sample'), 'added sample' ); + ok( mkdir(dir('t')), 'created t/' ); + ok( add_file('t/01_comile.t', <<'END_TEST'), 'added test' ); +#!/usr/bin/perl + +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More tests => 2; + +ok( $] >= 5.005, 'Perl version is new enough' ); + +use_ok( 'Foo', 'Loaded Foo.pm' ); +END_TEST + + ok( build_dist(), 'build dist' ); + + my $metafile = file('META.yml'); + ok( -f $metafile, 'META.yml created' ); + + my $meta = YAML::Tiny::LoadFile($metafile); + + is_deeply( + [ sort @{ $meta->{no_index}->{directory} } ], + [ qw{ eg inc t } ], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + is_deeply( + $meta->{keywords}, + [ 'kw1','kw 2','kw3'], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + + is($meta->{license},'restrictive','license: restrictive'); + is($meta->{resources}->{license}, undef,'resources.license: URL'); + + my $makefile = makefile(); + ok( -f $makefile, 'Makefile created' ); + + my $content = _read($makefile); + ok( $content =~ /^#\s+PREREQ_PM/m, 'PREREQ_PM found' ); + + ok( kill_dist(), 'kill dist' ); +} diff --git a/t/51_license_unrestricted.t b/t/51_license_unrestricted.t new file mode 100644 index 0000000..f18735d --- /dev/null +++ b/t/51_license_unrestricted.t @@ -0,0 +1,85 @@ +#!perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More; +use t::lib::Test; +use YAML::Tiny (); + +plan tests => 14; + +SCOPE: { + ok( create_dist('Foo', { 'Makefile.PL' => <<'END_DSL' }), 'create_dist' ); +use inc::Module::Install 0.82; + +name 'Foo'; +license 'unrestricted'; +author 'Foo Bar '; +all_from 'lib/Foo.pm'; +requires 'perl' => '5.008000'; +test_requires 'Test::More' => '0.86'; +no_index 'directory' => qw{ t xt share inc }; +install_share 'eg'; +keywords 'kw1','kw 2'; +keywords 'kw3'; + +WriteAll; +END_DSL + + unlink file('META.yml'); + unlink file('MYMETA.yml'); + ok( mkdir(dir('eg')), 'created eg/' ); + ok( add_file('eg/sample', 'This is a sample'), 'added sample' ); + ok( mkdir(dir('t')), 'created t/' ); + ok( add_file('t/01_comile.t', <<'END_TEST'), 'added test' ); +#!/usr/bin/perl + +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More tests => 2; + +ok( $] >= 5.005, 'Perl version is new enough' ); + +use_ok( 'Foo', 'Loaded Foo.pm' ); +END_TEST + + ok( build_dist(), 'build dist' ); + + my $metafile = file('META.yml'); + ok( -f $metafile, 'META.yml created' ); + + my $meta = YAML::Tiny::LoadFile($metafile); + + is_deeply( + [ sort @{ $meta->{no_index}->{directory} } ], + [ qw{ eg inc t } ], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + is_deeply( + $meta->{keywords}, + [ 'kw1','kw 2','kw3'], + 'no_index is ok', + ) or diag( + "no_index: @{ $meta->{no_index}->{directory} }" + ); + + is($meta->{license},'unrestricted','license: unrestricted'); + is($meta->{resources}->{license}, undef,'resources.license: URL'); + + my $makefile = makefile(); + ok( -f $makefile, 'Makefile created' ); + + my $content = _read($makefile); + ok( $content =~ /^#\s+PREREQ_PM/m, 'PREREQ_PM found' ); + + ok( kill_dist(), 'kill dist' ); +} diff --git a/t/52_license_unknown.t b/t/52_license_unknown.t new file mode 100644 index 0000000..65fb710 --- /dev/null +++ b/t/52_license_unknown.t @@ -0,0 +1,55 @@ +#!perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More; +use t::lib::Test; +use YAML::Tiny (); + +plan tests => 7; + +SCOPE: { + ok( create_dist('Foo', { 'Makefile.PL' => <<'END_DSL' }), 'create_dist' ); +use inc::Module::Install 0.82; + +name 'Foo'; +license 'rubharb'; +author 'Foo Bar '; +all_from 'lib/Foo.pm'; +requires 'perl' => '5.008000'; +test_requires 'Test::More' => '0.86'; +no_index 'directory' => qw{ t xt share inc }; +install_share 'eg'; +keywords 'kw1','kw 2'; +keywords 'kw3'; + +WriteAll; +END_DSL + + unlink file('META.yml'); + unlink file('MYMETA.yml'); + ok( mkdir(dir('eg')), 'created eg/' ); + ok( add_file('eg/sample', 'This is a sample'), 'added sample' ); + ok( mkdir(dir('t')), 'created t/' ); + ok( add_file('t/01_comile.t', <<'END_TEST'), 'added test' ); +#!/usr/bin/perl + +BEGIN { + $| = 1; + $^W = 1; +} + +use Test::More tests => 2; + +ok( $] >= 5.005, 'Perl version is new enough' ); + +use_ok( 'Foo', 'Loaded Foo.pm' ); +END_TEST + + is( build_dist(), 0, 'build dist failed with unknown license name' ); + ok( kill_dist(), 'kill dist' ); +} diff --git a/t/lib/Test.pm b/t/lib/Test.pm index 06f4a57..f048554 100644 --- a/t/lib/Test.pm +++ b/t/lib/Test.pm @@ -119,7 +119,7 @@ __END__ =head1 COPYRIGHT This program is free software; you can redistribute it and/or -modify it under the same terms as Perl itself. +modify it under the same terms as the perl 5 programming language system itself. =cut END_MODULE