Modified source files and compiled any and armel versions of packages
[pkg-perl] / deb-src / libperl-critic-perl / libperl-critic-perl-1.088 / t / generate_without_optional_dependencies_wrappers.PL
1 #!/usr/bin/env perl
2
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) $
6 #   $Author: clonezone $
7 # $Revision: 2489 $
8 ##############################################################################
9
10 use 5.006001;
11 use strict;
12 use warnings;
13
14 use lib 'inc';
15
16 use English qw{-no_match_vars};
17 use Readonly;
18 use Carp qw{ confess };
19 use Fatal qw{ open close };
20
21 use Perl::Critic::BuildUtilities qw{ recommended_module_versions };
22
23 our $VERSION = '1.088';
24
25 Readonly::Scalar my $GENERATED_DIRECTORY => 'xt/author/generated/';
26
27 if ( not -d $GENERATED_DIRECTORY ) {
28     print
29         "\n\nSkipping generating tests because it doesn't ",
30         "look like we're in an author environment.\n\n";
31     exit 0;
32 }
33
34 print "\n\nGenerating tests that hide modules and then run other tests.\n";
35
36 my $this_program = __FILE__;
37
38 my @modules_to_hide = sort keys %{ { recommended_module_versions } };
39 my $modules_to_hide = join "\n" . q< > x 4, @modules_to_hide;
40
41 foreach my $test_program_name (@ARGV) {
42     my ($wrapped_test_name) =
43         $test_program_name =~ m<
44             \A
45             $GENERATED_DIRECTORY
46             ( (?: t | xt/author ) / [\w.]+ \.t ) # test to be wrapped
47             _without_optional_dependencies\.t   # suffix the new test will have
48             \z
49         >xmso;
50     if (not $wrapped_test_name) {
51         confess
52               'Could not figure out the name of the test to wrap from "'
53             . $test_program_name
54             . q{".};
55     }
56
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";
60
61     print {$test_program} <<"END_TEST_PROGRAM";
62 #!/usr/bin/env perl
63
64 # Do not edit!!!  This program generated by $this_program.
65
66 use strict;
67 use warnings;
68
69 use English qw{-no_match_vars};
70
71 use lib 't/tlib';
72
73 use Perl::Critic::TestUtilitiesWithMinimalDependencies qw{
74     get_skip_all_tests_tap
75 };
76
77 our \$VERSION = $VERSION;
78
79 #-----------------------------------------------------------------------------
80
81 eval <<'END_HIDE_MODULES';
82 use Test::Without::Module qw{
83     $modules_to_hide
84 };
85 END_HIDE_MODULES
86
87 if ( \$EVAL_ERROR ) {
88     print
89         get_skip_all_tests_tap(),
90         'Test::Without::Module required to test with the ',
91         "absence of optional modules\\n";
92     exit 0;
93 }
94
95
96 require '$wrapped_test_name';
97 END_TEST_PROGRAM
98
99     close $test_program;
100 }
101
102 print "Done.\n\n";
103
104 __END__
105
106 #-----------------------------------------------------------------------------
107
108 =pod
109
110 =for stopwords 
111
112 =head1 NAME
113
114 generate_without_additional_dependencies_wrappers.PL - generate tests that are wrappers around other tests but which hide the existence of modules first.
115
116
117 =head1 SYNOPSIS
118
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
123
124
125 =head1 DESCRIPTION
126
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.
130
131
132 =head1 AUTHOR
133
134 Elliot Shank C<< <perl@galumph.org> >>
135
136
137 =head1 COPYRIGHT
138
139 Copyright (c) 2007-2008 Elliot Shank.  All rights reserved.
140
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.
144
145
146 =cut
147
148 ##############################################################################
149 # Local Variables:
150 #   mode: cperl
151 #   cperl-indent-level: 4
152 #   fill-column: 78
153 #   indent-tabs-mode: nil
154 #   c-indentation-style: bsd
155 # End:
156 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :