Login
Let's see how this one goes over.
authorElliot Shank <perl@galumph.com>
Sun, 20 Apr 2008 00:36:58 +0000 (00:36 +0000)
committerElliot Shank <perl@galumph.com>
Sun, 20 Apr 2008 00:36:58 +0000 (00:36 +0000)
Following the Oslo QA hackathon where it was "officially"
decided to support the xt directory, dump the use of the
environment variable for author tests in favor of the
xt/author directory and a testauthor target in Build.PL.

13 files changed:
.gitignore
Build.PL
MANIFEST.SKIP
Makefile.PL
inc/Perl/Critic/BuildUtilities.pm
t/generate_without_optional_dependencies_wrappers.PL
t/tlib/Perl/Critic/TestUtilitiesWithMinimalDependencies.pm
xt/author/40_criticize.t [moved from t/40_criticize.t with 88% similarity]
xt/author/40_perlcriticrc [moved from t/40_perlcriticrc with 100% similarity]
xt/author/80_policysummary.t [moved from t/80_policysummary.t with 92% similarity]
xt/author/93_version.t [moved from t/93_version.t with 85% similarity]
xt/author/94_includes.t [moved from t/94_includes.t with 91% similarity]
xt/author/95_kwalitee.t [moved from t/95_kwalitee.t with 64% similarity]

index dc42571..e4d3eca 100644 (file)
@@ -2,3 +2,5 @@ cover_db
 t/*_without_optional_dependencies.t
 t/ControlStructures/ProhibitNegativeExpressionsInUnlessAndUntilConditions.run
 t/Variables/RequireLocalizedPunctuationVars.run
+xt/author/generated/t/*_without_optional_dependencies.t
+xt/author/generated/xt/author/*_without_optional_dependencies.t
index a392979..3688e54 100644 (file)
--- a/Build.PL
+++ b/Build.PL
@@ -6,7 +6,7 @@
 ########################################################################
 
 BEGIN {
-    require 5.006001;
+    use 5.006001;
 }
 
 use strict;
@@ -25,46 +25,37 @@ use Perl::Critic::BuildUtilities qw<
     emit_tar_warning_if_necessary
 >;
 
-my $warning = <<'END_WARNING';
-
-###################################################
-# NOTICE! NOTICE! NOTICE! NOTICE! NOTICE! NOTICE! #
-#-------------------------------------------------#
-# In this version of Perl::Critic, some of        #
-# the Policy modules have been renamed to better  #
-# better reflect the intent of the Policy.  If    #
-# you have an older version of Perl::Critic       #
-# already installed, it will cause many of the    #
-# tests to fail and the new version will not work #
-# properly.                                       #
-#                                                 #
-# I strongly advise you to remove the current     #
-# version of Perl::Critic before proceeding with  #
-# this installation.  In most cases, this can be  #
-# done by deleting everything below the           #
-# Perl/Critic/Policy directory in your site_perl  #
-# location.                                       #
-#                                                 #
-# Also, if you have created a .perlcriticrc file, #
-# you will need to update it to match the new     #
-# Policy module names.                            #
-#                                                 #
-# Sorry for the inconvenience.                    #
-#                                                 #
-# -Jeff <thaljef@cpan.org>                        #
-###################################################
-
-END_WARNING
-
-
-eval {
-    require Perl::Critic;
-    warn $warning if $Perl::Critic::VERSION < 0.14;
-};
-
 emit_tar_warning_if_necessary();
 
-my $builder = Module::Build->new(
+
+my $class = Module::Build->subclass( code => <<'END_SUBCLASS' );
+
+    sub ACTION_authortest {
+        my ($self) = @_;
+
+        $self->depends_on('build');
+        $self->depends_on('manifest');
+        $self->depends_on('distmeta');
+
+        $self->test_files( qw< t xt/author > );
+        $self->recursive_test_files(1);
+
+        $self->depends_on('test');
+
+        return;
+    } # end ACTION_authortest()
+
+    sub ACTION_distdir {
+        my ($self) = @_;
+
+        $self->depends_on('authortest');
+
+        return $self->SUPER::ACTION_distdir;
+    } # end ACTION_distdir
+
+END_SUBCLASS
+
+my $builder = $class->new(
     module_name    => 'Perl::Critic',
     dist_author    => 'Jeffrey Thalhammer <thaljef@cpan.org>',
     dist_abstract  => 'Critique Perl source code for best-practices.',
index e998888..ca54f5d 100644 (file)
@@ -1,6 +1,6 @@
 ^README\.developer$
 \.PPI$
-^t/.*_without_optional_dependencies.t$
+_without_optional_dependencies.t$
 ^t/ControlStructures/ProhibitNegativeExpressionsInUnlessAndUntilConditions.run$
 ^t/Variables/RequireLocalizedPunctuationVars.run$
 
index 0d6162f..e9b86f0 100644 (file)
@@ -24,43 +24,6 @@ use Perl::Critic::BuildUtilities qw<
     emit_tar_warning_if_necessary
 >;
 
-my $warning = <<'END_WARNING';
-
-###################################################
-# NOTICE! NOTICE! NOTICE! NOTICE! NOTICE! NOTICE! #
-#-------------------------------------------------#
-# In this version of Perl::Critic, some of        #
-# the Policy modules have been renamed to better  #
-# better reflect the intent of the Policy.  If    #
-# you have an older version of Perl::Critic       #
-# already installed, it will cause many of the    #
-# tests to fail and the new version will not work #
-# properly.                                       #
-#                                                 #
-# I strongly advise you to remove the current     #
-# version of Perl::Critic before proceeding with  #
-# this installation.  In most cases, this can be  #
-# done by deleting everything below the           #
-# Perl/Critic/Policy directory in your site_perl  #
-# location.                                       #
-#                                                 #
-# Also, if you have created a .perlcriticrc file, #
-# you will need to update it to match the new     #
-# Policy module names.                            #
-#                                                 #
-# Sorry for the inconvenience.                    #
-#                                                 #
-# -Jeff <thaljef@cpan.org>                        #
-###################################################
-
-END_WARNING
-
-
-eval {
-    require Perl::Critic;
-    warn $warning if $Perl::Critic::VERSION < 0.14;
-};
-
 
 emit_tar_warning_if_necessary();
 
index a7ace59..24e3133 100644 (file)
@@ -29,10 +29,6 @@ use lib 't/tlib';
 
 use Devel::CheckOS qw< os_is >;
 
-use Perl::Critic::TestUtilitiesWithMinimalDependencies qw<
-    should_skip_author_tests
->;
-
 
 sub recommended_module_versions {
     return (
@@ -60,6 +56,7 @@ sub test_wrappers_to_generate {
         t/04_defaults.t
         t/05_utils.t
         t/05_utils_ppi.t
+        t/05_utils_pod.t
         t/06_violation.t
         t/07_perlcritic.t
         t/08_document.t
@@ -73,14 +70,14 @@ sub test_wrappers_to_generate {
         t/15_statistics.t
         t/20_policy_podspelling.t
         t/20_policy_requiretidycode.t
-        t/80_policysummary.t
+        xt/author/80_policysummary.t
         t/92_memory_leaks.t
-        t/94_includes.t
+        xt/author/94_includes.t
     >;
 
     return
         map
-            { $_ . '_without_optional_dependencies.t' }
+            { "xt/author/generated/${_}_without_optional_dependencies.t" }
             @tests_to_be_wrapped;
 }
 
@@ -92,16 +89,8 @@ sub get_PL_files {
     $PL_files{'t/Variables/RequireLocalizedPunctuationVars.run.PL'} =
         't/Variables/RequireLocalizedPunctuationVars.run';
 
-    if (should_skip_author_tests()) {
-        print
-              "\nWill not generate extra author tests.  Set "
-            . '$ENV{TEST_AUTHOR_PERL_CRITIC} to a true value to have them generated.'
-            . "\n\n";
-    }
-    else {
-        $PL_files{'t/generate_without_optional_dependencies_wrappers.PL'} =
-            [ test_wrappers_to_generate() ];
-    }
+    $PL_files{'t/generate_without_optional_dependencies_wrappers.PL'} =
+        [ test_wrappers_to_generate() ];
 
     return \%PL_files;
 }
index 7beb9c4..eb8b6f2 100644 (file)
@@ -30,12 +30,13 @@ my $modules_to_hide = join "\n" . q< > x 4, @modules_to_hide;
 
 foreach my $test_program_name (@ARGV) {
     my ($wrapped_test_name) =
-        $test_program_name =~ m{
+        $test_program_name =~ m<
             \A
-            ( t/ [\w.]+ \.t )                  # test to be wrapped
-            _without_optional_dependencies\.t  # suffix the new test will have
+            xt/author/generated/
+            ( (?: t | xt/author ) / [\w.]+ \.t ) # test to be wrapped
+            _without_optional_dependencies\.t   # suffix the new test will have
             \z
-        }xms;
+        >xms;
     if (not $wrapped_test_name) {
         confess
               'Could not figure out the name of the test to wrap from "'
@@ -54,26 +55,18 @@ foreach my $test_program_name (@ARGV) {
 
 use strict;
 use warnings;
-use English qw{-no_match_vars};
 
-our \$VERSION = $VERSION;
+use English qw{-no_match_vars};
 
 use lib 't/tlib';
 
-use English qw(-no_match_vars);
-
 use Perl::Critic::TestUtilitiesWithMinimalDependencies qw{
-    should_skip_author_tests
-    get_author_test_skip_message
     get_skip_all_tests_tap
 };
 
-#-----------------------------------------------------------------------------
+our \$VERSION = $VERSION;
 
-if ( should_skip_author_tests() ) {
-    print get_skip_all_tests_tap(), get_author_test_skip_message(), "\\n";
-    exit 0;
-}
+#-----------------------------------------------------------------------------
 
 eval <<'END_HIDE_MODULES';
 use Test::Without::Module qw{
index 3335e5f..bc23304 100644 (file)
@@ -16,29 +16,11 @@ use base 'Exporter';
 
 our $VERSION = '1.083_001';
 our @EXPORT_OK = qw(
-    should_skip_author_tests
-    get_author_test_skip_message
     get_skip_all_tests_tap
 );
 
 #-----------------------------------------------------------------------------
 
-# Note: this code is duplicated in lib/Perl/Critic/TestUtils.pm.
-# If you change this here, make sure to change it there.
-
-sub should_skip_author_tests {
-    return not $ENV{TEST_AUTHOR_PERL_CRITIC};
-}
-
-#-----------------------------------------------------------------------------
-
-sub get_author_test_skip_message {
-    ## no critic (RequireInterpolation);
-    return 'Author test.  Set $ENV{TEST_AUTHOR_PERL_CRITIC} to a true value to run.';
-}
-
-#-----------------------------------------------------------------------------
-
 sub get_skip_all_tests_tap {
     return '1..0 # Skip ';
 }
@@ -60,21 +42,13 @@ Perl::Critic::TestUtilitiesWithMinimalDependencies - Testing functions that only
 =head1 SYNOPSIS
 
   use Perl::Critic::TestUtilitiesWithMinimalDependencies qw{
-      should_skip_author_tests
-      get_author_test_skip_message
       get_skip_all_tests_tap
   };
 
-  if ( should_skip_author_tests() ) {
-      print get_skip_all_tests_tap(), get_author_test_skip_message(), "\n";
-      exit 0;
-  }
-
-
   use Test::More;
 
-  if (should_skip_author_tests()) {
-      plan skip_all => get_author_test_skip_message();
+  if ($should_not_run) {
+      plan skip_all => 'Hey!  I shouldn't be run!';
   }
 
 =head1 DESCRIPTION
@@ -88,18 +62,6 @@ that need to hide the presence of other modules before starting.
 
 =over
 
-=item C< should_skip_author_tests() >
-
-Answers whether author tests should run.
-
-
-=item C< get_author_test_skip_message() >
-
-Returns a string containing the message that should be emitted when a
-test is skipped due to it being an author test when author tests are
-not enabled.
-
-
 =item C< get_skip_all_tests_tap() >
 
 Returns a string representing the TAP (Test Anything Protocol) output
@@ -107,6 +69,9 @@ for skipping an entire file.  This is useful if you don't want to load
 any Test::* modules.
 
 
+=back
+
+
 =head1 AUTHOR
 
 Elliot Shank <perl@cpan.org>
similarity index 88%
rename from t/40_criticize.t
rename to xt/author/40_criticize.t
index e129ee7..2f89c2b 100644 (file)
 use strict;
 use warnings;
 
-use lib 't/tlib';
-
 use English qw( -no_match_vars );
 
 use File::Spec qw();
 use Test::More;
 
 use Perl::Critic::Utils qw{ :characters };
-use Perl::Critic::TestUtilitiesWithMinimalDependencies qw{
-    should_skip_author_tests
-    get_author_test_skip_message
-};
 use Perl::Critic::TestUtils qw{ starting_points_including_examples };
 
 # Note: "use PolicyFactory" *must* appear after "use TestUtils" for the
@@ -35,12 +29,6 @@ use Perl::Critic::PolicyFactory (
 
 #-----------------------------------------------------------------------------
 
-if (should_skip_author_tests()) {
-    plan skip_all => get_author_test_skip_message();
-}
-
-#-----------------------------------------------------------------------------
-
 eval { require Test::Perl::Critic; };
 plan skip_all => 'Test::Perl::Critic required to criticise code' if $EVAL_ERROR;
 
@@ -87,7 +75,7 @@ else {
 #-----------------------------------------------------------------------------
 # Run critic against all of our own files
 
-my $rcfile = File::Spec->catfile( 't', '40_perlcriticrc' );
+my $rcfile = File::Spec->catfile( 'xt', 'author', '40_perlcriticrc' );
 Test::Perl::Critic->import( -profile => $rcfile );
 
 all_critic_ok( starting_points_including_examples() );
similarity index 100%
rename from t/40_perlcriticrc
rename to xt/author/40_perlcriticrc
similarity index 92%
rename from t/80_policysummary.t
rename to xt/author/80_policysummary.t
index ea03976..1b26522 100644 (file)
 use strict;
 use warnings;
 
-use lib 't/tlib';
-
 use File::Spec;
 use Test::More;
 use List::MoreUtils qw(any);
 
 use Perl::Critic::PolicyFactory ( -test => 1 );
-use Perl::Critic::TestUtilitiesWithMinimalDependencies qw{
-    should_skip_author_tests
-    get_author_test_skip_message
-};
 use Perl::Critic::TestUtils qw{ bundled_policy_names };
 
 #-----------------------------------------------------------------------------
 
-if (should_skip_author_tests()) {
-    plan skip_all => get_author_test_skip_message();
-}
-
 if (open my ($fh), '<', File::Spec->catfile(qw(lib Perl Critic PolicySummary.pod))) {
 
     my $content = do {local $/=undef; <$fh> };
similarity index 85%
rename from t/93_version.t
rename to xt/author/93_version.t
index a5a330f..496e939 100644 (file)
@@ -2,20 +2,9 @@
 use warnings;
 use strict;
 
-use lib 't/tlib';
-
 use File::Find;
 use Test::More;
 
-use Perl::Critic::TestUtilitiesWithMinimalDependencies qw{
-    should_skip_author_tests
-    get_author_test_skip_message
-};
-
-if (should_skip_author_tests()) {
-    plan skip_all => get_author_test_skip_message();
-}
-
 plan 'no_plan';
 
 my $last_version = undef;
similarity index 91%
rename from t/94_includes.t
rename to xt/author/94_includes.t
index 19c0648..3d8ffc3 100644 (file)
@@ -3,22 +3,11 @@
 use warnings;
 use strict;
 
-use lib 't/tlib';
-
 use Test::More;
 
 use File::Find;
 use PPI::Document;
 
-use Perl::Critic::TestUtilitiesWithMinimalDependencies qw{
-    should_skip_author_tests
-    get_author_test_skip_message
-};
-
-if (should_skip_author_tests()) {
-    plan skip_all => get_author_test_skip_message();
-}
-
 my %implied = (
     # Universal
     SUPER => 1,
similarity index 64%
rename from t/95_kwalitee.t
rename to xt/author/95_kwalitee.t
index 41c3300..7bfc08a 100644 (file)
@@ -3,21 +3,9 @@
 use strict;
 use warnings;
 
-use lib 't/tlib';
-
 use Test::More;
 
-use Perl::Critic::TestUtilitiesWithMinimalDependencies qw{
-    should_skip_author_tests
-    get_author_test_skip_message
-};
-
-if (should_skip_author_tests()) {
-    plan skip_all => get_author_test_skip_message();
-}
-
-eval
-{
+eval {
    require Test::Kwalitee;
    Test::Kwalitee->import( tests => [ qw{ -no_pod_errors -no_symlinks } ] );
 };