16fb12b70Safresh1#!/usr/bin/perl -T 26fb12b70Safresh1use strict; 36fb12b70Safresh1use warnings; 46fb12b70Safresh1 5*b8851fccSafresh1use Config; 6*b8851fccSafresh1use Test::More $Config{ccflags} =~ /-DSILENT_NO_TAINT_SUPPORT/ 7*b8851fccSafresh1 ? ( skip_all => 'No taint support' ) : ( tests => 2 ); 86fb12b70Safresh1use Module::Metadata; 96fb12b70Safresh1use Carp 'croak'; 106fb12b70Safresh1 116fb12b70Safresh1# stolen liberally from Class-Tiny/t/lib/TestUtils.pm - thanks xdg! 126fb12b70Safresh1sub exception(&) { 136fb12b70Safresh1 my $code = shift; 146fb12b70Safresh1 my $success = eval { $code->(); 1 }; 156fb12b70Safresh1 my $err = $@; 166fb12b70Safresh1 return undef if $success; # original returned '' 176fb12b70Safresh1 croak "Execution died, but the error was lost" unless $@; 186fb12b70Safresh1 return $@; 196fb12b70Safresh1} 206fb12b70Safresh1 21*b8851fccSafresh1my $taint_on = ! eval { no warnings; join('',values %ENV), kill 0; 1; }; 22*b8851fccSafresh1ok($taint_on, 'taint flag is set'); 236fb12b70Safresh1 246fb12b70Safresh1# without the fix, we get: 256fb12b70Safresh1# Insecure dependency in eval while running with -T switch at lib/Module/Metadata.pm line 668, <GEN0> line 15. 266fb12b70Safresh1is( 276fb12b70Safresh1 exception { Module::Metadata->new_from_module( "Module::Metadata" )->version }, 286fb12b70Safresh1 undef, 296fb12b70Safresh1 'no exception', 306fb12b70Safresh1); 316fb12b70Safresh1 32