App-CamelPKI
view release on metacpan or search on metacpan
inc/My/Module/Build.pm view on Meta::CPAN
# Compute adequate @INC for sub-perl:
my @inc = do { my %inc_dupes; grep { !$inc_dupes{$_}++ } @INC };
if (is_win32) { s/[\\\/+]$// foreach @inc; }
# Add blib/lib and blib/arch like the original ACTION_test does:
if ($self->use_blib) {
unshift @inc, catdir($self->base_dir(), $self->blib, 'lib'),
catdir($self->base_dir(), $self->blib, 'arch');
} else {
unshift @inc, catdir($self->base_dir(), 'lib');
}
# Parse shebang line to set taintedness properly:
local *TEST;
open(TEST, $files_to_test[0]) or die
"Can't open $files_to_test[0]. $!\n";
my $shebang = <TEST>;
close(TEST) or print "Can't close $files_to_test[0]. $!\n";
my $taint = ( $shebang =~ /^#!.*\bperl.*\s-\w*([Tt]+)/ );
my ($perl) = ($^X =~ m/^(.*)$/); # Untainted
system($perl, "-d",
($taint ? ("-T") : ()),
(map { ("-I" => $_) } @inc),
$files_to_test[0], "-emacs");
return;
}
# Localize stuff in order to fool our superclass for fun & profit
local %ENV = $self->customize_env(%ENV);
local $self->{FORCE_find_test_files_result}; # See L</find_test_files>
inc/My/Module/Build.pm view on Meta::CPAN
<<"BOGON");
#!perl -w
package My::Private::Stuff::Indeed;
use strict;
1;
BOGON
my ($perl) = ($^X =~ m/^(.*)$/); # Untainted
chdir($fakemoduledir);
my $pipe = new IO::Pipe();
$pipe->reader($perl, "$fakemoduledir/Build.PL");
my $log = join('', <$pipe>);
$pipe->close(); is($?, 0, "Running Build.PL");
like($log, qr/version.*0.42/, "Build.PL found the version string");
SKIP: {
skip "Not testing Build distmeta (YAML not available)", 2
inc/My/Tests/Below.pm view on Meta::CPAN
next if $line eq ""; # Often authors leave empty lines to
# delimit paragraphs in SYNOPSIS, count them as undefined
# length as well
$line =~ m/^( *)/; my $spaceamount = length($1);
$ragamount = $spaceamount if ((!defined $ragamount) ||
($ragamount > $spaceamount));
}
s/^[ ]{$ragamount}//gm;
m/^(.*)$/s; return $1; # Untainted
}
=item I<pod_code_snippet($snippetname)>
Works like L</pod_data_snippet>, except that an adequate #line is
prepended for the benefit of the debugger. You can thus single-step
inside your POD documentation, yow! Using the above sample .pm file
(see L</pod_data_snippet>), you could do something like this in the
test trailer:
inc/My/Tests/Below.pm view on Meta::CPAN
use File::Spec;
use Fatal qw(mkdir chdir read_file write_file);
###### Tests over the __END__ test section for real modules
# Runs Perl on $filename, returning what we got on stdout / stderr.
# $? is also set.
sub run_perl {
my ($filename) = @_;
my ($stdin, $stdout) = map { new IO::Handle } (1..2);
my ($perl) = ($^X =~ m/^(.*)$/); # Untainted
my $pid = open3($stdin, $stdout, $stdout,
$perl, (map { -I => $_ } @INC), '-Tw', $filename);
$stdin->close();
my $retval = join('', <$stdout>);
$stdout->close();
waitpid($pid, 0); # Sets $?
return $retval;
}
my $fakemoduledir = My::Tests::Below->tempdir() . "/Fake-Module";
t/lib/App/CamelPKI/Test.pm view on Meta::CPAN
=item I<openssl_path>
Returns the path to the C<openssl> command-line tool, if it is known,
or undef. Useful for skipping tests that depend on
L</run_thru_openssl> being able to run.
=cut
sub openssl_path {
my ($openssl_bin) =
( `which openssl 2>/dev/null` =~ m/^(.*)/ ); # Chopped, untainted
return if ! ($openssl_bin && -x $openssl_bin);
return $openssl_bin;
}
=item I<run_thru_openssl($stdin_text, $arg1, $arg2, ...)>
Runs the command C<openssl $arg1 $arg2 ...>, feeding it $stdin_text on
its standard input. In list context, returns a ($stdout_text,
$stderr_text) pair. In scalar context, returns the text of the
combined standard output and error streams. Throws an exception if
t/lib/App/CamelPKI/Test.pm view on Meta::CPAN
my $scriptfile = catfile
($scriptdir, sprintf("run_perl_ok_%d_%d", $$,
_unique_number()));
write_file($scriptfile, $scripttext);
diag(<<"FOR_CONVENIENCE");
run_perl: a copy of the script to run was saved in $scriptfile
to ease debugging.
FOR_CONVENIENCE
}
my ($perl) = ($^X =~ m/^(.*)$/); # Untainted
my @perlcmdline = ($perl, (map { -I => $_ }
(grep {! m|/usr|} @INC)), # Shame, shame.
);
diag(join(" ", @perlcmdline)) if $ENV{DEBUG};
my $stdout;
IPC::Run::run(\@perlcmdline, \$scripttext, \$stdout, \$stdout);
return $stdout;
}
( run in 0.294 second using v1.01-cache-2.11-cpan-d6f9594c0a5 )