This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Introduction of d_pseudofork
[perl5.git] / t / run / switcht.t
CommitLineData
317ea90d 1#!./perl -t
6537fe72
MS
2
3BEGIN {
4 chdir 't';
5 @INC = '../lib';
6 require './test.pl';
7}
8
317ea90d 9plan tests => 11;
6537fe72
MS
10
11my $Perl = which_perl();
12
13my $warning;
14local $SIG{__WARN__} = sub { $warning = join "\n", @_; };
15my $Tmsg = 'while running with -t switch';
16
9aa05f58 17is( ${^TAINT}, -1, '${^TAINT} == -1' );
6537fe72 18
dc459aad 19my $out = `$Perl -le "print q(Hello)"`;
6537fe72
MS
20is( $out, "Hello\n", '`` worked' );
21like( $warning, qr/^Insecure .* $Tmsg/, ' taint warn' );
22
23{
24 no warnings 'taint';
25 $warning = '';
dc459aad 26 my $out = `$Perl -le "print q(Hello)"`;
6537fe72
MS
27 is( $out, "Hello\n", '`` worked' );
28 is( $warning, '', ' no warnings "taint"' );
29}
30
31# Get ourselves a tainted variable.
32$file = $0;
33$file =~ s/.*/some.tmp/;
34ok( open(FILE, ">$file"), 'open >' ) or DIE $!;
35print FILE "Stuff\n";
36close FILE;
37like( $warning, qr/^Insecure dependency in open $Tmsg/, 'open > taint warn' );
38ok( -e $file, ' file written' );
39
40unlink($file);
41like( $warning, qr/^Insecure dependency in unlink $Tmsg/,
42 'unlink() taint warn' );
43ok( !-e $file, 'unlink worked' );
317ea90d
MS
44
45ok( !$^W, "-t doesn't enable regular warnings" );