@@ -0,0 +1,41 @@
+
+use strict;
+use warnings;
+
+use Module::Build 0.3601;
+
+my %module_build_args = (
+ 'dist_abstract' => 'common tests to check syntax of your modules',
+ 'script_files' => [],
+ 'license' => 'perl',
+ 'build_requires' => {
+ 'Test::More' => '0.88',
+ 'Scalar::Util' => '0',
+ 'English' => '0',
+ 'File::Find' => '0',
+ 'File::Temp' => '0',
+ 'Module::Build' => '0.3601',
+ 'Carp' => '0'
+ },
+ 'dist_name' => 'Dist-Zilla-Plugin-CompileTests',
+ 'dist_author' => [
+ 'Jerome Quelin'
+ ],
+ 'module_name' => 'Dist::Zilla::Plugin::CompileTests',
+ 'requires' => {
+ 'perl' => '5.008',
+ 'Dist::Zilla::Role::FileMunger' => '0',
+ 'Dist::Zilla::Plugin::InlineFiles' => '0',
+ 'Moose' => '0'
+ },
+ 'recommends' => {},
+ 'configure_requires' => {
+ 'Module::Build' => '0.3601'
+ },
+ 'dist_version' => '1.101500'
+ );
+
+
+my $build = Module::Build->new(%module_build_args);
+
+$build->create_build_script;
@@ -1,6 +1,19 @@
Revision history for Dist::Zilla::Plugin::CompileTests
-1.092870 2009-10-14 07:09:47 UTC
+1.101500 2010-05-30 17:55:12 Europe/Paris
+ - fix #57974: test::script 1.05 changed its interface
+
+1.100740 2010-03-15 18:29:52 Europe/Paris
+ - allow PERL5OPT to get a chance to be respected (marcel gruenauer)
+
+1.100220 2010-01-22 16:26:16 Europe/Paris
+ - new param fake_home to control $ENV{HOME} faking
+
+1.100160 2010-01-16 14:43:14 Europe/Paris
+ - requiring perl 5.8.x
+ - faking $ENV{HOME} for cpantesters
+
+1.092870 Wed Oct 14 09:10:00 2009
- fix: skip did not update test count
1.092840 Sun Oct 11 19:12:32 2009
@@ -1,13 +1,20 @@
+Build.PL
Changes
LICENSE
MANIFEST
META.yml
-Makefile.PL
README
dist.ini
+examples/dist.ini
lib/Dist/Zilla/Plugin/CompileTests.pm
t/00-compile.t
+t/000-report-versions.t
t/author-critic.t
-t/release-meta-yaml.t
+t/release-distmeta.t
+t/release-has-version.t
+t/release-kwalitee.t
+t/release-minimum-version.t
t/release-pod-coverage.t
-t/release-pod-syntax.t
\ No newline at end of file
+t/release-pod-syntax.t
+t/release-portability.t
+t/release-unused-vars.t
\ No newline at end of file
@@ -2,7 +2,17 @@
abstract: 'common tests to check syntax of your modules'
author:
- 'Jerome Quelin'
-generated_by: 'Dist::Zilla version 1.092680'
+build_requires:
+ Carp: 0
+ English: 0
+ File::Find: 0
+ File::Temp: 0
+ Module::Build: 0.3601
+ Scalar::Util: 0
+ Test::More: 0.88
+configure_requires:
+ Module::Build: 0.3601
+generated_by: 'Dist::Zilla version 2.101151'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -11,16 +21,198 @@ name: Dist-Zilla-Plugin-CompileTests
provides:
Dist::Zilla::Plugin::CompileTests:
file: lib/Dist/Zilla/Plugin/CompileTests.pm
- version: 1.092870
+ version: 1.101500
+recommends: {}
requires:
Dist::Zilla::Plugin::InlineFiles: 0
Dist::Zilla::Role::FileMunger: 0
- English: 0
- ExtUtils::MakeMaker: 0
- File::Find: 0
Moose: 0
- Test::More: 0
+ perl: 5.008
resources:
- homepage: http://search.cpan.org/dist/Dist-Zilla-Plugin-CompileTests
+ bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-CompileTests
+ homepage: http://search.cpan.org/dist/Dist-Zilla-Plugin-CompileTests/
repository: http://github.com/jquelin/dist-zilla-plugin-compiletests
-version: 1.092870
+version: 1.101500
+x_Dist_Zilla:
+ plugins:
+ -
+ class: Dist::Zilla::Plugin::MetaResources
+ name: MetaResources
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::AutoVersion
+ name: '@JQUELIN/AutoVersion'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::GatherDir
+ name: '@JQUELIN/GatherDir'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::CompileTests
+ name: '@JQUELIN/CompileTests'
+ version: 1.100740
+ -
+ class: Dist::Zilla::Plugin::CriticTests
+ name: '@JQUELIN/CriticTests'
+ version: 1.100140
+ -
+ class: Dist::Zilla::Plugin::HasVersionTests
+ name: '@JQUELIN/HasVersionTests'
+ version: 1.100700
+ -
+ class: Dist::Zilla::Plugin::KwaliteeTests
+ name: '@JQUELIN/KwaliteeTests'
+ version: 1.100690
+ -
+ class: Dist::Zilla::Plugin::MetaTests
+ name: '@JQUELIN/MetaTests'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::MinimumVersionTests
+ name: '@JQUELIN/MinimumVersionTests'
+ version: 1.100700
+ -
+ class: Dist::Zilla::Plugin::PodCoverageTests
+ name: '@JQUELIN/PodCoverageTests'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::PodSyntaxTests
+ name: '@JQUELIN/PodSyntaxTests'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::PortabilityTests
+ name: '@JQUELIN/PortabilityTests'
+ version: 1.100700
+ -
+ class: Dist::Zilla::Plugin::ReportVersions
+ name: '@JQUELIN/ReportVersions'
+ version: 1.100880
+ -
+ class: Dist::Zilla::Plugin::UnusedVarsTests
+ name: '@JQUELIN/UnusedVarsTests'
+ version: 1.100860
+ -
+ class: Dist::Zilla::Plugin::PruneCruft
+ name: '@JQUELIN/PruneCruft'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::ManifestSkip
+ name: '@JQUELIN/ManifestSkip'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::AutoPrereq
+ name: '@JQUELIN/AutoPrereq'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::ExtraTests
+ name: '@JQUELIN/ExtraTests'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::NextRelease
+ name: '@JQUELIN/NextRelease'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::PkgVersion
+ name: '@JQUELIN/PkgVersion'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::PodWeaver
+ name: '@JQUELIN/PodWeaver'
+ version: 3.100710
+ -
+ class: Dist::Zilla::Plugin::Prepender
+ name: '@JQUELIN/Prepender'
+ version: 1.100960
+ -
+ class: Dist::Zilla::Plugin::ExecDir
+ name: '@JQUELIN/ExecDir'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::ShareDir
+ name: '@JQUELIN/ShareDir'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::Bugtracker
+ name: '@JQUELIN/Bugtracker'
+ version: 1.100701
+ -
+ class: Dist::Zilla::Plugin::Homepage
+ name: '@JQUELIN/Homepage'
+ version: 1.100700
+ -
+ class: Dist::Zilla::Plugin::Repository
+ name: '@JQUELIN/Repository'
+ version: 0.11
+ -
+ class: Dist::Zilla::Plugin::MetaProvides::Package
+ name: '@JQUELIN/MetaProvides::Package'
+ version: 1.10001919
+ -
+ class: Dist::Zilla::Plugin::MetaConfig
+ name: '@JQUELIN/MetaConfig'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::License
+ name: '@JQUELIN/License'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::MetaYAML
+ name: '@JQUELIN/MetaYAML'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::ModuleBuild
+ name: '@JQUELIN/ModuleBuild'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::Readme
+ name: '@JQUELIN/Readme'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::Manifest
+ name: '@JQUELIN/Manifest'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::CheckChangeLog
+ name: '@JQUELIN/CheckChangeLog'
+ version: 0.01
+ -
+ class: Dist::Zilla::Plugin::UploadToCPAN
+ name: '@JQUELIN/UploadToCPAN'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::Git::Check
+ name: '@JQUELIN/Git/Check'
+ version: 1.100970
+ -
+ class: Dist::Zilla::Plugin::Git::Commit
+ name: '@JQUELIN/Git/Commit'
+ version: 1.100970
+ -
+ class: Dist::Zilla::Plugin::Git::Tag
+ name: '@JQUELIN/Git/Tag'
+ version: 1.100970
+ -
+ class: Dist::Zilla::Plugin::Git::Push
+ name: '@JQUELIN/Git/Push'
+ version: 1.100970
+ -
+ class: Dist::Zilla::Plugin::FinderCode
+ name: ':InstallModules'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::FinderCode
+ name: ':TestFiles'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::FinderCode
+ name: ':ExecFiles'
+ version: 2.101151
+ -
+ class: Dist::Zilla::Plugin::FinderCode
+ name: ':ShareFiles'
+ version: 2.101151
+ zilla:
+ class: Dist::Zilla
+ config:
+ is_trial: 0
+ version: 2.101151
@@ -1,25 +0,0 @@
-
-use strict;
-use warnings;
-
-use ExtUtils::MakeMaker;
-
-WriteMakefile(
- DISTNAME => 'Dist-Zilla-Plugin-CompileTests',
- NAME => 'Dist::Zilla::Plugin::CompileTests',
- AUTHOR => 'Jerome\ Quelin',
- ABSTRACT => 'common\ tests\ to\ check\ syntax\ of\ your\ modules',
- VERSION => '1.092870',
- EXE_FILES => [ qw() ],
- (eval { ExtUtils::MakeMaker->VERSION(6.31) } ? (LICENSE => 'perl') : ()),
- PREREQ_PM => {
- "Test::More" => '0',
- "Dist::Zilla::Role::FileMunger" => '0',
- "English" => '0',
- "File::Find" => '0',
- "Moose" => '0',
- "Dist::Zilla::Plugin::InlineFiles" => '0',
- },
- test => {TESTS => 't/*.t'}
-);
-
@@ -1,7 +1,7 @@
-This archive contains the distribution Dist-Zilla-Plugin-CompileTests, version
-1.092870:
+This archive contains the distribution Dist-Zilla-Plugin-CompileTests,
+version 1.101500:
common tests to check syntax of your modules
@@ -10,3 +10,4 @@ This software is copyright (c) 2009 by Jerome Quelin.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
+
@@ -6,73 +6,9 @@ copyright_year = 2009
; -- static meta-information
-
[MetaResources]
homepage = http://search.cpan.org/dist/Dist-Zilla-Plugin-CompileTests
repository = http://github.com/jquelin/dist-zilla-plugin-compiletests
;MailingList = none
-[AutoVersion]
-major = 1
-format = {{ $major }}.{{ cldr('yyDDD') }}{{ sprintf '%01u', ($ENV{N} || 0) }}
-
-
-; -- fetch & generate files
-
-[AllFiles]
-
-[CompileTests]
-[CriticTests]
-[MetaTests]
-[PodTests]
-
-
-; -- remove files
-
-[PruneCruft]
-
-;[PruneFiles]
-; file =
-
-[ManifestSkip]
-
-
-; -- get prereqs
-
-[AutoPrereq]
-
-
-; -- munge files
-
-[ExtraTests]
-[NextRelease]
-[PkgVersion]
-[PodPurler]
-
-;[PodVersion]
-; already taken care of by PodPurler
-
-[Prepender]
-copyright = 1
-
-
-; -- dynamic meta information
-
-[InstallDirs]
-[MetaProvides::Package]
-
-
-; -- generate meta files
-
-[License]
-[MakeMaker]
-[MetaYAML]
-[Readme]
-
-[Manifest] ; should come last
-
-
-; -- release
-
-[CheckChangeLog]
-[UploadToCPAN]
+[@JQUELIN]
@@ -0,0 +1,13 @@
+; standard intro section of your dist.ini
+name = My-Super-Cool-Dist
+author = A. U. Thor
+license = Perl_5
+copyright_holder = A. U. Thor
+copyright_year = 2009
+
+
+; use the following to add a new 00-compile.t test
+[CompileTests]
+
+
+; rest of your dist.ini looks the same
@@ -6,13 +6,14 @@
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
#
+use 5.008;
use strict;
use warnings;
package Dist::Zilla::Plugin::CompileTests;
-our $VERSION = '1.092870';
-
-
+BEGIN {
+ $Dist::Zilla::Plugin::CompileTests::VERSION = '1.101500';
+}
# ABSTRACT: common tests to check syntax of your modules
use Moose;
@@ -22,8 +23,8 @@ with 'Dist::Zilla::Role::FileMunger';
# -- attributes
-# skiplist - a regex
-has skip => ( is=>'ro', predicate=>'has_skip' );
+has fake_home => ( is=>'ro', predicate=>'has_fake_home' );
+has skip => ( is=>'ro', predicate=>'has_skip' ); # skiplist - a regex
# -- public methods
@@ -34,13 +35,18 @@ sub munge_file {
return unless $file->name eq 't/00-compile.t';
- my $replacement = ( $self->has_skip && $self->skip )
+ my $skip = ( $self->has_skip && $self->skip )
? sprintf( 'return if $found =~ /%s/;', $self->skip )
: '# nothing to skip';
- # replace the string in the file
+ my $home = ( $self->has_fake_home && $self->fake_home )
+ ? ''
+ : '# no fake requested ##';
+
+ # replace strings in the file
my $content = $file->content;
- $content =~ s/COMPILETESTS_SKIP/$replacement/;
+ $content =~ s/COMPILETESTS_SKIP/$skip/;
+ $content =~ s/COMPILETESTS_FAKE_HOME/$home/;
$file->content( $content );
}
@@ -52,7 +58,6 @@ __PACKAGE__->meta->make_immutable;
-
=pod
=head1 NAME
@@ -61,20 +66,15 @@ Dist::Zilla::Plugin::CompileTests - common tests to check syntax of your modules
=head1 VERSION
-version 1.092870
-
-=begin Pod::Coverage
-
-munge_file
-
-=end Pod::Coverage
+version 1.101500
=head1 SYNOPSIS
In your dist.ini:
[CompileTests]
- skip = Test$
+ skip = Test$
+ fake_home = 1
=head1 DESCRIPTION
@@ -89,7 +89,7 @@ This test will find all modules and scripts in your dist, and try to
compile them one by one. This means it's a bit slower than loading them
all at once, but it will catch more errors.
-=back
+=back
This plugin accepts the following options:
@@ -99,7 +99,14 @@ This plugin accepts the following options:
match is done against the module name (C<Foo::Bar>), not the file path
(F<lib/Foo/Bar.pm>).
-=back
+=item * fake_home: a boolean to indicate whether to fake $ENV{HOME}.
+This may be needed if your module unilateraly creates stuff in homedir:
+indeed, some cpantesters will smoke test your dist with a read-only home
+directory. Default to false.
+
+=back
+
+=for Pod::Coverage::TrustPod munge_file
=head1 SEE ALSO
@@ -123,10 +130,7 @@ L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dist-Zilla-Plugin-CompileTests>
L<http://github.com/jquelin/dist-zilla-plugin-compiletests.git>.
-=back
-
-
-
+=back
=head1 AUTHOR
@@ -139,8 +143,7 @@ This software is copyright (c) 2009 by Jerome Quelin.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
-=cut
-
+=cut
__DATA__
@@ -152,6 +155,7 @@ use warnings;
use Test::More;
use File::Find;
+use File::Temp qw{ tempdir };
my @modules;
find(
@@ -170,16 +174,21 @@ find(
my @scripts = glob "bin/*";
plan tests => scalar(@modules) + scalar(@scripts);
-
-is( qx{ $^X -Ilib -M$_ -e "print '$_ ok'" }, "$_ ok", "$_ loaded ok" )
- for sort @modules;
-
-SKIP: {
- eval "use Test::Script; 1;";
- skip "Test::Script needed to test script compilation", scalar(@scripts) if $@;
- foreach my $file ( @scripts ) {
- my $script = $file;
- $script =~ s!.*/!!;
- script_compiles_ok( $file, "$script script compiles" );
+
+{
+ # fake home for cpan-testers
+ COMPILETESTS_FAKE_HOME local $ENV{HOME} = tempdir( CLEANUP => 1 );
+
+ is( qx{ $^X -Ilib -e "use $_; print '$_ ok'" }, "$_ ok", "$_ 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" );
+ }
}
-}
\ No newline at end of file
+}
@@ -13,6 +13,7 @@ use warnings;
use Test::More;
use File::Find;
+use File::Temp qw{ tempdir };
my @modules;
find(
@@ -31,16 +32,21 @@ find(
my @scripts = glob "bin/*";
plan tests => scalar(@modules) + scalar(@scripts);
-
-is( qx{ $^X -Ilib -M$_ -e "print '$_ ok'" }, "$_ ok", "$_ loaded ok" )
- for sort @modules;
-
-SKIP: {
- eval "use Test::Script; 1;";
- skip "Test::Script needed to test script compilation", scalar(@scripts) if $@;
- foreach my $file ( @scripts ) {
- my $script = $file;
- $script =~ s!.*/!!;
- script_compiles_ok( $file, "$script script compiles" );
+
+{
+ # fake home for cpan-testers
+ # no fake requested ## local $ENV{HOME} = tempdir( CLEANUP => 1 );
+
+ is( qx{ $^X -Ilib -e "use $_; print '$_ ok'" }, "$_ ok", "$_ loaded ok" )
+ for sort @modules;
+
+ SKIP: {
+ eval "use Test::Script; 1;";
+ skip "Test::Script needed to test script compilation", scalar(@scripts) if $@;
+ foreach my $file ( @scripts ) {
+ my $script = $file;
+ $script =~ s!.*/!!;
+ script_compiles_ok( $file, "$script script compiles" );
+ }
}
-}
\ No newline at end of file
+}
@@ -0,0 +1,450 @@
+#!perl
+#
+# This file is part of Dist-Zilla-Plugin-CompileTests
+#
+# This software is copyright (c) 2009 by Jerome Quelin.
+#
+# This is free software; you can redistribute it and/or modify it under
+# the same terms as the Perl 5 programming language system itself.
+#
+use warnings;
+use strict;
+use Test::More 0.88;
+
+# Include a cut-down version of YAML::Tiny so we don't introduce unnecessary
+# dependencies ourselves.
+
+package Local::YAML::Tiny;
+
+use strict;
+use Carp 'croak';
+
+# UTF Support?
+sub HAVE_UTF8 () { $] >= 5.007003 }
+BEGIN {
+ if ( HAVE_UTF8 ) {
+ # The string eval helps hide this from Test::MinimumVersion
+ eval "require utf8;";
+ die "Failed to load UTF-8 support" if $@;
+ }
+
+ # Class structure
+ require 5.004;
+ $YAML::Tiny::VERSION = '1.40';
+
+ # Error storage
+ $YAML::Tiny::errstr = '';
+}
+
+# Printable characters for escapes
+my %UNESCAPES = (
+ z => "\x00", a => "\x07", t => "\x09",
+ n => "\x0a", v => "\x0b", f => "\x0c",
+ r => "\x0d", e => "\x1b", '\\' => '\\',
+);
+
+
+#####################################################################
+# Implementation
+
+# Create an empty YAML::Tiny object
+sub new {
+ my $class = shift;
+ bless [ @_ ], $class;
+}
+
+# Create an object from a file
+sub read {
+ my $class = ref $_[0] ? ref shift : shift;
+
+ # Check the file
+ my $file = shift or return $class->_error( 'You did not specify a file name' );
+ return $class->_error( "File '$file' does not exist" ) unless -e $file;
+ return $class->_error( "'$file' is a directory, not a file" ) unless -f _;
+ return $class->_error( "Insufficient permissions to read '$file'" ) unless -r _;
+
+ # Slurp in the file
+ local $/ = undef;
+ local *CFG;
+ unless ( open(CFG, $file) ) {
+ return $class->_error("Failed to open file '$file': $!");
+ }
+ my $contents = <CFG>;
+ unless ( close(CFG) ) {
+ return $class->_error("Failed to close file '$file': $!");
+ }
+
+ $class->read_string( $contents );
+}
+
+# Create an object from a string
+sub read_string {
+ my $class = ref $_[0] ? ref shift : shift;
+ my $self = bless [], $class;
+ my $string = $_[0];
+ unless ( defined $string ) {
+ return $self->_error("Did not provide a string to load");
+ }
+
+ # Byte order marks
+ # NOTE: Keeping this here to educate maintainers
+ # my %BOM = (
+ # "\357\273\277" => 'UTF-8',
+ # "\376\377" => 'UTF-16BE',
+ # "\377\376" => 'UTF-16LE',
+ # "\377\376\0\0" => 'UTF-32LE'
+ # "\0\0\376\377" => 'UTF-32BE',
+ # );
+ if ( $string =~ /^(?:\376\377|\377\376|\377\376\0\0|\0\0\376\377)/ ) {
+ return $self->_error("Stream has a non UTF-8 BOM");
+ } else {
+ # Strip UTF-8 bom if found, we'll just ignore it
+ $string =~ s/^\357\273\277//;
+ }
+
+ # Try to decode as utf8
+ utf8::decode($string) if HAVE_UTF8;
+
+ # Check for some special cases
+ return $self unless length $string;
+ unless ( $string =~ /[\012\015]+\z/ ) {
+ return $self->_error("Stream does not end with newline character");
+ }
+
+ # Split the file into lines
+ my @lines = grep { ! /^\s*(?:\#.*)?\z/ }
+ split /(?:\015{1,2}\012|\015|\012)/, $string;
+
+ # Strip the initial YAML header
+ @lines and $lines[0] =~ /^\%YAML[: ][\d\.]+.*\z/ and shift @lines;
+
+ # A nibbling parser
+ while ( @lines ) {
+ # Do we have a document header?
+ if ( $lines[0] =~ /^---\s*(?:(.+)\s*)?\z/ ) {
+ # Handle scalar documents
+ shift @lines;
+ if ( defined $1 and $1 !~ /^(?:\#.+|\%YAML[: ][\d\.]+)\z/ ) {
+ push @$self, $self->_read_scalar( "$1", [ undef ], \@lines );
+ next;
+ }
+ }
+
+ if ( ! @lines or $lines[0] =~ /^(?:---|\.\.\.)/ ) {
+ # A naked document
+ push @$self, undef;
+ while ( @lines and $lines[0] !~ /^---/ ) {
+ shift @lines;
+ }
+
+ } elsif ( $lines[0] =~ /^\s*\-/ ) {
+ # An array at the root
+ my $document = [ ];
+ push @$self, $document;
+ $self->_read_array( $document, [ 0 ], \@lines );
+
+ } elsif ( $lines[0] =~ /^(\s*)\S/ ) {
+ # A hash at the root
+ my $document = { };
+ push @$self, $document;
+ $self->_read_hash( $document, [ length($1) ], \@lines );
+
+ } else {
+ croak("YAML::Tiny failed to classify the line '$lines[0]'");
+ }
+ }
+
+ $self;
+}
+
+# Deparse a scalar string to the actual scalar
+sub _read_scalar {
+ my ($self, $string, $indent, $lines) = @_;
+
+ # Trim trailing whitespace
+ $string =~ s/\s*\z//;
+
+ # Explitic null/undef
+ return undef if $string eq '~';
+
+ # Quotes
+ if ( $string =~ /^\'(.*?)\'\z/ ) {
+ return '' unless defined $1;
+ $string = $1;
+ $string =~ s/\'\'/\'/g;
+ return $string;
+ }
+ if ( $string =~ /^\"((?:\\.|[^\"])*)\"\z/ ) {
+ # Reusing the variable is a little ugly,
+ # but avoids a new variable and a string copy.
+ $string = $1;
+ $string =~ s/\\"/"/g;
+ $string =~ s/\\([never\\fartz]|x([0-9a-fA-F]{2}))/(length($1)>1)?pack("H2",$2):$UNESCAPES{$1}/gex;
+ return $string;
+ }
+
+ # Special cases
+ if ( $string =~ /^[\'\"!&]/ ) {
+ croak("YAML::Tiny does not support a feature in line '$lines->[0]'");
+ }
+ return {} if $string eq '{}';
+ return [] if $string eq '[]';
+
+ # Regular unquoted string
+ return $string unless $string =~ /^[>|]/;
+
+ # Error
+ croak("YAML::Tiny failed to find multi-line scalar content") unless @$lines;
+
+ # Check the indent depth
+ $lines->[0] =~ /^(\s*)/;
+ $indent->[-1] = length("$1");
+ if ( defined $indent->[-2] and $indent->[-1] <= $indent->[-2] ) {
+ croak("YAML::Tiny found bad indenting in line '$lines->[0]'");
+ }
+
+ # Pull the lines
+ my @multiline = ();
+ while ( @$lines ) {
+ $lines->[0] =~ /^(\s*)/;
+ last unless length($1) >= $indent->[-1];
+ push @multiline, substr(shift(@$lines), length($1));
+ }
+
+ my $j = (substr($string, 0, 1) eq '>') ? ' ' : "\n";
+ my $t = (substr($string, 1, 1) eq '-') ? '' : "\n";
+ return join( $j, @multiline ) . $t;
+}
+
+# Parse an array
+sub _read_array {
+ my ($self, $array, $indent, $lines) = @_;
+
+ while ( @$lines ) {
+ # Check for a new document
+ if ( $lines->[0] =~ /^(?:---|\.\.\.)/ ) {
+ while ( @$lines and $lines->[0] !~ /^---/ ) {
+ shift @$lines;
+ }
+ return 1;
+ }
+
+ # Check the indent level
+ $lines->[0] =~ /^(\s*)/;
+ if ( length($1) < $indent->[-1] ) {
+ return 1;
+ } elsif ( length($1) > $indent->[-1] ) {
+ croak("YAML::Tiny found bad indenting in line '$lines->[0]'");
+ }
+
+ if ( $lines->[0] =~ /^(\s*\-\s+)[^\'\"]\S*\s*:(?:\s+|$)/ ) {
+ # Inline nested hash
+ my $indent2 = length("$1");
+ $lines->[0] =~ s/-/ /;
+ push @$array, { };
+ $self->_read_hash( $array->[-1], [ @$indent, $indent2 ], $lines );
+
+ } elsif ( $lines->[0] =~ /^\s*\-(\s*)(.+?)\s*\z/ ) {
+ # Array entry with a value
+ shift @$lines;
+ push @$array, $self->_read_scalar( "$2", [ @$indent, undef ], $lines );
+
+ } elsif ( $lines->[0] =~ /^\s*\-\s*\z/ ) {
+ shift @$lines;
+ unless ( @$lines ) {
+ push @$array, undef;
+ return 1;
+ }
+ if ( $lines->[0] =~ /^(\s*)\-/ ) {
+ my $indent2 = length("$1");
+ if ( $indent->[-1] == $indent2 ) {
+ # Null array entry
+ push @$array, undef;
+ } else {
+ # Naked indenter
+ push @$array, [ ];
+ $self->_read_array( $array->[-1], [ @$indent, $indent2 ], $lines );
+ }
+
+ } elsif ( $lines->[0] =~ /^(\s*)\S/ ) {
+ push @$array, { };
+ $self->_read_hash( $array->[-1], [ @$indent, length("$1") ], $lines );
+
+ } else {
+ croak("YAML::Tiny failed to classify line '$lines->[0]'");
+ }
+
+ } elsif ( defined $indent->[-2] and $indent->[-1] == $indent->[-2] ) {
+ # This is probably a structure like the following...
+ # ---
+ # foo:
+ # - list
+ # bar: value
+ #
+ # ... so lets return and let the hash parser handle it
+ return 1;
+
+ } else {
+ croak("YAML::Tiny failed to classify line '$lines->[0]'");
+ }
+ }
+
+ return 1;
+}
+
+# Parse an array
+sub _read_hash {
+ my ($self, $hash, $indent, $lines) = @_;
+
+ while ( @$lines ) {
+ # Check for a new document
+ if ( $lines->[0] =~ /^(?:---|\.\.\.)/ ) {
+ while ( @$lines and $lines->[0] !~ /^---/ ) {
+ shift @$lines;
+ }
+ return 1;
+ }
+
+ # Check the indent level
+ $lines->[0] =~ /^(\s*)/;
+ if ( length($1) < $indent->[-1] ) {
+ return 1;
+ } elsif ( length($1) > $indent->[-1] ) {
+ croak("YAML::Tiny found bad indenting in line '$lines->[0]'");
+ }
+
+ # Get the key
+ unless ( $lines->[0] =~ s/^\s*([^\'\" ][^\n]*?)\s*:(\s+|$)// ) {
+ if ( $lines->[0] =~ /^\s*[?\'\"]/ ) {
+ croak("YAML::Tiny does not support a feature in line '$lines->[0]'");
+ }
+ croak("YAML::Tiny failed to classify line '$lines->[0]'");
+ }
+ my $key = $1;
+
+ # Do we have a value?
+ if ( length $lines->[0] ) {
+ # Yes
+ $hash->{$key} = $self->_read_scalar( shift(@$lines), [ @$indent, undef ], $lines );
+ } else {
+ # An indent
+ shift @$lines;
+ unless ( @$lines ) {
+ $hash->{$key} = undef;
+ return 1;
+ }
+ if ( $lines->[0] =~ /^(\s*)-/ ) {
+ $hash->{$key} = [];
+ $self->_read_array( $hash->{$key}, [ @$indent, length($1) ], $lines );
+ } elsif ( $lines->[0] =~ /^(\s*)./ ) {
+ my $indent2 = length("$1");
+ if ( $indent->[-1] >= $indent2 ) {
+ # Null hash entry
+ $hash->{$key} = undef;
+ } else {
+ $hash->{$key} = {};
+ $self->_read_hash( $hash->{$key}, [ @$indent, length($1) ], $lines );
+ }
+ }
+ }
+ }
+
+ return 1;
+}
+
+# Set error
+sub _error {
+ $YAML::Tiny::errstr = $_[1];
+ undef;
+}
+
+# Retrieve error
+sub errstr {
+ $YAML::Tiny::errstr;
+}
+
+
+
+#####################################################################
+# Use Scalar::Util if possible, otherwise emulate it
+
+BEGIN {
+ eval {
+ require Scalar::Util;
+ };
+ if ( $@ ) {
+ # Failed to load Scalar::Util
+ eval <<'END_PERL';
+sub refaddr {
+ my $pkg = ref($_[0]) or return undef;
+ if (!!UNIVERSAL::can($_[0], 'can')) {
+ bless $_[0], 'Scalar::Util::Fake';
+ } else {
+ $pkg = undef;
+ }
+ "$_[0]" =~ /0x(\w+)/;
+ my $i = do { local $^W; hex $1 };
+ bless $_[0], $pkg if defined $pkg;
+ $i;
+}
+END_PERL
+ } else {
+ Scalar::Util->import('refaddr');
+ }
+}
+
+
+#####################################################################
+# main test
+#####################################################################
+
+package main;
+
+BEGIN {
+
+ # Skip modules that either don't want to be loaded directly, such as
+ # Module::Install, or that mess with the test count, such as the Test::*
+ # modules listed here.
+ #
+ # Moose::Role conflicts if Moose is loaded as well, but Moose::Role is in
+ # the Moose distribution and it's certain that someone who uses
+ # Moose::Role also uses Moose somewhere, so if we disallow Moose::Role,
+ # we'll still get the relevant version number.
+
+ my %skip = map { $_ => 1 } qw(
+ App::FatPacker
+ Class::Accessor::Classy
+ Module::Install
+ Moose::Role
+ Test::YAML::Meta
+ Test::Pod::Coverage
+ Test::Portability::Files
+ );
+
+ my $Test = Test::Builder->new;
+
+ $Test->plan(skip_all => "META.yml could not be found")
+ unless -f 'META.yml' and -r _;
+
+ my $meta = (Local::YAML::Tiny->read('META.yml'))->[0];
+ my %requires;
+ for my $require_key (grep { /requires/ } keys %$meta) {
+ my %h = %{ $meta->{$require_key} };
+ $requires{$_}++ for keys %h;
+ }
+ delete $requires{perl};
+
+ diag("Testing with Perl $], $^X");
+ for my $module (sort keys %requires) {
+ if ($skip{$module}) {
+ note "$module doesn't want to be loaded directly, skipping";
+ next;
+ }
+ local $SIG{__WARN__} = sub { note "$module: $_[0]" };
+ use_ok $module or BAIL_OUT("can't load $module");
+ my $version = $module->VERSION;
+ $version = 'undefined' unless defined $version;
+ diag(" $module version is $version");
+ }
+ done_testing;
+}
@@ -16,6 +16,9 @@ BEGIN {
}
+use strict;
+use warnings;
+
use Test::More;
use English qw(-no_match_vars);
@@ -0,0 +1,23 @@
+#!perl
+#
+# This file is part of Dist-Zilla-Plugin-CompileTests
+#
+# This software is copyright (c) 2009 by Jerome Quelin.
+#
+# This is free software; you can redistribute it and/or modify it under
+# the same terms as the Perl 5 programming language system itself.
+#
+
+BEGIN {
+ unless ($ENV{RELEASE_TESTING}) {
+ require Test::More;
+ Test::More::plan(skip_all => 'these tests are for release candidate testing');
+ }
+}
+
+
+use Test::More;
+
+eval "use Test::CPAN::Meta";
+plan skip_all => "Test::CPAN::Meta required for testing META.yml" if $@;
+meta_yaml_ok();
\ No newline at end of file
@@ -0,0 +1,24 @@
+#!perl
+#
+# This file is part of Dist-Zilla-Plugin-CompileTests
+#
+# This software is copyright (c) 2009 by Jerome Quelin.
+#
+# This is free software; you can redistribute it and/or modify it under
+# the same terms as the Perl 5 programming language system itself.
+#
+
+BEGIN {
+ unless ($ENV{RELEASE_TESTING}) {
+ require Test::More;
+ Test::More::plan(skip_all => 'these tests are for release candidate testing');
+ }
+}
+
+
+use Test::More;
+
+eval "use Test::HasVersion";
+plan skip_all => "Test::HasVersion required for testing version numbers"
+ if $@;
+all_pm_version_ok();
\ No newline at end of file
@@ -0,0 +1,23 @@
+#!perl
+#
+# This file is part of Dist-Zilla-Plugin-CompileTests
+#
+# This software is copyright (c) 2009 by Jerome Quelin.
+#
+# This is free software; you can redistribute it and/or modify it under
+# the same terms as the Perl 5 programming language system itself.
+#
+
+BEGIN {
+ unless ($ENV{RELEASE_TESTING}) {
+ require Test::More;
+ Test::More::plan(skip_all => 'these tests are for release candidate testing');
+ }
+}
+
+
+use Test::More;
+
+eval "use Test::Kwalitee";
+plan skip_all => "Test::Kwalitee required for testing kwalitee"
+ if $@;
\ No newline at end of file
@@ -1,23 +0,0 @@
-#!perl
-#
-# This file is part of Dist-Zilla-Plugin-CompileTests
-#
-# This software is copyright (c) 2009 by Jerome Quelin.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
-
-BEGIN {
- unless ($ENV{RELEASE_TESTING}) {
- require Test::More;
- Test::More::plan(skip_all => 'these tests are for release candidate testing');
- }
-}
-
-
-use Test::More;
-
-eval "use Test::CPAN::Meta";
-plan skip_all => "Test::CPAN::Meta required for testing META.yml" if $@;
-meta_yaml_ok();
\ No newline at end of file
@@ -0,0 +1,24 @@
+#!perl
+#
+# This file is part of Dist-Zilla-Plugin-CompileTests
+#
+# This software is copyright (c) 2009 by Jerome Quelin.
+#
+# This is free software; you can redistribute it and/or modify it under
+# the same terms as the Perl 5 programming language system itself.
+#
+
+BEGIN {
+ unless ($ENV{RELEASE_TESTING}) {
+ require Test::More;
+ Test::More::plan(skip_all => 'these tests are for release candidate testing');
+ }
+}
+
+
+use Test::More;
+
+eval "use Test::MinimumVersion";
+plan skip_all => "Test::MinimumVersion required for testing minimum versions"
+ if $@;
+all_minimum_version_from_metayml_ok();
\ No newline at end of file
@@ -0,0 +1,24 @@
+#!perl
+#
+# This file is part of Dist-Zilla-Plugin-CompileTests
+#
+# This software is copyright (c) 2009 by Jerome Quelin.
+#
+# This is free software; you can redistribute it and/or modify it under
+# the same terms as the Perl 5 programming language system itself.
+#
+
+BEGIN {
+ unless ($ENV{RELEASE_TESTING}) {
+ require Test::More;
+ Test::More::plan(skip_all => 'these tests are for release candidate testing');
+ }
+}
+
+
+use Test::More;
+
+eval "use Test::Portability::Files";
+plan skip_all => "Test::Portability::Files required for testing portability"
+ if $@;
+run_tests();
\ No newline at end of file
@@ -0,0 +1,24 @@
+#!perl
+#
+# This file is part of Dist-Zilla-Plugin-CompileTests
+#
+# This software is copyright (c) 2009 by Jerome Quelin.
+#
+# This is free software; you can redistribute it and/or modify it under
+# the same terms as the Perl 5 programming language system itself.
+#
+
+BEGIN {
+ unless ($ENV{RELEASE_TESTING}) {
+ require Test::More;
+ Test::More::plan(skip_all => 'these tests are for release candidate testing');
+ }
+}
+
+
+use Test::More;
+
+eval "use Test::Vars";
+plan skip_all => "Test::Vars required for testing unused vars"
+ if $@;
+all_vars_ok();
\ No newline at end of file