The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Build.PL 12
Changes 017
MANIFEST 55
META.json 45
META.yml 45
Makefile.PL 23
README 67
lib/Test/Compile/Internal.pm 1118
lib/Test/Compile.pm 15136
t/000-compile.t 09
t/100-internal-all-pm-files.t 45
t/100-internal-mess-with-lib.t 021
t/100-internal-pl-file-compiles.t 01
t/100-internal-pm-file-compiles.t 38
t/100-internal-verbose.t 11
t/200-basic.t 100
t/200-lib.t 170
t/scripts/LethalImport.pm 05
t/scripts/lib.pl 01
xt/author/00-compile.t 100
20 files changed (This is a version diff) 93249
@@ -12,8 +12,9 @@ my $build = Module::Build->new (
     license  => 'perl',
     configure_requires => { 'Module::Build' => 0.38 },
     requires => {
-       'perl'               => '5.6.0',
+       'perl'               => '5.6.2',
        'UNIVERSAL::require' => 0,
+       'version'            => 0,
     },
     recommends => {
         'Devel::CheckOS' => 0,
@@ -1,5 +1,22 @@
 Revision history for Perl extension Test-Compile
 
+v1.1.0    2014-07-18              (Evan Giles <egiles@cpan.org>)
+    - Allow use of Test::Compile in an object oriented manner
+    - Promote the OO interface in the POD
+    - Test::Compile::Internal is now verbose by default
+    - Correct the dependancy information
+
+v1.0.1    2014-03-20              (Evan Giles <egiles@cpan.org>)
+    - Fix stupid omission from the MANAIFEST (tests failed everywhere)
+
+v1.0.0    2014-03-19              (Evan Giles <egiles@cpan.org>)
+    - Try to use Sematic Versioning - http://semver.org
+    - Add diagnostics on compilation failure        (Micheal G. Schwern)
+    - require, don't use                            (Micheal G. Schwern)
+    - Test for truth, not an integer.               (Micheal G. Schwern)
+    - Small POD fix                                 (Micheal G. Schwern)
+    - OS X is not a crazy OS from a redirection POV (Micheal G. Schwern)
+
 0.24  2013 02 22                  (Evan Giles <egiles@cpan.org>)
     - Update POD to explain more problems with Test::Compile
 
@@ -7,27 +7,27 @@ Build.PL
 MANIFEST			This list of files
 META.yml
 README
+t/000-compile.t
 t/100-internal-all-pl-files.t
 t/100-internal-all-pm-files.t
 t/100-internal-basic.t
 t/100-internal-is-in-taint-mode.t
+t/100-internal-mess-with-lib.t
 t/100-internal-pl-file-compiles.t
 t/100-internal-pm-file-compiles.t
 t/100-internal-verbose.t
-t/200-basic.t
-t/200-lib.t
 t/200-pl-file-ok.t
 t/200-pl-file-ok-vms.t
 t/200-taint.t
 t/scripts/CVS/Ignore.pm
 t/scripts/CVS/taint2.pl
-t/scripts/Module.pm
-t/scripts/Module2.pm
 t/scripts/failure.pl
+t/scripts/LethalImport.pm
 t/scripts/lib.pl
+t/scripts/Module2.pm
+t/scripts/Module.pm
 t/scripts/subdir/success.pl
 t/scripts/taint.pl
-xt/author/00-compile.t
 xt/author/01_perl_critic.t
 xt/author/02_pod.t
 xt/author/04_pod_coverage.t
@@ -25,18 +25,19 @@
          },
          "requires" : {
             "UNIVERSAL::require" : "0",
-            "perl" : "v5.6.0"
+            "perl" : "v5.6.2",
+            "version" : "0"
          }
       }
    },
    "provides" : {
       "Test::Compile" : {
          "file" : "lib/Test/Compile.pm",
-         "version" : "0.24"
+         "version" : "v1.1.0"
       },
       "Test::Compile::Internal" : {
          "file" : "lib/Test/Compile/Internal.pm",
-         "version" : "0.24"
+         "version" : "v1.1.0"
       }
    },
    "release_status" : "stable",
@@ -48,5 +49,5 @@
          "url" : "http://github.com/egiles/test-compile"
       }
    },
-   "version" : "0.24"
+   "version" : "v1.1.0"
 }
@@ -15,16 +15,17 @@ name: Test-Compile
 provides:
   Test::Compile:
     file: lib/Test/Compile.pm
-    version: 0.24
+    version: v1.1.0
   Test::Compile::Internal:
     file: lib/Test/Compile/Internal.pm
-    version: 0.24
+    version: v1.1.0
 recommends:
   Devel::CheckOS: 0
 requires:
   UNIVERSAL::require: 0
-  perl: v5.6.0
+  perl: v5.6.2
+  version: 0
 resources:
   license: http://dev.perl.org/licenses/
   repository: http://github.com/egiles/test-compile
-version: 0.24
+version: v1.1.0
@@ -1,12 +1,13 @@
 # Note: this file was auto-generated by Module::Build::Compat version 0.3800
-require 5.006000;
+require 5.006002;
 use ExtUtils::MakeMaker;
 WriteMakefile
 (
   'NAME' => 'Test::Compile',
   'VERSION_FROM' => 'lib/Test/Compile.pm',
   'PREREQ_PM' => {
-                   'UNIVERSAL::require' => 0
+                   'UNIVERSAL::require' => 0,
+                   'version' => 0
                  },
   'INSTALLDIRS' => 'site',
   'EXE_FILES' => [],
@@ -1,12 +1,13 @@
 DESCRIPTION
-    Test::Compile is a Perl module that lets you check whether a Perl module
-    or script compiles properly, and report its results in standard
-    Test::Simple fashion. It can test all Perl modules in a distribution, as
-    well as single module or script files. 
+    Test::Compile is a Perl module that lets you check whether Perl modules
+    or scripts compile properly, and report its results in standard
+    Test::Simple fashion. It can test all Perl files in a distribution, or
+    individual files.
 
 DEPENDANCIES
-    Requires perl v5.6.0, and
+    Requires perl v5.6.2, plus
     * UNIVERSAL::require
+    * version
 
 INSTALLATION
     Standard process for building & installing modules:
@@ -17,7 +18,7 @@ INSTALLATION
       ./Build install
 
 COPYRIGHT AND LICENSE
-    Copyright 2007-2013.
+    Copyright 2007-2014.
 
     This library is free software; you can redistribute it and/or modify it
     under the same terms as Perl itself.
@@ -1,14 +1,13 @@
 package Test::Compile::Internal;
 
-use 5.006;
+use 5.6.2;
 use warnings;
 use strict;
 
 use File::Spec;
 use UNIVERSAL::require;
 use Test::Builder;
-
-our $VERSION = '0.24';
+use version; our $VERSION = qv("v1.1.0");
 
 =head1 NAME
 
@@ -79,7 +78,7 @@ sub all_files_ok {
 An accessor to get/set the verbose flag.  If C<verbose> is set, you can get some 
 extra diagnostics when compilation fails.
 
-Verbose is set off by default.
+Verbose is set on by default.
 =cut
 
 sub verbose {
@@ -89,7 +88,7 @@ sub verbose {
         $self->{verbose} = $verbose;
     }
 
-    return $self->{verbose};
+    return defined($self->{verbose}) ? $self->{verbose} : 1;
 }
 
 =item C<all_pm_files(@dirs)>
@@ -172,10 +171,11 @@ sub pl_file_compiles {
 Returns true if C<$file> compiles as a perl module.
 
 =back
+
 =cut
 
 sub pm_file_compiles {
-    my ($self,$file) = @_;
+    my ($self,$file,%args) = @_;
 
     return $self->_run_closure(
         sub{
@@ -185,8 +185,15 @@ sub pm_file_compiles {
                 $module =~ s![/\\]!::!g;
                 $module =~ s/\.pm$//;
     
-                $module->use;
-                return ($@ ? 0 : 1);
+                return 1 if $module->require;
+
+                $self->{test}->diag("Compilation of $module failed: $@")
+                  if $self->verbose();
+                return 0;
+            }
+            else {
+                $self->{test}->diag("$file could not be found") if $self->verbose();
+                return 0;
             }
         }
     );
@@ -259,9 +266,9 @@ sub diag {
     $self->{test}->diag(@args);
 }
 
-=item C<skip($why)>
+=item C<skip($reason)>
 
-Skips the current test, reporting C<$why>.
+Skips the current test, reporting the C<$reason>.
 
 =cut
 
@@ -358,7 +365,7 @@ Evan Giles, C<< <egiles@cpan.org> >>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2007-2013 by the authors.
+Copyright 2007-2014 by the authors.
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.
@@ -1,15 +1,14 @@
 package Test::Compile;
 
-use 5.006;
+use 5.6.2;
 use warnings;
 use strict;
 
 use UNIVERSAL::require;
 use Test::Compile::Internal;
+use version; our $VERSION = qv("v1.1.0");
 
-our $VERSION = '0.24';
 my $Test = Test::Compile::Internal->new();
-_verbose(1);
 
 =head1 NAME
 
@@ -17,6 +16,13 @@ Test::Compile - Check whether Perl files compile correctly.
 
 =head1 SYNOPSIS
 
+    # The OO way (recommended)
+    use Test::Compile;
+    my $test = Test::Compile->new();
+    $test->all_files_ok();
+    $test->done_testing();
+
+    # The procedural way
     use Test::Compile;
     all_pm_files_ok();
 
@@ -25,14 +31,20 @@ Test::Compile - Check whether Perl files compile correctly.
 C<Test::Compile> lets you check the whether your perl modules and scripts
 compile properly, and report its results in standard C<Test::Simple> fashion.
 
-The basic usage - as shown above, will find all pm files and test that they
+The basic usage - as shown above, will locate your perl files and test that they
 all compile.
 
-You can explicitly specify the list of directories to check, using
-the C<all_pm_files()> function supplied:
+Module authors can (and probably should) include the following in a F<t/00-compile.t>
+file and have C<Test::Compile> automatically find and check all Perl files
+in a module distribution:
 
-    my @pmdirs = qw(blib script);
-    all_pm_files_ok(all_pm_files(@pmdirs));
+    #!perl
+    use strict;
+    use warnings;
+    use Test::Compile;
+    my $test = Test::Compile->new();
+    $test->all_files_ok();
+    $test->done_testing();
 
 =cut
 
@@ -52,6 +64,115 @@ sub import {
     $Test->plan(@_);
 }
 
+=head1 METHODS
+
+=over 4
+
+=item C<new()>
+
+A basic constructor, nothing special except that it returns a
+L<Test::Compile::Internal> object.
+
+=cut
+
+sub new {
+    my $class = shift;
+    return Test::Compile::Internal->new(@_);
+}
+
+=item C<all_files_ok(@dirs)>
+
+Checks all the perl files it can find for compilation errors.
+
+If C<@dirs> is defined then it is taken as an array of directories to
+be searched for perl files, otherwise it searches some default locatioons
+- see L</all_pm_files()> and L</all_pl_files()>.
+
+=item C<all_pm_files(@dirs)>
+
+Returns a list of all the perl module files - that is any files ending in F<.pm>
+in C<@dirs> and in directories below. If C<@dirs> is undefined, it
+searches F<blib> if F<blib> exists, or else F<lib>.
+
+Skips any files in C<CVS> or C<.svn> directories.
+
+The order of the files returned is machine-dependent. If you want them
+sorted, you'll have to sort them yourself.
+
+=item C<all_pl_files(@dirs)>
+
+Returns a list of all the perl script files - that is, any files ending in F<.pl>
+or files with no extension in C<@dirs> and in directories below. If
+C<@dirs> is undefined, it searches F<script> if F<script> exists, or else
+F<bin> if F<bin> exists.
+
+Skips any files in C<CVS> or C<.svn> directories.
+
+The order of the files returned is machine-dependent. If you want them
+sorted, you'll have to sort them yourself.
+
+=item C<pl_file_compiles($file)>
+
+Returns true if C<$file> compiles as a perl script.
+
+=item C<pm_file_compiles($file)>
+
+Returns true if C<$file> compiles as a perl module.
+
+=item C<verbose($verbose)>
+
+An accessor to get/set the verbose flag.  If C<verbose> is set, you can get some
+extra diagnostics when compilation fails.
+
+Verbose is set on by default.
+
+=back
+
+=head2 TEST METHODS
+
+C<Test::Compile::Internal> encapsulates a C<Test::Builder> object, and provides
+access to some of its methods.
+
+=over 4
+
+=item C<done_testing()>
+
+Declares that you are done testing, no more tests will be run after this point.
+
+=item C<ok($test,$name)>
+
+Your basic test. Pass if C<$test> is true, fail if C<$test> is false. Just
+like C<Test::Simple>'s C<ok()>.
+
+=item C<plan($count)>
+
+Defines how many tests you plan to run.
+
+=item C<exported_to($caller)>
+
+Tells C<Test::Builder> what package you exported your functions to.  I am
+not sure why you would want to do that, or whether it would do you any good.
+
+=item C<diag(@msgs)>
+
+Prints out the given C<@msgs>. Like print, arguments are simply appended
+together.
+
+Output will be indented and marked with a # so as not to interfere with
+test output. A newline will be put on the end if there isn't one already.
+
+We encourage using this rather than calling print directly.
+
+=item C<skip($reason)>
+
+Skips the current test, reporting the C<$reason>.
+
+=item C<skip_all($reason)>
+
+Skips all the tests, using the given C<$reason>. Exits immediately with 0.
+
+=back
+
 =head1 FUNCTIONS
 
 =over 4
@@ -63,9 +184,9 @@ Checks all the perl module files it can find for compilation errors.
 It uses C<all_pm_files(@files)> to find the perl module files.
 
 It also calls the C<plan()> function for you (one test for each module), so
-you can't have already called C<plan>. Unfortunately, this also means 
+you can't have already called C<plan>. Unfortunately, this also means
 you can't use this function with C<all_pl_files_ok()>.  If this is a problem
-you should really be using L<Test::Compile::Internal>.
+you should really be using the object oriented interface.
 
 Returns true if all Perl module files are ok, or false if any fail.
 
@@ -101,9 +222,9 @@ Checks all the perl script files it can find for compilation errors.
 It uses C<all_pl_files(@files)> to find the perl script files.
 
 It also calls the C<plan()> function for you (one test for each script), so
-you can't have already called C<plan>. Unfortunately, this also means 
+you can't have already called C<plan>. Unfortunately, this also means
 you can't use this function with C<all_pm_files_ok()>.  If this is a problem
-you should really be using L<Test::Compile::Internal>.
+you should really be using the object oriented interface.
 
 Returns true if all Perl script files are ok, or false if any fail.
 
@@ -239,15 +360,15 @@ Evan Giles, C<< <egiles@cpan.org> >>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2007-2013 by the authors.
+Copyright 2007-2014 by the authors.
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.
 
 =head1 SEE ALSO
 
-L<Test::Compile::Internal> provides an object oriented interface to the
-Test::Compile functionality.
+L<Test::Compile::Internal> provides the object oriented interface to (and the
+inner workings for) the Test::Compile functionality.
 
 L<Test::Strict> proveds functions to ensure your perl files comnpile, with
 added bonus that it will check you have used strict in all your files.
@@ -0,0 +1,9 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::Compile;
+my $test = Test::Compile->new();
+$test->all_files_ok();
+$test->done_testing();
@@ -11,13 +11,14 @@ my $internal = Test::Compile::Internal->new();
 my @files;
 
 @files = sort $internal->all_pm_files();
-is(scalar @files,2,'Found correct number of modules in default location');
+is(@files,2,'Found correct number of modules in default location');
 like($files[0],qr/lib.Test.Compile.pm/,'Found module: Compile.pm');
 like($files[1],qr/lib.Test.Compile.Internal.pm/,'Found module: Internal.pm');
 
 @files = sort $internal->all_pm_files('t/scripts');
-is(scalar @files,2,'Found correct number of modules in t/scripts');
-like($files[0],qr/t.scripts.Module.pm/,'Found module: Module.pm');
-like($files[1],qr/t.scripts.Module2.pm/,'Found module: Module2.pm');
+is(@files,3,'Found correct number of modules in t/scripts');
+like($files[0],qr/t.scripts.LethalImport.pm/,'Found module: Module2.pm');
+like($files[1],qr/t.scripts.Module.pm/,'Found module: Module.pm');
+like($files[2],qr/t.scripts.Module2.pm/,'Found module: Module2.pm');
 
 $internal->done_testing();
@@ -0,0 +1,21 @@
+#!perl -w
+
+use strict;
+use warnings;
+
+use Test::Compile::Internal;
+use Test::More ;
+
+plan skip_all => "Distribution hasn't been built yet" unless -d "blib/lib";
+
+my $test = Test::Compile::Internal->new();
+$test->verbose(0);
+
+# lib.pl has a dodgy begin block which messes with @INC.
+# - that should force it to *only* look in blib/lib for
+#   modules.. but it should still compile. See rt72557
+#   for more details.
+my $compiles = $test->pl_file_compiles('t/scripts/lib.pl');
+ok($compiles, "lib.pl compiles");
+
+done_testing();
@@ -7,6 +7,7 @@ use Test::More;
 use Test::Compile::Internal;
 
 my $internal = Test::Compile::Internal->new();
+$internal->verbose(0);
 
 my $yes = $internal->pl_file_compiles('t/scripts/subdir/success.pl');
 is($yes,1,"success.pl should compile");
@@ -7,15 +7,20 @@ use Test::More;
 use Test::Compile::Internal;
 
 my $internal = Test::Compile::Internal->new();
+$internal->verbose(0);
 
 my $yes = $internal->pm_file_compiles('t/scripts/Module.pm');
-is($yes,1,"Module.pm should compile");
+ok($yes, "Module.pm should compile");
 
 my $no = $internal->pm_file_compiles('t/scripts/CVS/Ignore.pm');
-is($no,0,"Ignore.pm should not compile");
+ok(!$no, "Ignore.pm should not compile");
 
 my $notfound = $internal->pm_file_compiles('t/scripts/NotFound.pm');
-is($notfound,0,"NotFound.pm should not compile");
+ok(!$notfound, "NotFound.pm should not compile");
 
+note "Does not call import"; {
+    my $result = $internal->pm_file_compiles('t/scripts/LethalImport.pm');
+    ok $result, "Does not call import() routines";
+}
 
 done_testing();
@@ -8,7 +8,7 @@ use Test::More;
 use Test::Compile::Internal;
 
 plan skip_all => "I don't know how to redirect STDERR on your crazy OS"
-    unless $^O =~ m/linux|.*bsd|solaris/;
+    unless $^O =~ m/linux|.*bsd|solaris|darwin/;
 
 
 sub makeAnError {
@@ -1,10 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use Test::More;
-
-require_ok('Test::Compile');
-
-done_testing();
@@ -1,17 +0,0 @@
-#!perl -w
-
-use strict;
-use warnings;
-
-use Test::Compile;
-
-use Test::More ;
-plan skip_all => "Distribution hasn't been built yet" unless -d "blib/lib";
-
-# lib.pl has a dodgy begin block which messes with @INC.
-# - that should force it to *only* look in blib/lib for
-#   modules.. but it should still compile. See rt72557
-#   for more details.
-pl_file_ok('t/scripts/lib.pl', 'lib.pl compiles');
-
-done_testing();
@@ -0,0 +1,5 @@
+package t::scripts::LethalImport;
+
+sub import { die "All die"; }
+
+1;
@@ -6,6 +6,7 @@ BEGIN {
     require Test::Builder;
     require File::Spec;
     require UNIVERSAL::require;
+    require version;
     @INC = grep { $_ eq 'blib/lib' } @INC;
 }
 use Test::Compile;
@@ -1,10 +0,0 @@
-#! /usr/bin/perl
-
-use strict;
-use warnings;
-
-use Test::Compile::Internal;
-
-my $internal = Test::Compile::Internal->new();
-$internal->all_files_ok();
-$internal->done_testing();