diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-06-13 19:02:48 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-06-13 19:02:48 +0000 |
commit | 0a0ea7d6333a44d024998c9e7c6f04db8dc8fba7 (patch) | |
tree | adc2e47f9657376db54ef15d61bd1f6e9c9fe80a /t | |
parent | fcf2db383b9625d65c84a8308e9be05a073bed3b (diff) | |
parent | cd040c5e5361532c72bb6628047b8d6c97fee51b (diff) | |
download | perl-0a0ea7d6333a44d024998c9e7c6f04db8dc8fba7.tar.gz |
Integrate mainline. Storable fail has gone, insecure dependancy still there.
p4raw-id: //depot/perlio@10577
Diffstat (limited to 't')
-rwxr-xr-x | t/base/term.t | 5 | ||||
-rwxr-xr-x | t/comp/cpp.t | 2 | ||||
-rwxr-xr-x | t/comp/multiline.t | 4 | ||||
-rwxr-xr-x | t/comp/script.t | 3 | ||||
-rwxr-xr-x | t/lib/anydbm.t | 2 | ||||
-rwxr-xr-x | t/lib/autoloader.t | 36 | ||||
-rwxr-xr-x | t/lib/dirhand.t | 3 | ||||
-rw-r--r-- | t/lib/extutils.t | 71 | ||||
-rw-r--r-- | t/lib/filecomp.t | 12 | ||||
-rwxr-xr-x | t/lib/filecopy.t | 72 | ||||
-rwxr-xr-x | t/lib/filefind.t | 735 | ||||
-rwxr-xr-x | t/lib/io_dir.t | 8 | ||||
-rwxr-xr-x | t/lib/selfloader.t | 13 | ||||
-rwxr-xr-x | t/op/anonsub.t | 11 | ||||
-rwxr-xr-x | t/op/closure.t | 1 | ||||
-rwxr-xr-x | t/op/defins.t | 9 | ||||
-rwxr-xr-x | t/op/exec.t | 6 | ||||
-rwxr-xr-x | t/op/glob.t | 10 | ||||
-rwxr-xr-x | t/op/goto.t | 2 | ||||
-rwxr-xr-x | t/op/magic.t | 6 | ||||
-rwxr-xr-x | t/op/pack.t | 2 | ||||
-rwxr-xr-x | t/op/regexp.t | 2 | ||||
-rwxr-xr-x | t/op/regexp_noamp.t | 6 | ||||
-rwxr-xr-x | t/op/split.t | 1 | ||||
-rwxr-xr-x | t/op/write.t | 3 | ||||
-rwxr-xr-x | t/pragma/strict.t | 8 |
26 files changed, 835 insertions, 198 deletions
diff --git a/t/base/term.t b/t/base/term.t index 061cd33b1e..1d688b8f5b 100755 --- a/t/base/term.t +++ b/t/base/term.t @@ -11,8 +11,9 @@ print "1..7\n"; # check "" interpretation $x = "\n"; -# 10 is ASCII/Iso Latin, 21 is EBCDIC. +# 10 is ASCII/Iso Latin, 13 is Mac OS, 21 is EBCDIC. if ($x eq chr(10)) { print "ok 1\n";} +elsif ($x eq chr(13)) { print "ok 1 # Mac OS\n"; } elsif ($x eq chr(21)) { print "ok 1 # EBCDIC\n"; } else {print "not ok 1\n";} @@ -39,7 +40,7 @@ if (($x | 1) == 101) {print "ok 5\n";} else {print "not ok 5\n";} # check <> pseudoliteral -open(try, "/dev/null") || open(try,"nla0:") || (die "Can't open /dev/null."); +open(try, "/dev/null") || open(try,"Dev:Null") || open(try,"nla0:") || (die "Can't open /dev/null."); if (<try> eq '') { print "ok 6\n"; } diff --git a/t/comp/cpp.t b/t/comp/cpp.t index 5b061ee181..cb8df50811 100755 --- a/t/comp/cpp.t +++ b/t/comp/cpp.t @@ -8,7 +8,7 @@ BEGIN { } use Config; -if ( $^O eq 'MSWin32' or +if ( $^O eq 'MSWin32' or $^O eq 'MacOS' or ($Config{'cppstdin'} =~ /\bcppstdin\b/) and ( ! -x $Config{'binexp'} . "/cppstdin") ) { print "1..0 # Skip: \$Config{cppstdin} unavailable\n"; diff --git a/t/comp/multiline.t b/t/comp/multiline.t index ed418b84fc..309ac71e9b 100755 --- a/t/comp/multiline.t +++ b/t/comp/multiline.t @@ -36,7 +36,9 @@ if ($z eq $y) {print "ok 2\n";} else {print "not ok 2\n";} if ($count == 7) {print "ok 3\n";} else {print "not ok 3\n";} -$_ = ($^O eq 'MSWin32') ? `type Comp.try` : `cat Comp.try`; +$_ = ($^O eq 'MSWin32') ? `type Comp.try` + : ($^O eq 'MacOS') ? `catenate Comp.try` + : `cat Comp.try`; if (/.*\n.*\n.*\n$/) {print "ok 4\n";} else {print "not ok 4\n";} diff --git a/t/comp/script.t b/t/comp/script.t index a9bc47d3f2..9ae83e4304 100755 --- a/t/comp/script.t +++ b/t/comp/script.t @@ -4,7 +4,8 @@ print "1..3\n"; -$PERL = ($^O eq 'MSWin32') ? '.\perl' : './perl'; +$PERL = ($^O eq 'MSWin32') ? '.\perl' + : ($^O eq 'MacOS') ? $^X : './perl'; $x = `$PERL -le "print 'ok';"`; if ($x eq "ok\n") {print "ok 1\n";} else {print "not ok 1\n";} diff --git a/t/lib/anydbm.t b/t/lib/anydbm.t index 40c436628f..08d1f7c947 100755 --- a/t/lib/anydbm.t +++ b/t/lib/anydbm.t @@ -29,7 +29,7 @@ $Dfile = "Op_dbmx.pag"; if (! -e $Dfile) { ($Dfile) = <Op_dbmx*>; } -if ($Is_Dosish) { +if ($Is_Dosish || $^O eq 'MacOS') { print "ok 2 # Skipped: different file permission semantics\n"; } else { diff --git a/t/lib/autoloader.t b/t/lib/autoloader.t index b53b9feeae..f2fae7f309 100755 --- a/t/lib/autoloader.t +++ b/t/lib/autoloader.t @@ -2,7 +2,13 @@ BEGIN { chdir 't' if -d 't'; - $dir = "auto-$$"; + if ($^O eq 'MacOS') { + $dir = ":auto-$$"; + $sep = ":"; + } else { + $dir = "auto-$$"; + $sep = "/"; + } @INC = $dir; push @INC, '../lib'; } @@ -11,10 +17,10 @@ print "1..11\n"; # First we must set up some autoloader files mkdir $dir, 0755 or die "Can't mkdir $dir: $!"; -mkdir "$dir/auto", 0755 or die "Can't mkdir: $!"; -mkdir "$dir/auto/Foo", 0755 or die "Can't mkdir: $!"; +mkdir "$dir${sep}auto", 0755 or die "Can't mkdir: $!"; +mkdir "$dir${sep}auto${sep}Foo", 0755 or die "Can't mkdir: $!"; -open(FOO, ">$dir/auto/Foo/foo.al") or die; +open(FOO, ">$dir${sep}auto${sep}Foo${sep}foo.al") or die; print FOO <<'EOT'; package Foo; sub foo { shift; shift || "foo" } @@ -22,7 +28,7 @@ sub foo { shift; shift || "foo" } EOT close(FOO); -open(BAR, ">$dir/auto/Foo/bar.al") or die; +open(BAR, ">$dir${sep}auto${sep}Foo${sep}bar.al") or die; print BAR <<'EOT'; package Foo; sub bar { shift; shift || "bar" } @@ -30,7 +36,7 @@ sub bar { shift; shift || "bar" } EOT close(BAR); -open(BAZ, ">$dir/auto/Foo/bazmarkhian.al") or die; +open(BAZ, ">$dir${sep}auto${sep}Foo${sep}bazmarkhian.al") or die; print BAZ <<'EOT'; package Foo; sub bazmarkhianish { shift; shift || "baz" } @@ -90,7 +96,7 @@ print "not " unless $foo->bazmarkhianish($1) eq 'foo'; print "ok 9\n"; # test recursive autoloads -open(F, ">$dir/auto/Foo/a.al") or die; +open(F, ">$dir${sep}auto${sep}Foo${sep}a.al") or die; print F <<'EOT'; package Foo; BEGIN { b() } @@ -99,7 +105,7 @@ sub a { print "ok 11\n"; } EOT close(F); -open(F, ">$dir/auto/Foo/b.al") or die; +open(F, ">$dir${sep}auto${sep}Foo${sep}b.al") or die; print F <<'EOT'; package Foo; sub b { print "ok 10\n"; } @@ -111,12 +117,12 @@ Foo::a(); # cleanup END { return unless $dir && -d $dir; -unlink "$dir/auto/Foo/foo.al"; -unlink "$dir/auto/Foo/bar.al"; -unlink "$dir/auto/Foo/bazmarkhian.al"; -unlink "$dir/auto/Foo/a.al"; -unlink "$dir/auto/Foo/b.al"; -rmdir "$dir/auto/Foo"; -rmdir "$dir/auto"; +unlink "$dir${sep}auto${sep}Foo${sep}foo.al"; +unlink "$dir${sep}auto${sep}Foo${sep}bar.al"; +unlink "$dir${sep}auto${sep}Foo${sep}bazmarkhian.al"; +unlink "$dir${sep}auto${sep}Foo${sep}a.al"; +unlink "$dir${sep}auto${sep}Foo${sep}b.al"; +rmdir "$dir${sep}auto${sep}Foo"; +rmdir "$dir${sep}auto"; rmdir "$dir"; } diff --git a/t/lib/dirhand.t b/t/lib/dirhand.t index aa7be356df..e83ea13496 100755 --- a/t/lib/dirhand.t +++ b/t/lib/dirhand.t @@ -14,7 +14,8 @@ use DirHandle; print "1..5\n"; -$dot = new DirHandle "."; +$dot = new DirHandle ($^O eq 'MacOS' ? ':' : '.'); + print defined($dot) ? "ok" : "not ok", " 1\n"; @a = sort <*>; diff --git a/t/lib/extutils.t b/t/lib/extutils.t index 48c2aa30e4..fa256af17c 100644 --- a/t/lib/extutils.t +++ b/t/lib/extutils.t @@ -1,6 +1,6 @@ #!./perl -w -print "1..21\n"; +print "1..24\n"; BEGIN { chdir 't' if -d 't'; @@ -42,6 +42,11 @@ END { my $package = "ExtTest"; +# Test the code that generates 1 and 2 letter name comparisons. +my %compass = ( +N => 0, NE => 45, E => 90, SE => 135, S => 180, SW => 225, W => 270, NW => 315 +); + my @names = ("FIVE", {name=>"OK6", type=>"PV",}, {name=>"OK7", type=>"PVN", value=>['"not ok 7\\n\\0ok 7\\n"', 15]}, @@ -54,9 +59,11 @@ my @names = ("FIVE", {name=>"OK6", type=>"PV",}, {name => "ANSWER", default=>["UV", 42]}, "NOTDEF", {name => "Yes", type=>"YES"}, {name => "No", type=>"NO"}, - {name => "Undef", type=>"UNDEF"} + {name => "Undef", type=>"UNDEF"}, ); +push @names, $_ foreach keys %compass; + my @names_only = map {(ref $_) ? $_->{name} : $_} @names; my $types = {}; @@ -78,8 +85,14 @@ print FH <<'EOT'; #define Yes 0 #define No 1 #define Undef 1 + #undef NOTDEF + EOT + +while (my ($point, $bearing) = each %compass) { + print FH "#define $point $bearing\n" +} close FH or die "close $header: $!\n"; ################ XS @@ -232,6 +245,58 @@ unless (defined $undef) { print "not ok 16 # \$undef='$undef'\n"; } + +# invalid macro (chosen to look like a mix up between No and SW) +$notdef = eval { &ExtTest::So }; +if (defined $notdef) { + print "not ok 17 # \$notdef='$notdef'\n"; +} elsif ($@ !~ /^So is not a valid ExtTest macro/) { + print "not ok 17 # \$@='$@'\n"; +} else { + print "ok 17\n"; +} + +# invalid defined macro +$notdef = eval { &ExtTest::EW }; +if (defined $notdef) { + print "not ok 18 # \$notdef='$notdef'\n"; +} elsif ($@ !~ /^EW is not a valid ExtTest macro/) { + print "not ok 18 # \$@='$@'\n"; +} else { + print "ok 18\n"; +} + +my %compass = ( +EOT + +while (my ($point, $bearing) = each %compass) { + print FH "$point => $bearing, " +} + +print FH <<'EOT'; + +); + +my $fail; +while (my ($point, $bearing) = each %compass) { + my $val = eval $point; + if ($@) { + print "# $point: \$@='$@'\n"; + $fail = 1; + } elsif (!defined $bearing) { + print "# $point: \$val=undef\n"; + $fail = 1; + } elsif ($val != $bearing) { + print "# $point: \$val=$val, not $bearing\n"; + $fail = 1; + } +} +if ($fail) { + print "not ok 19\n"; +} else { + print "ok 19\n"; +} + EOT close FH or die "close $testpl: $!\n"; @@ -309,7 +374,7 @@ if ($Config{usedl}) { } } -my $test = 17; +my $test = 20; my $maketest = "$make test"; print "# make = '$maketest'\n"; $makeout = `$maketest`; diff --git a/t/lib/filecomp.t b/t/lib/filecomp.t index 167a46a431..aedc32323e 100644 --- a/t/lib/filecomp.t +++ b/t/lib/filecomp.t @@ -97,8 +97,16 @@ print "# problems when testing with a tempory file\n" if $@; if (@donetests == 2) { print "not " unless $donetests[0] == 0; print "ok 11\n"; - print "not " unless $donetests[1] == 0; - print "ok 12\n"; + if ($^O eq 'VMS') { + # The open attempt on FROM in File::Compare::compare should fail + # on this OS since files are not shared by default. + print "not " unless $donetests[1] == -1; + print "ok 12\n"; + } + else { + print "not " unless $donetests[1] == 0; + print "ok 12\n"; + } } else { print "ok 11# Skip\nok 12 # Skip Likely due to File::Temp\n"; diff --git a/t/lib/filecopy.t b/t/lib/filecopy.t index 8412258a69..44b5827e72 100755 --- a/t/lib/filecopy.t +++ b/t/lib/filecopy.t @@ -3,12 +3,13 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; + push @INC, "::lib:$MacPerl::Architecture" if $^O eq 'MacOS'; } $| = 1; my @pass = (0,1); -my $tests = 11; +my $tests = $^O eq 'MacOS' ? 14 : 11; printf "1..%d\n", $tests * scalar(@pass); use File::Copy; @@ -82,22 +83,65 @@ for my $pass (@pass) { print "# foo=`$foo'\nnot " unless $foo eq sprintf "ok %d\n", 3+$loopconst; printf "ok %d\n", 9+$loopconst; - copy "file-$$", "lib"; - open(R, "lib/file-$$") or die; $foo = <R>; close(R); - print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst; - printf "ok %d\n", 10+$loopconst; - unlink "lib/file-$$" or die "unlink: $!"; - - move "file-$$", "lib"; - open(R, "lib/file-$$") or die "open lib/file-$$: $!"; $foo = <R>; close(R); - print "not " unless $foo eq sprintf("ok %d\n", 3+$loopconst) - and not -e "file-$$";; - printf "ok %d\n", 11+$loopconst; - unlink "lib/file-$$" or die "unlink: $!"; + if ($^O eq 'MacOS') { + + copy "file-$$", "lib"; + open(R, ":lib:file-$$") or die; $foo = <R>; close(R); + print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst; + printf "ok %d\n", 10+$loopconst; + unlink ":lib:file-$$" or die "unlink: $!"; + + copy "file-$$", ":lib"; + open(R, ":lib:file-$$") or die; $foo = <R>; close(R); + print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst; + printf "ok %d\n", 11+$loopconst; + unlink ":lib:file-$$" or die "unlink: $!"; + + copy "file-$$", ":lib:"; + open(R, ":lib:file-$$") or die; $foo = <R>; close(R); + print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst; + printf "ok %d\n", 12+$loopconst; + unlink ":lib:file-$$" or die "unlink: $!"; + + unless (-e 'lib:') { # make sure there's no volume called 'lib' + undef $@; + eval { (copy "file-$$", "lib:") || die "'lib:' is not a volume name"; }; + print "# Died: $@"; + print "not " unless ( $@ =~ m|'lib:' is not a volume name| ); + } + printf "ok %d\n", 13+$loopconst; + + move "file-$$", ":lib:"; + open(R, ":lib:file-$$") or die "open :lib:file-$$: $!"; $foo = <R>; close(R); + print "not " unless $foo eq sprintf("ok %d\n", 3+$loopconst) + and not -e "file-$$";; + printf "ok %d\n", 14+$loopconst; + unlink ":lib:file-$$" or die "unlink: $!"; + + } else { + + copy "file-$$", "lib"; + open(R, "lib/file-$$") or die; $foo = <R>; close(R); + print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst; + printf "ok %d\n", 10+$loopconst; + unlink "lib/file-$$" or die "unlink: $!"; + + move "file-$$", "lib"; + open(R, "lib/file-$$") or die "open lib/file-$$: $!"; $foo = <R>; close(R); + print "not " unless $foo eq sprintf("ok %d\n", 3+$loopconst) + and not -e "file-$$";; + printf "ok %d\n", 11+$loopconst; + unlink "lib/file-$$" or die "unlink: $!"; + + } } END { 1 while unlink "file-$$"; - 1 while unlink "lib/file-$$"; + if ($^O eq 'MacOS') { + 1 while unlink ":lib:file-$$"; + } else { + 1 while unlink "lib/file-$$"; + } } diff --git a/t/lib/filefind.t b/t/lib/filefind.t index 72e2669ad0..1152cdf157 100755 --- a/t/lib/filefind.t +++ b/t/lib/filefind.t @@ -1,43 +1,79 @@ -####!./perl +#!./perl -T my %Expect; my $symlink_exists = eval { symlink("",""); 1 }; +my $warn_msg; +my $cwd; +my $cwd_untainted; BEGIN { chdir 't' if -d 't'; - @INC = '../lib'; + @INC = '../lib'; + + for (keys %ENV) { # untaint ENV + ($ENV{$_}) = keys %{{ map {$_ => 1} $ENV{$_} }}; + } + + $SIG{'__WARN__'} = sub { $warn_msg = $_[0]; warn "# Warn: $_[0]"; } } -if ( $symlink_exists ) { print "1..119\n"; } -else { print "1..61\n"; } +if ( $symlink_exists ) { print "1..184\n"; } +else { print "1..75\n"; } use File::Find; +use Cwd; cleanup(); -find(sub { print "ok 1\n" if $_ eq 'filefind.t'; }, "."); -finddepth(sub { print "ok 2\n" if $_ eq 'filefind.t'; }, "."); +if ($^O eq 'MacOS') { + find({wanted => sub { print "ok 1\n" if $_ eq 'filefind.t'; }, untaint => 1}, ':'); + finddepth({wanted => sub { print "ok 2\n" if $_ eq 'filefind.t'; }, untaint => 1}, ':'); +} else { + find({wanted => sub { print "ok 1\n" if $_ eq 'filefind.t'; }, untaint => 1, + untaint_pattern => qr|^(.+)$|}, '.'); + finddepth({wanted => sub { print "ok 2\n" if $_ eq 'filefind.t'; }, + untaint => 1, untaint_pattern => qr|^(.+)$|}, '.'); +} my $case = 2; my $FastFileTests_OK = 0; sub cleanup { - if (-d 'for_find') { - chdir('for_find'); - } - if (-d 'fa') { - unlink 'fa/fa_ord', 'fa/fsl', 'fa/faa/faa_ord', - 'fa/fab/fab_ord', 'fa/fab/faba/faba_ord', - 'fb/fb_ord', 'fb/fba/fba_ord'; - rmdir 'fa/faa'; - rmdir 'fa/fab/faba'; - rmdir 'fa/fab'; - rmdir 'fa'; - rmdir 'fb/fba'; - rmdir 'fb'; - chdir '..'; - rmdir 'for_find'; + if ($^O eq 'MacOS') { + if (-d ':for_find') { + chdir(':for_find'); + } + if (-d ':fa') { + unlink ':fa:fa_ord',':fa:fsl',':fa:faa:faa_ord', + ':fa:fab:fab_ord',':fa:fab:faba:faba_ord', + ':fb:fb_ord',':fb:fba:fba_ord'; + rmdir ':fa:faa'; + rmdir ':fa:fab:faba'; + rmdir ':fa:fab'; + rmdir ':fa'; + rmdir ':fb:fba'; + rmdir ':fb'; + chdir '::'; + rmdir ':for_find'; + } + } else { + if (-d 'for_find') { + chdir('for_find'); + } + if (-d 'fa') { + unlink 'fa/fa_ord','fa/fsl','fa/faa/faa_ord', + 'fa/fab/fab_ord','fa/fab/faba/faba_ord', + 'fb/fb_ord','fb/fba/fba_ord'; + rmdir 'fa/faa'; + rmdir 'fa/fab/faba'; + rmdir 'fa/fab'; + rmdir 'fa'; + rmdir 'fb/fba'; + rmdir 'fb'; + chdir '..'; + rmdir 'for_find'; + } } } @@ -66,7 +102,7 @@ sub MkDir($$) { } sub wanted { - print "# '$_' => 1\n"; + print "# '$_' => 1\n"; s#\.$## if ($^O eq 'VMS' && $_ ne '.'); Check( $Expect{$_} ); if ( $FastFileTests_OK ) { @@ -77,7 +113,7 @@ sub wanted { unless ( $Expect_Dir{$_} && ! -d $_ ); } $File::Find::prune=1 if $_ eq 'faba'; - + } sub dn_wanted { @@ -86,8 +122,10 @@ sub dn_wanted { print "# '$n' => 1\n"; my $i = rindex($n,'/'); my $OK = exists($Expect{$n}); - if ( $OK ) { - $OK= exists($Expect{substr($n,0,$i)}) if $i >= 0; + unless ($^O eq 'MacOS') { + if ( $OK ) { + $OK= exists($Expect{substr($n,0,$i)}) if $i >= 0; + } } Check($OK); delete $Expect{$n}; @@ -98,120 +136,551 @@ sub d_wanted { s#\.$## if ($^O eq 'VMS' && $_ ne '.'); my $i = rindex($_,'/'); my $OK = exists($Expect{$_}); - if ( $OK ) { - $OK= exists($Expect{substr($_,0,$i)}) if $i >= 0; + unless ($^O eq 'MacOS') { + if ( $OK ) { + $OK= exists($Expect{substr($_,0,$i)}) if $i >= 0; + } } Check($OK); delete $Expect{$_}; } -MkDir( 'for_find',0770 ); -CheckDie(chdir(for_find)); -MkDir( 'fa',0770 ); -MkDir( 'fb',0770 ); -touch('fb/fb_ord'); -MkDir( 'fb/fba',0770 ); -touch('fb/fba/fba_ord'); -CheckDie( symlink('../fb','fa/fsl') ) if $symlink_exists; -touch('fa/fa_ord'); - -MkDir( 'fa/faa',0770 ); -touch('fa/faa/faa_ord'); -MkDir( 'fa/fab',0770 ); -touch('fa/fab/fab_ord'); -MkDir( 'fa/fab/faba',0770 ); -touch('fa/fab/faba/faba_ord'); - -%Expect = ('.' => 1, 'fsl' => 1, 'fa_ord' => 1, 'fab' => 1, 'fab_ord' => 1, - 'faba' => 1, 'faa' => 1, 'faa_ord' => 1); -delete $Expect{'fsl'} unless $symlink_exists; -%Expect_Dir = ('fa' => 1, 'faa' => 1, 'fab' => 1, 'faba' => 1, - 'fb' => 1, 'fba' => 1); -delete @Expect_Dir{'fb','fba'} unless $symlink_exists; -File::Find::find( {wanted => \&wanted, },'fa' ); -Check( scalar(keys %Expect) == 0 ); - -%Expect=('fa' => 1, 'fa/fsl' => 1, 'fa/fa_ord' => 1, 'fa/fab' => 1, - 'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, - 'fa/fab/faba/faba_ord' => 1, 'fa/faa' => 1, 'fa/faa/faa_ord' => 1); -delete $Expect{'fa/fsl'} unless $symlink_exists; -%Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, - 'fb' => 1, 'fb/fba' => 1); -delete @Expect_Dir{'fb','fb/fba'} unless $symlink_exists; -File::Find::find( {wanted => \&wanted, no_chdir => 1},'fa' ); - -Check( scalar(keys %Expect) == 0 ); - -%Expect=('.' => 1, './fa' => 1, './fa/fsl' => 1, './fa/fa_ord' => 1, './fa/fab' => 1, - './fa/fab/fab_ord' => 1, './fa/fab/faba' => 1, - './fa/fab/faba/faba_ord' => 1, './fa/faa' => 1, './fa/faa/faa_ord' => 1, - './fb' => 1, './fb/fba' => 1, './fb/fba/fba_ord' => 1, './fb/fb_ord' => 1); -delete $Expect{'./fa/fsl'} unless $symlink_exists; -%Expect_Dir = ('./fa' => 1, './fa/faa' => 1, '/fa/fab' => 1, './fa/fab/faba' => 1, - './fb' => 1, './fb/fba' => 1); -delete @Expect_Dir{'./fb','./fb/fba'} unless $symlink_exists; -File::Find::finddepth( {wanted => \&dn_wanted },'.' ); -Check( scalar(keys %Expect) == 0 ); - -%Expect=('.' => 1, './fa' => 1, './fa/fsl' => 1, './fa/fa_ord' => 1, './fa/fab' => 1, - './fa/fab/fab_ord' => 1, './fa/fab/faba' => 1, - './fa/fab/faba/faba_ord' => 1, './fa/faa' => 1, './fa/faa/faa_ord' => 1, - './fb' => 1, './fb/fba' => 1, './fb/fba/fba_ord' => 1, './fb/fb_ord' => 1); -delete $Expect{'./fa/fsl'} unless $symlink_exists; -%Expect_Dir = ('./fa' => 1, './fa/faa' => 1, '/fa/fab' => 1, './fa/fab/faba' => 1, - './fb' => 1, './fb/fba' => 1); -delete @Expect_Dir{'./fb','./fb/fba'} unless $symlink_exists; -File::Find::finddepth( {wanted => \&d_wanted, no_chdir => 1 },'.' ); -Check( scalar(keys %Expect) == 0 ); - -if ( $symlink_exists ) { - $FastFileTests_OK= 1; - %Expect=('.' => 1, 'fa_ord' => 1, 'fsl' => 1, 'fb_ord' => 1, 'fba' => 1, - 'fba_ord' => 1, 'fab' => 1, 'fab_ord' => 1, 'faba' => 1, 'faa' => 1, - 'faa_ord' => 1); - %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, - 'fb' => 1, 'fb/fba' => 1); - - File::Find::find( {wanted => \&wanted, follow_fast => 1},'fa' ); - Check( scalar(keys %Expect) == 0 ); - - %Expect=('fa' => 1, 'fa/fa_ord' => 1, 'fa/fsl' => 1, 'fa/fsl/fb_ord' => 1, - 'fa/fsl/fba' => 1, 'fa/fsl/fba/fba_ord' => 1, 'fa/fab' => 1, - 'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, 'fa/fab/faba/faba_ord' => 1, - 'fa/faa' => 1, 'fa/faa/faa_ord' => 1); - %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, - 'fb' => 1, 'fb/fba' => 1); - File::Find::find( {wanted => \&wanted, follow_fast => 1, no_chdir => 1},'fa' ); - Check( scalar(keys %Expect) == 0 ); - - %Expect=('fa' => 1, 'fa/fa_ord' => 1, 'fa/fsl' => 1, 'fa/fsl/fb_ord' => 1, - 'fa/fsl/fba' => 1, 'fa/fsl/fba/fba_ord' => 1, 'fa/fab' => 1, - 'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, 'fa/fab/faba/faba_ord' => 1, - 'fa/faa' => 1, 'fa/faa/faa_ord' => 1); - %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, - 'fb' => 1, 'fb/fba' => 1); - - File::Find::finddepth( {wanted => \&dn_wanted, follow_fast => 1},'fa' ); - Check( scalar(keys %Expect) == 0 ); - - %Expect=('fa' => 1, 'fa/fa_ord' => 1, 'fa/fsl' => 1, 'fa/fsl/fb_ord' => 1, - 'fa/fsl/fba' => 1, 'fa/fsl/fba/fba_ord' => 1, 'fa/fab' => 1, - 'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, 'fa/fab/faba/faba_ord' => 1, - 'fa/faa' => 1, 'fa/faa/faa_ord' => 1); - %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, - 'fb' => 1, 'fb/fba' => 1); - - File::Find::finddepth( {wanted => \&d_wanted, follow_fast => 1, no_chdir => 1},'fa' ); - Check( scalar(keys %Expect) == 0 ); - - # Verify that File::Find::find will call wanted even if the topdir of - # is a symlink to a directory, and it shouldn't follow the link - # unless follow is set, which it isn't in this case - %Expect = ('fsl' => 1); - %Expect_Dir = (); - File::Find::find( {wanted => \&wanted, },'fa/fsl' ); - Check( scalar(keys %Expect) == 0 ); +sub simple_wanted { + print "# \$File::Find::dir => '$File::Find::dir'\n"; + print "# \$_ => '$_'\n"; +} + +sub noop_wanted {} +sub my_preprocess { + @files = @_; + print "# --PREPROCESS--\n"; + print "# \$File::Find::dir => '$File::Find::dir' \n"; + foreach $file (@files) { + print "# $file \n"; + delete $Expect{$File::Find::dir}->{$file}; + } + print "# --END PREPROCESS--\n"; + Check(scalar(keys %{$Expect{$File::Find::dir}}) == 0); + if (scalar(keys %{$Expect{$File::Find::dir}}) == 0) { + delete $Expect{$File::Find::dir} + } + return @files; +} + +sub my_postprocess { + print "# POSTPROCESS: \$File::Find::dir => '$File::Find::dir' \n"; + delete $Expect{$File::Find::dir}; +} + + +if ($^O eq 'MacOS') { + + MkDir( 'for_find',0770 ); + CheckDie(chdir(for_find)); + + $cwd = cwd(); # save cwd + ( $cwd_untainted ) = $cwd =~ m|^(.+)$|; # untaint it + + MkDir( 'fa',0770 ); + MkDir( 'fb',0770 ); + touch(':fb:fb_ord'); + MkDir( ':fb:fba',0770 ); + touch(':fb:fba:fba_ord'); + CheckDie( symlink(':fb',':fa:fsl') ) if $symlink_exists; + touch(':fa:fa_ord'); + + MkDir( ':fa:faa',0770 ); + touch(':fa:faa:faa_ord'); + MkDir( ':fa:fab',0770 ); + touch(':fa:fab:fab_ord'); + MkDir( ':fa:fab:faba',0770 ); + touch(':fa:fab:faba:faba_ord'); + + %Expect = (':' => 1, 'fsl' => 1, 'fa_ord' => 1, 'fab' => 1, 'fab_ord' => 1, + 'faba' => 1, 'faa' => 1, 'faa_ord' => 1); + delete $Expect{'fsl'} unless $symlink_exists; + %Expect_Dir = (':' => 1, 'fa' => 1, 'faa' => 1, 'fab' => 1, 'faba' => 1, + 'fb' => 1, 'fba' => 1); + delete @Expect_Dir{'fb','fba'} unless $symlink_exists; + File::Find::find( {wanted => \&wanted, untaint => 1},':fa' ); + Check( scalar(keys %Expect) == 0 ); + + %Expect=(':fa' => 1, ':fa:fsl' => 1, ':fa:fa_ord' => 1, ':fa:fab' => 1, + ':fa:fab:fab_ord' => 1, ':fa:fab:faba' => 1, + ':fa:fab:faba:faba_ord' => 1, ':fa:faa' => 1, ':fa:faa:faa_ord' => 1); + delete $Expect{':fa:fsl'} unless $symlink_exists; + %Expect_Dir = (':fa' => 1, ':fa:faa' => 1, ':fa:fab' => 1, ':fa:fab:faba' => 1, + ':fb' => 1, ':fb:fba' => 1); + delete @Expect_Dir{':fb',':fb:fba'} unless $symlink_exists; + File::Find::find( {wanted => \&wanted, no_chdir => 1, untaint => 1},':fa' ); + Check( scalar(keys %Expect) == 0 ); + + %Expect=(':' => 1, ':fa' => 1, ':fa:fsl' => 1, ':fa:fa_ord' => 1, ':fa:fab' => 1, + ':fa:fab:fab_ord' => 1, ':fa:fab:faba' => 1, + ':fa:fab:faba:faba_ord' => 1, ':fa:faa' => 1, ':fa:faa:faa_ord' => 1, + ':fb' => 1, ':fb:fba' => 1, ':fb:fba:fba_ord' => 1, ':fb:fb_ord' => 1); + delete $Expect{':fa:fsl'} unless $symlink_exists; + %Expect_Dir = (':' => 1, ':fa' => 1, ':fa:faa' => 1, ':fa:fab' => 1, ':fa:fab:faba' => 1, + ':fb' => 1, ':fb:fba' => 1); + delete @Expect_Dir{':fb',':fb:fba'} unless $symlink_exists; + File::Find::finddepth( {wanted => \&dn_wanted, untaint => 1 },':' ); + Check( scalar(keys %Expect) == 0 ); + + %Expect=(':' => 1, ':fa' => 1, ':fa:fsl' => 1, ':fa:fa_ord' => 1, ':fa:fab' => 1, + ':fa:fab:fab_ord' => 1, ':fa:fab:faba' => 1, + ':fa:fab:faba:faba_ord' => 1, ':fa:faa' => 1, ':fa:faa:faa_ord' => 1, + ':fb' => 1, ':fb:fba' => 1, ':fb:fba:fba_ord' => 1, ':fb:fb_ord' => 1); + delete $Expect{':fa:fsl'} unless $symlink_exists; + %Expect_Dir = (':' => 1, ':fa' => 1, ':fa:faa' => 1, ':fa:fab' => 1, ':fa:fab:faba' => 1, + ':fb' => 1, ':fb:fba' => 1); + delete @Expect_Dir{':fb',':fb:fba'} unless $symlink_exists; + File::Find::finddepth( {wanted => \&d_wanted, no_chdir => 1, untaint => 1 },':' ); + Check( scalar(keys %Expect) == 0 ); + + # untaint, preprocess and postprocess tests below added by Thomas Wegner, 17-05-2001 + + print "# check untainting (no follow)\n"; + # don't untaint at all + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted},':fa' );}; + print "# Died: $@"; + Check( $@ =~ m|Insecure dependency| ); + chdir($cwd_untainted); + + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, untaint => 1, + untaint_pattern => qr|^(NO_MATCH)$|},':fa' );}; + print "# Died: $@"; + Check( $@ =~ m|is still tainted| ); + chdir($cwd_untainted); + + print "# check untaint_skip (no follow)\n"; + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, untaint => 1, untaint_skip => 1, + untaint_pattern => qr|^(NO_MATCH)$|}, ':fa' );}; + print "# Died: $@"; + Check( $@ =~ m|insecure cwd| ); + chdir($cwd_untainted); + + print "# check preprocess\n"; + %Expect=( + ':' => {fa => 1, fb => 1}, + ':fa:' => {faa => 1, fab => 1, fa_ord => 1}, + ':fa:faa:' => {faa_ord => 1}, + ':fa:fab:' => {faba => 1, fab_ord => 1}, + ':fa:fab:faba:' => {faba_ord => 1}, + ':fb:' => {fba => 1, fb_ord => 1}, + ':fb:fba:' => {fba_ord => 1} + ); + File::Find::find( {wanted => \&noop_wanted, untaint => 1, preprocess => \&my_preprocess}, ':' ); + Check( scalar(keys %Expect) == 0 ); + + print "# check postprocess\n"; + %Expect=(':' => 1, ':fa:' => 1, ':fa:faa:' => 1, ':fa:fab:' => 1, ':fa:fab:faba:' => 1, ':fb:' => 1, + ':fb:fba:' => 1 ); + File::Find::find( {wanted => \&noop_wanted, untaint => 1, postprocess => \&my_postprocess}, ':' ); + Check( scalar(keys %Expect) == 0 ); + + # Verify that File::Find::find will call wanted even if the topdir of + # is a symlink to a directory, and it shouldn't follow the link + # unless follow is set, which it isn't in this case + %Expect = ('fsl' => 1); + %Expect_Dir = (); + File::Find::find( {wanted => \&wanted, untaint => 1},':fa:fsl' ); + Check( scalar(keys %Expect) == 0 ); + + if ( $symlink_exists ) { + $FastFileTests_OK= 1; + %Expect=(':' => 1, 'fa_ord' => 1, 'fsl' => 1, 'fb_ord' => 1, 'fba' => 1, + 'fba_ord' => 1, 'fab' => 1, 'fab_ord' => 1, 'faba' => 1, 'faa' => 1, + 'faa_ord' => 1); + %Expect_Dir = (':' => 1, 'fa' => 1, 'faa' => 1, 'fab' => 1, 'faba' => 1, + 'fb' => 1, 'fba' => 1); + File::Find::find( {wanted => \&wanted, follow_fast => 1, untaint => 1},':fa' ); + Check( scalar(keys %Expect) == 0 ); + + %Expect=(':fa' => 1, ':fa:fa_ord' => 1, ':fa:fsl' => 1, ':fa:fsl:fb_ord' => 1, + ':fa:fsl:fba' => 1, ':fa:fsl:fba:fba_ord' => 1, ':fa:fab' => 1, + ':fa:fab:fab_ord' => 1, ':fa:fab:faba' => 1, ':fa:fab:faba:faba_ord' => 1, + ':fa:faa' => 1, ':fa:faa:faa_ord' => 1); + %Expect_Dir = (':fa' => 1, ':fa:faa' => 1, ':fa:fab' => 1, ':fa:fab:faba' => 1, + ':fb' => 1, ':fb:fba' => 1); + File::Find::find( {wanted => \&wanted, follow_fast => 1, no_chdir => 1, untaint => 1 },':fa' ); + Check( scalar(keys %Expect) == 0 ); + + %Expect=(':fa' => 1, ':fa:fa_ord' => 1, ':fa:fsl' => 1, ':fa:fsl:fb_ord' => 1, + ':fa:fsl:fba' => 1, ':fa:fsl:fba:fba_ord' => 1, ':fa:fab' => 1, + ':fa:fab:fab_ord' => 1, ':fa:fab:faba' => 1, ':fa:fab:faba:faba_ord' => 1, + ':fa:faa' => 1, ':fa:faa:faa_ord' => 1); + %Expect_Dir = (':fa' => 1, ':fa:faa' => 1, ':fa:fab' => 1, ':fa:fab:faba' => 1, + ':fb' => 1, ':fb:fba' => 1); + File::Find::finddepth( {wanted => \&dn_wanted, follow_fast => 1, untaint => 1 },':fa' ); + Check( scalar(keys %Expect) == 0 ); + + %Expect=(':fa' => 1, ':fa:fa_ord' => 1, ':fa:fsl' => 1, ':fa:fsl:fb_ord' => 1, + ':fa:fsl:fba' => 1, ':fa:fsl:fba:fba_ord' => 1, ':fa:fab' => 1, + ':fa:fab:fab_ord' => 1, ':fa:fab:faba' => 1, ':fa:fab:faba:faba_ord' => 1, + ':fa:faa' => 1, ':fa:faa:faa_ord' => 1); + %Expect_Dir = (':fa' => 1, ':fa:faa' => 1, ':fa:fab' => 1, ':fa:fab:faba' => 1, + ':fb' => 1, ':fb:fba' => 1); + File::Find::finddepth( {wanted => \&d_wanted, follow_fast => 1, no_chdir => 1, untaint => 1 },':fa' ); + Check( scalar(keys %Expect) == 0 ); + + # tests below added by Thomas Wegner, 17-05-2001 + + print "# check dangling symbolic links\n"; + MkDir( 'dangling_dir',0770 ); + CheckDie( symlink('dangling_dir','dangling_dir_sl') ); + rmdir 'dangling_dir'; + touch('dangling_file'); + CheckDie( symlink('dangling_file',':fa:dangling_file_sl') ); + unlink 'dangling_file'; + + %Expect=(':' => 1, 'fa_ord' => 1, 'fsl' => 1, 'fb_ord' => 1, 'fba' => 1, + 'fba_ord' => 1, 'fab' => 1, 'fab_ord' => 1, 'faba' => 1, 'faba_ord' => 1, + 'faa' => 1, 'faa_ord' => 1); + %Expect_Dir = (':' => 1, 'fa' => 1, 'faa' => 1, 'fab' => 1, 'faba' => 1, + 'fb' => 1, 'fba' => 1); + undef $warn_msg; + File::Find::find( {wanted => \&d_wanted, follow => 1, untaint => 1 }, 'dangling_dir_sl', ':fa' ); + Check( $warn_msg =~ m|dangling_dir_sl is a dangling symbolic link| ); + unlink ':fa:dangling_file_sl', 'dangling_dir_sl'; + + print "# check recursion\n"; + CheckDie( symlink(':fa:faa',':fa:faa:faa_sl') ); + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, follow => 1, no_chdir => 1, untaint => 1 },':fa' ); }; + print "# Died: $@"; + Check( $@ =~ m|:for_find:fa:faa:faa_sl is a recursive symbolic link| ); + unlink ':fa:faa:faa_sl'; + + print "# check follow_skip (file)\n"; + CheckDie( symlink(':fa:fa_ord',':fa:fa_ord_sl') ); # symlink to a file + undef $@; + eval {File::Find::finddepth( {wanted => \&simple_wanted, follow => 1,follow_skip => 0, + no_chdir => 1, untaint => 1 },':fa' );}; + print "# Died: $@"; + Check( $@ =~ m|:for_find:fa:fa_ord encountered a second time| ); + + %Expect=(':fa' => 1, ':fa:fa_ord' => 1, ':fa:fsl' => 1, ':fa:fsl:fb_ord' => 1, + ':fa:fsl:fba' => 1, ':fa:fsl:fba:fba_ord' => 1, ':fa:fab' => 1, + ':fa:fab:fab_ord' => 1, ':fa:fab:faba' => 1, ':fa:fab:faba:faba_ord' => 1, + ':fa:faa' => 1, ':fa:faa:faa_ord' => 1); + %Expect_Dir = (':fa' => 1, ':fa:faa' => 1, ':fa:fab' => 1, ':fa:fab:faba' => 1, + ':fb' => 1, ':fb:fba' => 1); + File::Find::finddepth( {wanted => \&wanted, follow => 1, follow_skip => 1, no_chdir => 1, + untaint => 1 },':fa' ); + Check( scalar(keys %Expect) == 0 ); + unlink ':fa:fa_ord_sl'; + + print "# check follow_skip (directory)\n"; + CheckDie( symlink(':fa:faa',':fa:faa_sl') ); # symlink to a directory + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, follow => 1, follow_skip => 0, + no_chdir => 1, untaint => 1 },':fa' );}; + print "# Died: $@"; + Check( $@ =~ m|:for_find:fa:faa: encountered a second time| ); + + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, follow => 1, follow_skip => 1, + no_chdir => 1, untaint => 1 },':fa' );}; + print "# Died: $@"; + Check( $@ =~ m|:for_find:fa:faa: encountered a second time| ); + + %Expect=(':fa' => 1, ':fa:fa_ord' => 1, ':fa:fsl' => 1, ':fa:fsl:fb_ord' => 1, + ':fa:fsl:fba' => 1, ':fa:fsl:fba:fba_ord' => 1, ':fa:fab' => 1, + ':fa:fab:fab_ord' => 1, ':fa:fab:faba' => 1, ':fa:fab:faba:faba_ord' => 1, + ':fa:faa' => 1, ':fa:faa:faa_ord' => 1); + %Expect_Dir = (':fa' => 1, ':fa:faa' => 1, ':fa:fab' => 1, ':fa:fab:faba' => 1, + ':fb' => 1, ':fb:fba' => 1); + File::Find::find( {wanted => \&wanted, follow => 1, follow_skip => 2, no_chdir => 1, + untaint => 1},':fa' ); + Check( scalar(keys %Expect) == 0 ); + unlink ':fa:faa_sl'; + + print "# check untainting (follow)\n"; + # don't untaint at all + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, follow => 1},':fa' );}; + print "# Died: $@"; + Check( $@ =~ m|Insecure dependency| ); + chdir($cwd_untainted); + + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, follow => 1, untaint => 1, + untaint_pattern => qr|^(NO_MATCH)$|},':fa' );}; + print "# Died: $@"; + Check( $@ =~ m|is still tainted| ); + chdir($cwd_untainted); + + print "# check untaint_skip (follow)\n"; + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, untaint => 1, untaint_skip => 1, + untaint_pattern => qr|^(NO_MATCH)$|}, ':fa' );}; + print "# Died: $@"; + Check( $@ =~ m|insecure cwd| ); + chdir($cwd_untainted); + + } + +} else { + + MkDir( 'for_find',0770 ); + CheckDie(chdir(for_find)); + + $cwd = cwd(); # save cwd + ( $cwd_untainted ) = $cwd =~ m|^(.+)$|; # untaint it + + MkDir( 'fa',0770 ); + MkDir( 'fb',0770 ); + touch('fb/fb_ord'); + MkDir( 'fb/fba',0770 ); + touch('fb/fba/fba_ord'); + CheckDie( symlink('../fb','fa/fsl') ) if $symlink_exists; + touch('fa/fa_ord'); + + MkDir( 'fa/faa',0770 ); + touch('fa/faa/faa_ord'); + MkDir( 'fa/fab',0770 ); + touch('fa/fab/fab_ord'); + MkDir( 'fa/fab/faba',0770 ); + touch('fa/fab/faba/faba_ord'); + + %Expect = ('.' => 1, 'fsl' => 1, 'fa_ord' => 1, 'fab' => 1, 'fab_ord' => 1, + 'faba' => 1, 'faa' => 1, 'faa_ord' => 1); + delete $Expect{'fsl'} unless $symlink_exists; + %Expect_Dir = ('fa' => 1, 'faa' => 1, 'fab' => 1, 'faba' => 1, + 'fb' => 1, 'fba' => 1); + delete @Expect_Dir{'fb','fba'} unless $symlink_exists; + File::Find::find( {wanted => \&wanted, untaint => 1, untaint_pattern => qr|^(.+)$|},'fa' ); + Check( scalar(keys %Expect) == 0 ); + + %Expect=('fa' => 1, 'fa/fsl' => 1, 'fa/fa_ord' => 1, 'fa/fab' => 1, + 'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, + 'fa/fab/faba/faba_ord' => 1, 'fa/faa' => 1, 'fa/faa/faa_ord' => 1); + delete $Expect{'fa/fsl'} unless $symlink_exists; + %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, + 'fb' => 1, 'fb/fba' => 1); + delete @Expect_Dir{'fb','fb/fba'} unless $symlink_exists; + File::Find::find( {wanted => \&wanted, no_chdir => 1, untaint => 1, untaint_pattern => qr|^(.+)$|},'fa' ); + Check( scalar(keys %Expect) == 0 ); + + %Expect=('.' => 1, './fa' => 1, './fa/fsl' => 1, './fa/fa_ord' => 1, './fa/fab' => 1, + './fa/fab/fab_ord' => 1, './fa/fab/faba' => 1, + './fa/fab/faba/faba_ord' => 1, './fa/faa' => 1, './fa/faa/faa_ord' => 1, + './fb' => 1, './fb/fba' => 1, './fb/fba/fba_ord' => 1, './fb/fb_ord' => 1); + delete $Expect{'./fa/fsl'} unless $symlink_exists; + %Expect_Dir = ('./fa' => 1, './fa/faa' => 1, '/fa/fab' => 1, './fa/fab/faba' => 1, + './fb' => 1, './fb/fba' => 1); + delete @Expect_Dir{'./fb','./fb/fba'} unless $symlink_exists; + File::Find::finddepth( {wanted => \&dn_wanted , untaint => 1, untaint_pattern => qr|^(.+)$|},'.' ); + Check( scalar(keys %Expect) == 0 ); + + %Expect=('.' => 1, './fa' => 1, './fa/fsl' => 1, './fa/fa_ord' => 1, './fa/fab' => 1, + './fa/fab/fab_ord' => 1, './fa/fab/faba' => 1, + './fa/fab/faba/faba_ord' => 1, './fa/faa' => 1, './fa/faa/faa_ord' => 1, + './fb' => 1, './fb/fba' => 1, './fb/fba/fba_ord' => 1, './fb/fb_ord' => 1); + delete $Expect{'./fa/fsl'} unless $symlink_exists; + %Expect_Dir = ('./fa' => 1, './fa/faa' => 1, '/fa/fab' => 1, './fa/fab/faba' => 1, + './fb' => 1, './fb/fba' => 1); + delete @Expect_Dir{'./fb','./fb/fba'} unless $symlink_exists; + File::Find::finddepth( {wanted => \&d_wanted, no_chdir => 1, untaint => 1, untaint_pattern => qr|^(.+)$| },'.' ); + Check( scalar(keys %Expect) == 0 ); + + # untaint, preprocess and postprocess tests below added by Thomas Wegner, 17-05-2001 + + print "# check untainting (no follow)\n"; + # don't untaint at all + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted},'fa' );}; + print "# Died: $@"; + Check( $@ =~ m|Insecure dependency| ); + chdir($cwd_untainted); + + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, untaint => 1, + untaint_pattern => qr|^(NO_MATCH)$|},'fa' );}; + print "# Died: $@"; + Check( $@ =~ m|is still tainted| ); + chdir($cwd_untainted); + + print "# check untaint_skip (no follow)\n"; + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, untaint => 1, untaint_skip => 1, + untaint_pattern => qr|^(NO_MATCH)$|}, 'fa' );}; + print "# Died: $@"; + Check( $@ =~ m|insecure cwd| ); + chdir($cwd_untainted); + + print "# check preprocess\n"; + %Expect=( + '.' => {fa => 1, fb => 1}, + './fa' => {faa => 1, fab => 1, fa_ord => 1}, + './fa/faa' => {faa_ord => 1}, + './fa/fab' => {faba => 1, fab_ord => 1}, + './fa/fab/faba' => {faba_ord => 1}, + './fb' => {fba => 1, fb_ord => 1}, + './fb/fba' => {fba_ord => 1} + ); + + File::Find::find( {wanted => \&noop_wanted, preprocess => \&my_preprocess, untaint => 1, + untaint_pattern => qr|^(.+)$|}, '.' ); + Check( scalar(keys %Expect) == 0 ); + + print "# check postprocess\n"; + %Expect=('.' => 1, './fa' => 1, './fa/faa' => 1, './fa/fab' => 1, './fa/fab/faba' => 1, './fb' => 1, + './fb/fba' => 1 ); + File::Find::find( {wanted => \&noop_wanted, postprocess => \&my_postprocess, untaint => 1, + untaint_pattern => qr|^(.+)$|}, '.' ); + Check( scalar(keys %Expect) == 0 ); + + # Verify that File::Find::find will call wanted even if the topdir of + # is a symlink to a directory, and it shouldn't follow the link + # unless follow is set, which it isn't in this case + %Expect = ('fsl' => 1); + %Expect_Dir = (); + File::Find::find( {wanted => \&wanted, untaint => 1},'fa/fsl' ); + Check( scalar(keys %Expect) == 0 ); + + if ( $symlink_exists ) { + $FastFileTests_OK= 1; + %Expect=('.' => 1, 'fa_ord' => 1, 'fsl' => 1, 'fb_ord' => 1, 'fba' => 1, + 'fba_ord' => 1, 'fab' => 1, 'fab_ord' => 1, 'faba' => 1, 'faa' => 1, + 'faa_ord' => 1); + %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, + 'fb' => 1, 'fb/fba' => 1); + File::Find::find( {wanted => \&wanted, follow_fast => 1, untaint => 1, untaint_pattern => qr|^(.+)$|},'fa' ); + Check( scalar(keys %Expect) == 0 ); + + %Expect=('fa' => 1, 'fa/fa_ord' => 1, 'fa/fsl' => 1, 'fa/fsl/fb_ord' => 1, + 'fa/fsl/fba' => 1, 'fa/fsl/fba/fba_ord' => 1, 'fa/fab' => 1, + 'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, 'fa/fab/faba/faba_ord' => 1, + 'fa/faa' => 1, 'fa/faa/faa_ord' => 1); + %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, + 'fb' => 1, 'fb/fba' => 1); + File::Find::find( {wanted => \&wanted, follow_fast => 1, no_chdir => 1, untaint => 1, + untaint_pattern => qr|^(.+)$|},'fa' ); + Check( scalar(keys %Expect) == 0 ); + + %Expect=('fa' => 1, 'fa/fa_ord' => 1, 'fa/fsl' => 1, 'fa/fsl/fb_ord' => 1, + 'fa/fsl/fba' => 1, 'fa/fsl/fba/fba_ord' => 1, 'fa/fab' => 1, + 'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, 'fa/fab/faba/faba_ord' => 1, + 'fa/faa' => 1, 'fa/faa/faa_ord' => 1); + %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, + 'fb' => 1, 'fb/fba' => 1); + File::Find::finddepth( {wanted => \&dn_wanted, follow_fast => 1, untaint => 1, + untaint_pattern => qr|^(.+)$|},'fa' ); + Check( scalar(keys %Expect) == 0 ); + + %Expect=('fa' => 1, 'fa/fa_ord' => 1, 'fa/fsl' => 1, 'fa/fsl/fb_ord' => 1, + 'fa/fsl/fba' => 1, 'fa/fsl/fba/fba_ord' => 1, 'fa/fab' => 1, + 'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, 'fa/fab/faba/faba_ord' => 1, + 'fa/faa' => 1, 'fa/faa/faa_ord' => 1); + %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, + 'fb' => 1, 'fb/fba' => 1); + File::Find::finddepth( {wanted => \&d_wanted, follow_fast => 1, no_chdir => 1, + untaint => 1, untaint_pattern => qr|^(.+)$|},'fa' ); + Check( scalar(keys %Expect) == 0 ); + + # tests below added by Thomas Wegner, 17-05-2001 + + print "# check dangling symbolic links\n"; + MkDir( 'dangling_dir',0770 ); + CheckDie( symlink('dangling_dir','dangling_dir_sl') ); + rmdir 'dangling_dir'; + touch('dangling_file'); + CheckDie( symlink('../dangling_file','fa/dangling_file_sl') ); + unlink 'dangling_file'; + + %Expect=('.' => 1, 'fa_ord' => 1, 'fsl' => 1, 'fb_ord' => 1, 'fba' => 1, + 'fba_ord' => 1, 'fab' => 1, 'fab_ord' => 1, 'faba' => 1, 'faba_ord' => 1, + 'faa' => 1, 'faa_ord' => 1); + %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, 'fa/fab' => 1, 'fa/fab/faba' => 1, + 'fb' => 1, 'fb/fba' => 1); + undef $warn_msg; + File::Find::find( {wanted => \&d_wanted, follow => 1, untaint => 1, + untaint_pattern => qr|^(.+)$|}, 'dangling_dir_sl', 'fa' ); + Check( $warn_msg =~ m|dangling_dir_sl is a dangling symbolic link| ); + unlink 'fa/dangling_file_sl', 'dangling_dir_sl'; + + print "# check recursion\n"; + CheckDie( symlink('../faa','fa/faa/faa_sl') ); + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, follow => 1, no_chdir => 1, + untaint => 1, untaint_pattern => qr|^(.+)$|},'fa' ); }; + print "# Died: $@"; + Check( $@ =~ m|for_find/fa/faa/faa_sl is a recursive symbolic link| ); + unlink 'fa/faa/faa_sl'; + + print "# check follow_skip (file)\n"; + CheckDie( symlink('./fa_ord','fa/fa_ord_sl') ); # symlink to a file + undef $@; + eval {File::Find::finddepth( {wanted => \&simple_wanted, follow => 1, follow_skip => 0, no_chdir => 1, + untaint => 1, untaint_pattern => qr|^(.+)$|},'fa' );}; + print "# Died: $@"; + Check( $@ =~ m|for_find/fa/fa_ord encountered a second time| ); + + %Expect=('fa' => 1, 'fa/fa_ord' => 1, 'fa/fsl' => 1, 'fa/fsl/fb_ord' => 1, + 'fa/fsl/fba' => 1, 'fa/fsl/fba/fba_ord' => 1, 'fa/fab' => 1, + 'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, 'fa/fab/faba/faba_ord' => 1, + 'fa/faa' => 1, 'fa/faa/faa_ord' => 1); + %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, + 'fb' => 1, 'fb/fba' => 1); + File::Find::finddepth( {wanted => \&wanted, follow => 1, follow_skip => 1, no_chdir => 1, + untaint => 1, untaint_pattern => qr|^(.+)$|},'fa' ); + Check( scalar(keys %Expect) == 0 ); + unlink 'fa/fa_ord_sl'; + + print "# check follow_skip (directory)\n"; + CheckDie( symlink('./faa','fa/faa_sl') ); # symlink to a directory + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, follow => 1, follow_skip => 0, no_chdir => 1, + untaint => 1, untaint_pattern => qr|^(.+)$|},'fa' );}; + print "# Died: $@"; + Check( $@ =~ m|for_find/fa/faa encountered a second time| ); + + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, follow => 1, follow_skip => 1, no_chdir => 1, + untaint => 1, untaint_pattern => qr|^(.+)$|},'fa' );}; + print "# Died: $@"; + Check( $@ =~ m|for_find/fa/faa encountered a second time| ); + + %Expect=('fa' => 1, 'fa/fa_ord' => 1, 'fa/fsl' => 1, 'fa/fsl/fb_ord' => 1, + 'fa/fsl/fba' => 1, 'fa/fsl/fba/fba_ord' => 1, 'fa/fab' => 1, + 'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, 'fa/fab/faba/faba_ord' => 1, + 'fa/faa' => 1, 'fa/faa/faa_ord' => 1); + %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, + 'fb' => 1, 'fb/fba' => 1); + File::Find::find( {wanted => \&wanted, follow => 1, follow_skip => 2, no_chdir => 1, + untaint => 1, untaint_pattern => qr|^(.+)$|},'fa' ); + Check( scalar(keys %Expect) == 0 ); + unlink 'fa/faa_sl'; + + print "# check untainting (follow)\n"; + # don't untaint at all + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, follow => 1},'fa' );}; + print "# Died: $@"; + Check( $@ =~ m|Insecure dependency| ); + chdir($cwd_untainted); + + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, follow => 1, untaint => 1, + untaint_pattern => qr|^(NO_MATCH)$|},'fa' );}; + print "# Died: $@"; + Check( $@ =~ m|is still tainted| ); + chdir($cwd_untainted); + + print "# check untaint_skip (follow)\n"; + undef $@; + eval {File::Find::find( {wanted => \&simple_wanted, untaint => 1, untaint_skip => 1, + untaint_pattern => qr|^(NO_MATCH)$|}, 'fa' );}; + print "# Died: $@"; + Check( $@ =~ m|insecure cwd| ); + chdir($cwd_untainted); + + } } print "# of cases: $case\n"; diff --git a/t/lib/io_dir.t b/t/lib/io_dir.t index 3689871555..6ec4e9f232 100755 --- a/t/lib/io_dir.t +++ b/t/lib/io_dir.t @@ -19,7 +19,9 @@ use IO::Dir qw(DIR_UNLINK); print "1..10\n"; -$dot = new IO::Dir "."; +my $DIR = $^O eq 'MacOS' ? ":" : "."; + +$dot = new IO::Dir $DIR; print defined($dot) ? "ok" : "not ok", " 1\n"; @a = sort <*>; @@ -41,7 +43,7 @@ open(FH,'>X') || die "Can't create x"; print FH "X"; close(FH); -tie %dir, IO::Dir, "."; +tie %dir, IO::Dir, $DIR; my @files = keys %dir; # I hope we do not have an empty dir :-) @@ -55,7 +57,7 @@ delete $dir{'X'}; print -f 'X' ? "ok" : "not ok", " 8\n"; -tie %dirx, IO::Dir, ".", DIR_UNLINK; +tie %dirx, IO::Dir, $DIR, DIR_UNLINK; my $statx = $dirx{'X'}; print defined($statx) && UNIVERSAL::isa($statx,'File::stat') && $statx->size == 1 diff --git a/t/lib/selfloader.t b/t/lib/selfloader.t index 6b9c244b7e..6987f6592b 100755 --- a/t/lib/selfloader.t +++ b/t/lib/selfloader.t @@ -3,6 +3,13 @@ BEGIN { chdir 't' if -d 't'; $dir = "self-$$"; + $sep = "/"; + + if ($^O eq 'MacOS') { + $dir = ":" . $dir; + $sep = ":"; + } + @INC = $dir; push @INC, '../lib'; @@ -11,7 +18,7 @@ BEGIN { # First we must set up some selfloader files mkdir $dir, 0755 or die "Can't mkdir $dir: $!"; - open(FOO, ">$dir/Foo.pm") or die; + open(FOO, ">$dir${sep}Foo.pm") or die; print FOO <<'EOT'; package Foo; use SelfLoader; @@ -40,7 +47,7 @@ EOT close(FOO); - open(BAR, ">$dir/Bar.pm") or die; + open(BAR, ">$dir${sep}Bar.pm") or die; print BAR <<'EOT'; package Bar; use SelfLoader; @@ -196,6 +203,6 @@ if ($bardata ne "sub never { die \"D'oh\" }\n") { # cleanup END { return unless $dir && -d $dir; -unlink "$dir/Foo.pm", "$dir/Bar.pm"; +unlink "$dir${sep}Foo.pm", "$dir${sep}Bar.pm"; rmdir "$dir"; } diff --git a/t/op/anonsub.t b/t/op/anonsub.t index 17889d9d2f..aa25de0131 100755 --- a/t/op/anonsub.t +++ b/t/op/anonsub.t @@ -4,6 +4,7 @@ chdir 't' if -d 't'; @INC = '../lib'; $Is_VMS = $^O eq 'VMS'; $Is_MSWin32 = $^O eq 'MSWin32'; +$Is_MacOS = $^O eq 'MacOS'; $ENV{PERL5LIB} = "../lib" unless $Is_VMS; $|=1; @@ -26,10 +27,12 @@ for (@prgs){ print TEST "$prog\n"; close TEST; my $results = $Is_VMS ? - `MCR $^X "-I[-.lib]" $switch $tmpfile 2>&1` : - $Is_MSWin32 ? - `.\\perl -I../lib $switch $tmpfile 2>&1` : - `./perl $switch $tmpfile 2>&1`; + `MCR $^X "-I[-.lib]" $switch $tmpfile 2>&1` : + $Is_MSWin32 ? + `.\\perl -I../lib $switch $tmpfile 2>&1` : + $Is_MacOS ? + `$^X -I::lib $switch $tmpfile` : + `./perl $switch $tmpfile 2>&1`; my $status = $?; $results =~ s/\n+$//; # allow expected output to be written as if $prog is on STDIN diff --git a/t/op/closure.t b/t/op/closure.t index 5f3245fbc9..633428607e 100755 --- a/t/op/closure.t +++ b/t/op/closure.t @@ -465,6 +465,7 @@ END open CMD, ">$cmdfile"; print CMD $code; close CMD; my $cmd = (($^O eq 'VMS') ? "MCR $^X" : ($^O eq 'MSWin32') ? '.\perl' + : ($^O eq 'MacOS') ? $^X : './perl'); $cmd .= " -w $cmdfile 2>$errfile"; if ($^O eq 'VMS' or $^O eq 'MSWin32') { diff --git a/t/op/defins.t b/t/op/defins.t index 33c74ea28e..06d48b601b 100755 --- a/t/op/defins.t +++ b/t/op/defins.t @@ -12,16 +12,17 @@ BEGIN { } $wanted_filename = $^O eq 'VMS' ? '0.' : '0'; +$saved_filename = $^O eq 'MacOS' ? ':0' : './0'; print "not " if $warns; print "ok 1\n"; -open(FILE,">./0"); +open(FILE,">$saved_filename"); print FILE "1\n"; print FILE "0"; close(FILE); -open(FILE,"<./0"); +open(FILE,"<$saved_filename"); my $seen = 0; my $dummy; while (my $name = <FILE>) @@ -63,7 +64,7 @@ print "not " unless $seen; print "ok 5\n"; close FILE; -opendir(DIR,'.'); +opendir(DIR,($^O eq 'MacOS' ? ':' : '.')); $seen = 0; while (my $name = readdir(DIR)) { @@ -116,7 +117,7 @@ while ($where{$seen} = glob('*')) print "not " unless $seen; print "ok 11\n"; -unlink("./0"); +unlink($saved_filename); my %hash = (0 => 1, 1 => 2); diff --git a/t/op/exec.t b/t/op/exec.t index 23e9ec1cec..57a114e766 100755 --- a/t/op/exec.t +++ b/t/op/exec.t @@ -11,6 +11,12 @@ if ($^O eq 'MSWin32') { exit(0); } +if ($^O eq 'MacOS') { + # XXX the system tests could be written to use ./perl and so work on Win32 + print "1..0 # Mostly useless tests for Mac OS\n"; + exit(0); +} + print "1..8\n"; if ($^O ne 'os2') { diff --git a/t/op/glob.t b/t/op/glob.t index 98efc3d65a..2eb371ae35 100755 --- a/t/op/glob.t +++ b/t/op/glob.t @@ -5,7 +5,7 @@ BEGIN { @INC = '../lib'; } -print "1..7\n"; +print "1..10\n"; @oops = @ops = <op/*>; @@ -48,3 +48,11 @@ for (1..2) { ++$i; } print $i == 2 ? "ok 7\n" : "not ok 7\n"; + +# [ID 20010526.001] localized glob loses value when assigned to + +$j=1; %j=(a=>1); @j=(1); local *j=*j; *j = sub{}; + +print $j == 1 ? "ok 8\n" : "not ok 8\n"; +print $j{a} == 1 ? "ok 9\n" : "not ok 9\n"; +print $j[0] == 1 ? "ok 10\n" : "not ok 10\n"; diff --git a/t/op/goto.t b/t/op/goto.t index b2e5b2ca98..579e8180e4 100755 --- a/t/op/goto.t +++ b/t/op/goto.t @@ -29,7 +29,7 @@ label4: print "#2\t:$foo: == 4\n"; if ($foo == 4) {print "ok 2\n";} else {print "not ok 2\n";} -$PERL = ($^O eq 'MSWin32') ? '.\perl' : './perl'; +$PERL = ($^O eq 'MSWin32') ? '.\perl' : ($^O eq 'MacOS') ? $^X : './perl'; $CMD = qq[$PERL -e "goto foo;" 2>&1 ]; $x = `$CMD`; diff --git a/t/op/magic.t b/t/op/magic.t index d71d6b299c..c8b2d1c7bf 100755 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -27,7 +27,7 @@ $Is_os2 = $^O eq 'os2'; $Is_Cygwin = $^O eq 'cygwin'; $PERL = ($Is_MSWin32 ? '.\perl' : './perl'); -print "1..38\n"; +print "1..41\n"; eval '$ENV{"FOO"} = "hi there";'; # check that ENV is inited inside eval if ($Is_MSWin32) { ok 1, `cmd /x /c set FOO` eq "FOO=hi there\n"; } @@ -247,3 +247,7 @@ delete $INC{"Errno.pm"}; open(FOO, "nonesuch"); # Generate ENOENT my %errs = %{"!"}; # Cause Errno.pm to be loaded at run-time ok 38, ${"!"}{ENOENT}; + +ok 39, $^S == 0; +eval { ok 40, $^S == 1 }; +ok 41, $^S == 0; diff --git a/t/op/pack.t b/t/op/pack.t index 5323bc34b8..f9b35ae35a 100755 --- a/t/op/pack.t +++ b/t/op/pack.t @@ -43,7 +43,7 @@ $sum = 103 if ($Config{ebcdic} eq 'define'); print +($x = unpack("%32B*", "Now is the time for all good blurfl")) == $sum ? "ok 7\n" : "not ok 7 $x\n"; -open(BIN, "./perl") || open(BIN, "./perl.exe") +open(BIN, "./perl") || open(BIN, "./perl.exe") || open(BIN, $^X) || die "Can't open ../perl or ../perl.exe: $!\n"; sysread BIN, $foo, 8192; close BIN; diff --git a/t/op/regexp.t b/t/op/regexp.t index 0751559964..6d33580b30 100755 --- a/t/op/regexp.t +++ b/t/op/regexp.t @@ -38,7 +38,7 @@ BEGIN { $iters = shift || 1; # Poor man performance suite, 10000 is OK. -open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests') || +open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests') || open(TESTS,':op:re_tests') || die "Can't open re_tests"; while (<TESTS>) { } diff --git a/t/op/regexp_noamp.t b/t/op/regexp_noamp.t index 088bd40264..8a6dd28206 100755 --- a/t/op/regexp_noamp.t +++ b/t/op/regexp_noamp.t @@ -1,10 +1,10 @@ #!./perl $skip_amp = 1; -for $file ('op/regexp.t', 't/op/regexp.t') { +for $file ('./op/regexp.t', './t/op/regexp.t', ':op:regexp.t') { if (-r $file) { - do "./$file"; + do $file; exit; } } -die "Cannot find op/regexp.t or t/op/regexp.t\n"; +die "Cannot find ./op/regexp.t or ./t/op/regexp.t\n"; diff --git a/t/op/split.t b/t/op/split.t index 3077909c92..4e3e546c18 100755 --- a/t/op/split.t +++ b/t/op/split.t @@ -52,6 +52,7 @@ print $_ eq '1:2:3:4:5:6:::' ? "ok 10\n" : "not ok 10 $_\n"; # Does assignment to a list imply split to one more field than that? if ($^O eq 'MSWin32') { $foo = `.\\perl -D1024 -e "(\$a,\$b) = split;" 2>&1` } elsif ($^O eq 'VMS') { $foo = `./perl "-D1024" -e "(\$a,\$b) = split;" 2>&1` } +elsif ($^O eq 'MacOS'){ $foo = `$^X "-D1024" -e "(\$a,\$b) = split;"` } else { $foo = `./perl -D1024 -e '(\$a,\$b) = split;' 2>&1` } print $foo =~ /DEBUGGING/ || $foo =~ /SV = (VOID|IV\(3\))/ ? "ok 11\n" : "not ok 11\n"; diff --git a/t/op/write.t b/t/op/write.t index e5baaa470c..8e4cca8fdc 100755 --- a/t/op/write.t +++ b/t/op/write.t @@ -7,7 +7,8 @@ BEGIN { print "1..44\n"; -my $CAT = ($^O eq 'MSWin32') ? 'type' : 'cat'; +my $CAT = ($^O eq 'MSWin32') ? 'type' + : ($^O eq 'MacOS') ? 'catenate' : 'cat'; format OUT = the quick brown @<< diff --git a/t/pragma/strict.t b/t/pragma/strict.t index 5b245d0ab4..bbfb8ab1f1 100755 --- a/t/pragma/strict.t +++ b/t/pragma/strict.t @@ -17,7 +17,7 @@ END { if ($tmpfile) { 1 while unlink $tmpfile; } } my @prgs = () ; -foreach (sort glob("pragma/strict-*")) { +foreach (sort glob($^O eq 'MacOS' ? ":pragma:strict-*" : "pragma/strict-*")) { next if /(~|\.orig|,v)$/; @@ -54,6 +54,7 @@ for (@prgs){ while (@files > 2) { my $filename = shift @files ; my $code = shift @files ; + $code =~ s|\./abc|:abc|g if $^O eq 'MacOS'; push @temps, $filename ; open F, ">$filename" or die "Cannot open $filename: $!\n" ; print F $code ; @@ -61,12 +62,15 @@ for (@prgs){ } shift @files ; $prog = shift @files ; + $prog =~ s|\./abc|:abc|g if $^O eq 'MacOS'; } open TEST, ">$tmpfile"; print TEST $prog,"\n"; close TEST; my $results = $Is_MSWin32 ? `.\\perl -I../lib $switch $tmpfile 2>&1` : + $^O eq 'MacOS' ? + `$^X -I::lib $switch $tmpfile` : `./perl $switch $tmpfile 2>&1`; my $status = $?; $results =~ s/\n+$//; @@ -74,6 +78,8 @@ for (@prgs){ $results =~ s/tmp\d+/-/g; $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg $expected =~ s/\n+$//; + $expected =~ s|(\./)?abc\.pm|:abc.pm|g if $^O eq 'MacOS'; + $expected =~ s|./abc|:abc|g if $^O eq 'MacOS'; my $prefix = ($results =~ s/^PREFIX\n//) ; if ( $results =~ s/^SKIPPED\n//) { print "$results\n" ; |