—#!/usr/bin/env perl
##############################################################################
# $Date: 2009-07-21 08:50:56 -0700 (Tue, 21 Jul 2009) $
# $Author: clonezone $
# $Revision: 3404 $
##############################################################################
use
5.006001;
use
strict;
use
warnings;
use
Readonly;
#-----------------------------------------------------------------------------
our
$VERSION
=
'1.101_001'
;
#-----------------------------------------------------------------------------
Readonly::Scalar
my
$GENERATED_DIRECTORY
=>
'xt/author/generated/'
;
if
( not -d
$GENERATED_DIRECTORY
) {
"\n\nSkipping generating tests because it doesn't "
,
"look like we're in an author environment.\n\n"
;
exit
0;
}
"\n\nGenerating tests that hide modules and then run other tests.\n"
;
my
$this_program
= __FILE__;
my
@modules_to_hide
=
sort
keys
%{ { recommended_module_versions } };
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<
\A
$GENERATED_DIRECTORY
( (?: t | xt/author ) / [\w.]+ [.] t )
# test to be wrapped
_without_optional_dependencies [.] t
# suffix the new test will have
\z
>xmso;
if
(not
$wrapped_test_name
) {
confess
'Could not figure out the name of the test to wrap from "'
.
$test_program_name
.
q{".}
;
}
"Generating $test_program_name.\n"
;
open
my
$test_program
,
'>'
,
$test_program_name
## no critic (RequireBriefOpen)
or confess
"Could not open $test_program_name: $ERRNO"
;
{
$test_program
}
<<"END_TEST_PROGRAM";
#!/usr/bin/env perl
# Do not edit!!! This program generated by $this_program.
use strict;
use warnings;
use English qw{-no_match_vars};
our \$VERSION = $VERSION;
#-----------------------------------------------------------------------------
my \$module_loaded = eval <<'END_HIDE_MODULES';
use Test::Without::Module qw{
$modules_to_hide
};
1;
END_HIDE_MODULES
if ( not \$module_loaded ) {
'1..0 # Skip ',
'Test::Without::Module required to test with the ',
"absence of optional modules\\n";
exit 0;
}
require '$wrapped_test_name';
END_TEST_PROGRAM
close
$test_program
;
}
"Done.\n\n"
;
__END__
#-----------------------------------------------------------------------------
=pod
=for stopwords
=head1 NAME
generate_without_additional_dependencies_wrappers.PL - generate tests that are wrappers around other tests but which hide the existence of modules first.
=head1 SYNOPSIS
generate_without_additional_dependencies_wrappers.PL \
t/00_modules.t_without_optional_dependencies.t \
t/01_config.t_without_optional_dependencies.t \
t/13_bundled_policies.t_without_optional_dependencies.t
=head1 DESCRIPTION
Release 1.07 of Perl::Critic was an embarrassment because there were no tests
of core without the presence of optional modules. This program generates
wrappers for other tests that hide those optional modules.
=head1 AUTHOR
Elliot Shank C<< <perl@galumph.org> >>
=head1 COPYRIGHT
Copyright (c) 2007-2009 Elliot Shank. All rights reserved.
This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself. The full text of this license can be found in
the LICENSE file included with this module.
=cut
##############################################################################
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 78
# indent-tabs-mode: nil
# c-indentation-style: bsd
# End:
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :