3 ##############################################################################
4 # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/t/generate_without_optional_dependencies_wrappers.PL $
5 # $Date: 2008-07-03 10:19:10 -0500 (Thu, 03 Jul 2008) $
8 ##############################################################################
16 use English qw{-no_match_vars};
18 use Carp qw{ confess };
19 use Fatal qw{ open close };
21 use Perl::Critic::BuildUtilities qw{ recommended_module_versions };
23 our $VERSION = '1.088';
25 Readonly::Scalar my $GENERATED_DIRECTORY => 'xt/author/generated/';
27 if ( not -d $GENERATED_DIRECTORY ) {
29 "\n\nSkipping generating tests because it doesn't ",
30 "look like we're in an author environment.\n\n";
34 print "\n\nGenerating tests that hide modules and then run other tests.\n";
36 my $this_program = __FILE__;
38 my @modules_to_hide = sort keys %{ { recommended_module_versions } };
39 my $modules_to_hide = join "\n" . q< > x 4, @modules_to_hide;
41 foreach my $test_program_name (@ARGV) {
42 my ($wrapped_test_name) =
43 $test_program_name =~ m<
46 ( (?: t | xt/author ) / [\w.]+ \.t ) # test to be wrapped
47 _without_optional_dependencies\.t # suffix the new test will have
50 if (not $wrapped_test_name) {
52 'Could not figure out the name of the test to wrap from "'
57 print "Generating $test_program_name.\n";
58 open my $test_program, '>', $test_program_name
59 or die "Could not open $test_program_name: $ERRNO";
61 print {$test_program} <<"END_TEST_PROGRAM";
64 # Do not edit!!! This program generated by $this_program.
69 use English qw{-no_match_vars};
73 use Perl::Critic::TestUtilitiesWithMinimalDependencies qw{
74 get_skip_all_tests_tap
77 our \$VERSION = $VERSION;
79 #-----------------------------------------------------------------------------
81 eval <<'END_HIDE_MODULES';
82 use Test::Without::Module qw{
89 get_skip_all_tests_tap(),
90 'Test::Without::Module required to test with the ',
91 "absence of optional modules\\n";
96 require '$wrapped_test_name';
106 #-----------------------------------------------------------------------------
114 generate_without_additional_dependencies_wrappers.PL - generate tests that are wrappers around other tests but which hide the existence of modules first.
119 generate_without_additional_dependencies_wrappers.PL \
120 t/00_modules.t_without_optional_dependencies.t \
121 t/01_config.t_without_optional_dependencies.t \
122 t/13_bundled_policies.t_without_optional_dependencies.t
127 Release 1.07 of Perl::Critic was an embarrassment because there were no tests
128 of core without the presence of optional modules. This program generates
129 wrappers for other tests that hide those optional modules.
134 Elliot Shank C<< <perl@galumph.org> >>
139 Copyright (c) 2007-2008 Elliot Shank. All rights reserved.
141 This program is free software; you can redistribute it and/or modify it under
142 the same terms as Perl itself. The full text of this license can be found in
143 the LICENSE file included with this module.
148 ##############################################################################
151 # cperl-indent-level: 4
153 # indent-tabs-mode: nil
154 # c-indentation-style: bsd
156 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :