Blame t/taint.t

Packit 6539e1
#!/usr/bin/perl -T
Packit 6539e1
use strict;
Packit 6539e1
use warnings;
Packit 6539e1
Packit 6539e1
use Config;
Packit 6539e1
use Test::More $Config{ccflags} =~ /-DSILENT_NO_TAINT_SUPPORT/
Packit 6539e1
    ? ( skip_all => 'No taint support' ) : ( tests => 2 );
Packit 6539e1
use Module::Metadata;
Packit 6539e1
use Carp 'croak';
Packit 6539e1
Packit 6539e1
# stolen liberally from Class-Tiny/t/lib/TestUtils.pm - thanks xdg!
Packit 6539e1
sub exception(&) {
Packit 6539e1
    my $code = shift;
Packit 6539e1
    my $success = eval { $code->(); 1 };
Packit 6539e1
    my $err = $@;
Packit 6539e1
    return undef if $success;   # original returned ''
Packit 6539e1
    croak "Execution died, but the error was lost" unless $@;
Packit 6539e1
    return $@;
Packit 6539e1
}
Packit 6539e1
Packit 6539e1
my $taint_on = ! eval { no warnings; join('',values %ENV), kill 0; 1; };
Packit 6539e1
ok($taint_on, 'taint flag is set');
Packit 6539e1
Packit 6539e1
# without the fix, we get:
Packit 6539e1
# Insecure dependency in eval while running with -T switch at lib/Module/Metadata.pm line 668, <GEN0> line 15.
Packit 6539e1
is(
Packit 6539e1
    exception { Module::Metadata->new_from_module( "Module::Metadata" )->version },
Packit 6539e1
    undef,
Packit 6539e1
    'no exception',
Packit 6539e1
);
Packit 6539e1