Integrate from mainperl.
[p5sagit/p5-mst-13.2.git] / t / op / stat.t
index 2207b40..ae627f6 100755 (executable)
@@ -4,7 +4,7 @@
 
 BEGIN {
     chdir 't' if -d 't';
-    @INC = '../lib';
+    unshift @INC, '../lib';
 }
 
 use Config;
@@ -13,7 +13,7 @@ print "1..58\n";
 
 $Is_MSWin32 = $^O eq 'MSWin32';
 $Is_Dos = $^O eq 'dos';
-$Is_Dosish = $Is_Dos || $^O eq 'os2' || $Is_MSWin32;
+$Is_Dosish = $Is_Dos || $^O eq 'os2' || $Is_MSWin32 || $^O =~ /cygwin/;
 chop($cwd = ($Is_MSWin32 ? `cd` : `pwd`));
 
 $DEV = `ls -l /dev` unless $Is_Dosish;
@@ -93,6 +93,9 @@ foreach ((12,13,14,15,16,17)) {
     print "ok $_\n";           #deleted tests
 }
 
+# in ms windows, Op.stat.tmp inherits owner uid from directory
+# not sure about os/2, but chown is harmless anyway
+chown $>,'Op.stat.tmp';
 chmod 0700,'Op.stat.tmp';
 if (-r 'Op.stat.tmp') {print "ok 18\n";} else {print "not ok 18\n";}
 if (-w 'Op.stat.tmp') {print "ok 19\n";} else {print "not ok 19\n";}
@@ -184,14 +187,23 @@ unless($ENV{PERL_SKIP_TTY_TEST}) {
        print "ok 37\n";
     }
     else {
-       unless (open(tty,"/dev/tty")) {
-           print STDERR "Can't open /dev/tty--run t/TEST outside of make.\n";
+       my $TTY = "/dev/tty";
+
+       $TTY = "/dev/ttyp0" if $^O eq 'rhapsody';
+
+       if (defined $TTY) {
+           unless (open(TTY, $TTY)) {
+               print STDERR "Can't open $TTY--run t/TEST outside of make.\n";
+           }
+           if (-t TTY) {print "ok 36\n";} else {print "not ok 36\n";}
+           if (-c TTY) {print "ok 37\n";} else {print "not ok 37\n";}
+           close(TTY);
+       } else { # if some platform completely undefines $TTY
+           print "ok 36 # skipped\n";
+           print "ok 37 # skipped\n";
        }
-       if (-t tty) {print "ok 36\n";} else {print "not ok 36\n";}
-       if (-c tty) {print "ok 37\n";} else {print "not ok 37\n";}
-       close(tty);
     }
-    if (! -t tty) {print "ok 38\n";} else {print "not ok 38\n";}
+    if (! -t TTY) {print "ok 38\n";} else {print "not ok 38\n";}
     if (-t)       {print "ok 39\n";} else {print "not ok 39\n";}
 }
 else {