#!/usr/bin/env perl
use
Fatal
qw{ open close }
;
our
$VERSION
=
'1.083_006'
;
Readonly::Scalar
my
$GENERATED_DIRECTORY
=>
'xt/author/generated/'
;
if
( not -d
$GENERATED_DIRECTORY
) {
print
"\n\nSkipping generating tests because it doesn't "
,
"look like we're in an author environment.\n\n"
;
exit
0;
}
print
"\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 )
_without_optional_dependencies\.t
\z
>xmso;
if
(not
$wrapped_test_name
) {
confess
'Could not figure out the name of the test to wrap from "'
.
$test_program_name
.
q{".}
;
}
print
"Generating $test_program_name.\n"
;
open
my
$test_program
,
'>'
,
$test_program_name
or
die
"Could not open $test_program_name: $ERRNO"
;
print
{
$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};
use lib 't/tlib';
use Perl::Critic::TestUtilitiesWithMinimalDependencies qw{
get_skip_all_tests_tap
};
our \$VERSION = $VERSION;
#-----------------------------------------------------------------------------
eval <<'END_HIDE_MODULES';
use Test::Without::Module qw{
$modules_to_hide
};
END_HIDE_MODULES
if ( \$EVAL_ERROR ) {
print
get_skip_all_tests_tap(),
'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
;
}
print
"Done.\n\n"
;
Hide Show 40 lines of Pod