diff options
Diffstat (limited to 't/op')
-rw-r--r-- | t/op/chdir.t | 13 | ||||
-rwxr-xr-x | t/op/exec.t | 2 | ||||
-rwxr-xr-x | t/op/magic.t | 13 | ||||
-rwxr-xr-x | t/op/read.t | 2 | ||||
-rwxr-xr-x | t/op/readdir.t | 3 | ||||
-rwxr-xr-x | t/op/runlevel.t | 1 | ||||
-rw-r--r-- | t/op/srand.t | 1 | ||||
-rwxr-xr-x | t/op/stat.t | 15 | ||||
-rwxr-xr-x | t/op/study.t | 2 | ||||
-rwxr-xr-x | t/op/subst_wamp.t | 4 | ||||
-rwxr-xr-x | t/op/taint.t | 25 | ||||
-rwxr-xr-x | t/op/write.t | 2 |
12 files changed, 52 insertions, 31 deletions
diff --git a/t/op/chdir.t b/t/op/chdir.t index f9c64a5b84..2932b922ea 100644 --- a/t/op/chdir.t +++ b/t/op/chdir.t @@ -11,7 +11,8 @@ use Config; require "test.pl"; plan(tests => 31); -my $IsVMS = $^O eq 'VMS'; +my $IsVMS = $^O eq 'VMS'; +my $IsMacOS = $^O eq 'MacOS'; # Might be a little early in the testing process to start using these, # but I can't think of a way to write this test without them. @@ -44,7 +45,7 @@ sub check_env { my($key) = @_; # Make sure $ENV{'SYS$LOGIN'} is only honored on VMS. - if( $key eq 'SYS$LOGIN' && !$IsVMS ) { + if( $key eq 'SYS$LOGIN' && !$IsVMS && !$IsMacOS ) { ok( !chdir(), "chdir() on $^O ignores only \$ENV{$key} set" ); is( abs_path, $Cwd, ' abs_path() did not change' ); pass( " no need to test SYS\$LOGIN on $^O" ) for 1..7; @@ -92,8 +93,10 @@ sub clean_env { next if $IsVMS && $env eq 'SYS$LOGIN'; next if $IsVMS && $env eq 'HOME' && !$Config{'d_setenv'}; - # On VMS, %ENV is many layered. - delete $ENV{$env} while exists $ENV{$env}; + unless ($IsMacOS) { # ENV on MacOS is "special" :-) + # On VMS, %ENV is many layered. + delete $ENV{$env} while exists $ENV{$env}; + } } # The following means we won't really be testing for non-existence, @@ -122,7 +125,7 @@ foreach my $key (@magic_envs) { { clean_env; - if ($IsVMS && !$Config{'d_setenv'}) { + if (($IsVMS || $IsMacOS) && !$Config{'d_setenv'}) { pass("Can't reset HOME, so chdir() test meaningless"); } else { ok( !chdir(), 'chdir() w/o any ENV set' ); diff --git a/t/op/exec.t b/t/op/exec.t index a0f361a8e3..3edbc6ac62 100755 --- a/t/op/exec.t +++ b/t/op/exec.t @@ -17,6 +17,8 @@ $ENV{LANGUAGE} = 'C'; # Ditto in GNU. my $Is_VMS = $^O eq 'VMS'; my $Is_Win32 = $^O eq 'MSWin32'; +skip_all("Tests mostly usesless on MacOS") if $^O eq 'MacOS'; + plan(tests => 20); my $Perl = which_perl(); diff --git a/t/op/magic.t b/t/op/magic.t index 0d7857b628..436e253ee2 100755 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -134,10 +134,15 @@ ok((keys %h)[0] eq "foo\034bar", (keys %h)[0]); } # $?, $@, $$ -system qq[$PERL "-I../lib" -e "use vmsish qw(hushed); exit(0)"]; -ok $? == 0, $?; -system qq[$PERL "-I../lib" -e "use vmsish qw(hushed); exit(1)"]; -ok $? != 0, $?; +if ($Is_MacOS) { + skip('$? + system are broken on MacPerl') for 1..2; +} +else { + system qq[$PERL "-I../lib" -e "use vmsish qw(hushed); exit(0)"]; + ok $? == 0, $?; + system qq[$PERL "-I../lib" -e "use vmsish qw(hushed); exit(1)"]; + ok $? != 0, $?; +} eval { die "foo\n" }; ok $@ eq "foo\n", $@; diff --git a/t/op/read.t b/t/op/read.t index 2746970d15..cfa01033e2 100755 --- a/t/op/read.t +++ b/t/op/read.t @@ -5,7 +5,7 @@ print "1..4\n"; -open(FOO,'op/read.t') || open(FOO,'t/op/read.t') || die "Can't open op.read"; +open(FOO,'op/read.t') || open(FOO,'t/op/read.t') || open(FOO,':op:read.t') || die "Can't open op.read"; seek(FOO,4,0); $got = read(FOO,$buf,4); diff --git a/t/op/readdir.t b/t/op/readdir.t index 7cfecdb565..83451d3d68 100755 --- a/t/op/readdir.t +++ b/t/op/readdir.t @@ -33,12 +33,13 @@ else { @R = sort @D; @G = sort <op/*.t>; +@G = sort <:op:*.t> if $^O eq 'MacOS'; if ($G[0] =~ m#.*\](\w+\.t)#i) { # grep is to convert filespecs returned from glob under VMS to format # identical to that returned by readdir @G = grep(s#.*\](\w+\.t).*#op/$1#i,<op/*.t>); } -while (@R && @G && "op/".$R[0] eq $G[0]) { +while (@R && @G && $G[0] eq ($^O eq 'MacOS' ? ':op:' : 'op/').$R[0]) { shift(@R); shift(@G); } diff --git a/t/op/runlevel.t b/t/op/runlevel.t index 1eedda8b09..fffe103836 100755 --- a/t/op/runlevel.t +++ b/t/op/runlevel.t @@ -11,6 +11,7 @@ chdir 't' if -d 't'; $Is_VMS = $^O eq 'VMS'; $Is_MSWin32 = $^O eq 'MSWin32'; $Is_NetWare = $^O eq 'NetWare'; +$Is_MacOS = $^O eq 'MacOS'; $ENV{PERL5LIB} = "../lib" unless $Is_VMS; $|=1; diff --git a/t/op/srand.t b/t/op/srand.t index e809673020..5753a5d0eb 100644 --- a/t/op/srand.t +++ b/t/op/srand.t @@ -53,6 +53,7 @@ ok( !eq_array(\@first_run, \@second_run), # This test checks whether Perl called srand for you. @first_run = `$^X -le "print int rand 100 for 1..100"`; +sleep(1); # in case our srand() is too time-dependent @second_run = `$^X -le "print int rand 100 for 1..100"`; ok( !eq_array(\@first_run, \@second_run), 'srand() called automatically'); diff --git a/t/op/stat.t b/t/op/stat.t index 5b01821524..3cdfc233c9 100755 --- a/t/op/stat.t +++ b/t/op/stat.t @@ -17,6 +17,7 @@ $Is_Amiga = $^O eq 'amigaos'; $Is_Cygwin = $^O eq 'cygwin'; $Is_Darwin = $^O eq 'darwin'; $Is_Dos = $^O eq 'dos'; +$Is_MacOS = $^O eq 'MacOS'; $Is_MPE = $^O eq 'mpeix'; $Is_MSWin32 = $^O eq 'MSWin32'; $Is_NetWare = $^O eq 'NetWare'; @@ -175,7 +176,7 @@ ok(-w $tmpfile, ' -w'); SKIP: { skip "-x simply determins if a file ends in an executable suffix", 1 - if $Is_Dosish; + if $Is_Dosish || $Is_MacOS; ok(-x $tmpfile, ' -x'); } @@ -330,9 +331,9 @@ SKIP: { # These aren't strictly "stat" calls, but so what? - -ok(-T 'op/stat.t', '-T'); -ok(! -B 'op/stat.t', '!-B'); +my $statfile = File::Spec->catfile($Curdir, 'op', 'stat.t'); +ok( -T $statfile, '-T'); +ok(! -B $statfile, '!-B'); SKIP: { skip("DG/UX", 1) if $Is_DGUX; @@ -341,7 +342,7 @@ ok(-B $Perl, '-B'); ok(! -T $Perl, '!-T'); -open(FOO,'op/stat.t'); +open(FOO,$statfile); SKIP: { eval { -T FOO; }; skip "-T/B on filehandle not implemented", 15 if $@ =~ /not implemented/; @@ -357,7 +358,7 @@ SKIP: { ok(! -B FOO, ' still -B'); close(FOO); - open(FOO,'op/stat.t'); + open(FOO,$statfile); $_ = <FOO>; like($_, qr/perl/, 'reopened and after readline'); ok(-T FOO, ' still -T'); @@ -392,7 +393,7 @@ ok(-f(), ' -f() "'); unlink $tmpfile or print "# unlink failed: $!\n"; # bug id 20011101.069 -my @r = \stat("."); +my @r = \stat($Curdir); is(scalar @r, 13, 'stat returns full 13 elements'); SKIP: { diff --git a/t/op/study.t b/t/op/study.t index d90efdc4d2..c93e4f63d2 100755 --- a/t/op/study.t +++ b/t/op/study.t @@ -105,7 +105,7 @@ ok(/^$_$/); $* = 1; # test 3 only tested the optimized version--this one is for real ok("ab\ncd\n" =~ /^cd/); -if ($^O eq 'os390' or $^O eq 'posix-bc') { +if ($^O eq 'os390' or $^O eq 'posix-bc' or $^O eq 'MacOS') { # Even with the alarm() OS/390 and BS2000 can't manage these tests # (Perl just goes into a busy loop, luckily an interruptable one) for (25..26) { print "not ok $_ # TODO compiler bug?\n" } diff --git a/t/op/subst_wamp.t b/t/op/subst_wamp.t index ced5ee9ebb..5e1b826ad4 100755 --- a/t/op/subst_wamp.t +++ b/t/op/subst_wamp.t @@ -1,9 +1,9 @@ #!./perl $dummy = defined $&; # Now we have it... -for $file ('op/subst.t', 't/op/subst.t') { +for $file ('op/subst.t', 't/op/subst.t', ':op:subst.t') { if (-r $file) { - do "./$file"; + do ($^O eq 'MacOS' ? $file : "./$file"); exit; } } diff --git a/t/op/taint.t b/t/op/taint.t index 07b9f48554..bbe643cbd7 100755 --- a/t/op/taint.t +++ b/t/op/taint.t @@ -14,6 +14,7 @@ BEGIN { use strict; use Config; +use File::Spec::Functions; my $test = 177; sub ok ($;$) { @@ -48,6 +49,7 @@ BEGIN { } } +my $Is_MacOS = $^O eq 'MacOS'; my $Is_VMS = $^O eq 'VMS'; my $Is_MSWin32 = $^O eq 'MSWin32'; my $Is_NetWare = $^O eq 'NetWare'; @@ -55,6 +57,7 @@ my $Is_Dos = $^O eq 'dos'; my $Is_Cygwin = $^O eq 'cygwin'; my $Invoke_Perl = $Is_VMS ? 'MCR Sys$Disk:[]Perl.' : ($Is_MSWin32 ? '.\perl' : + $Is_MacOS ? ':perl' : ($Is_NetWare ? 'perl' : './perl')); my @MoreEnv = qw/IFS CDPATH ENV BASH_ENV/; @@ -112,13 +115,15 @@ sub test ($$;$) { } # We need an external program to call. -my $ECHO = ($Is_MSWin32 ? ".\\echo$$" : ($Is_NetWare ? "echo$$" : "./echo$$")); +my $ECHO = ($Is_MSWin32 ? ".\\echo$$" : $Is_MacOS ? ":echo$$" : ($Is_NetWare ? "echo$$" : "./echo$$")); END { unlink $ECHO } open PROG, "> $ECHO" or die "Can't create $ECHO: $!"; print PROG 'print "@ARGV\n"', "\n"; close PROG; my $echo = "$Invoke_Perl $ECHO"; +my $TEST = catfile(curdir(), 'TEST'); + print "1..203\n"; # First, let's make sure that Perl is checking the dangerous @@ -139,7 +144,7 @@ print "1..203\n"; test 1, eval { `$echo 1` } eq "1\n"; - if ($Is_MSWin32 || $Is_NetWare || $Is_VMS || $Is_Dos) { + if ($Is_MSWin32 || $Is_NetWare || $Is_VMS || $Is_Dos || $Is_MacOS) { print "# Environment tainting tests skipped\n"; for (2..5) { print "ok $_\n" } } @@ -255,8 +260,8 @@ print "1..203\n"; # How about command-line arguments? The problem is that we don't # always get some, so we'll run another process with some. -{ - my $arg = "./arg$$"; +SKIP: { + my $arg = catfile(curdir(), "arg$$"); open PROG, "> $arg" or die "Can't create $arg: $!"; print PROG q{ eval { join('', @ARGV), kill 0 }; @@ -272,8 +277,7 @@ print "1..203\n"; # Reading from a file should be tainted { - my $file = './TEST'; - test 32, open(FILE, $file), "Couldn't open '$file': $!"; + test 32, open(FILE, $TEST), "Couldn't open '$TEST': $!"; my $block; sysread(FILE, $block, 100); @@ -606,7 +610,10 @@ else { if ($Config{d_readlink} && $Config{d_symlink}) { my $symlink = "sl$$"; unlink($symlink); - symlink("/something/naughty", $symlink) or die "symlink: $!\n"; + my $sl = "/something/naughty"; + # it has to be a real path on Mac OS + $sl = MacPerl::MakePath((MacPerl::Volumes())[0]) if $Is_MacOS; + symlink($sl, $symlink) or die "symlink: $!\n"; my $readlink = readlink($symlink); test 144, tainted $readlink; unlink($symlink); @@ -720,7 +727,7 @@ else { { # bug id 20001004.006 - open IN, "./TEST" or warn "$0: cannot read ./TEST: $!" ; + open IN, $TEST or warn "$0: cannot read $TEST: $!" ; local $/; my $a = <IN>; my $b = <IN>; @@ -732,7 +739,7 @@ else { { # bug id 20001004.007 - open IN, "./TEST" or warn "$0: cannot read ./TEST: $!" ; + open IN, $TEST or warn "$0: cannot read $TEST: $!" ; my $a = <IN>; my $c = { a => 42, diff --git a/t/op/write.t b/t/op/write.t index e08a64bebf..6af6fcbb95 100755 --- a/t/op/write.t +++ b/t/op/write.t @@ -273,7 +273,7 @@ else # 12..47: scary format testing from Merijn H. Brand -if ($^O eq 'VMS' || $^O eq 'MSWin32' || $^O eq 'dos' || +if ($^O eq 'VMS' || $^O eq 'MSWin32' || $^O eq 'dos' || $^O eq 'MacOS' || ($^O eq 'os2' and not eval '$OS2::can_fork')) { foreach (12..47) { print "ok $_ # skipped: '|-' and '-|' not supported\n"; } exit(0); |