This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Ensure t/op/stat.t passes under minitest if File::Spec is unavailable.
authorNicholas Clark <nick@ccl4.org>
Sun, 6 Mar 2011 18:15:43 +0000 (18:15 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 6 Mar 2011 20:39:57 +0000 (20:39 +0000)
require File::Spec in an eval. For miniperl, if the eval fails, skip tests
relating to File::Spec->devnull() and needing File::Spec->rel2abs(), and assume
that '.' will work as the current directory. Remove a call to catfile() only
needed for MacOS Classic - every other platform will accept Unix-style paths.

t/op/stat.t

index 583191c..1808ee4 100644 (file)
@@ -7,7 +7,18 @@ BEGIN {
 }
 
 use Config;
-use File::Spec;
+
+my ($Null, $Curdir);
+if(eval {require File::Spec; 1}) {
+    $Null = File::Spec->devnull;
+    $Curdir = File::Spec->curdir;
+} else {
+    die $@ unless is_miniperl();
+    $Curdir = '.';
+    diag("miniperl failed to load File::Spec, error is:\n$@");
+    diag("\ncontinuing, assuming '.' for current directory. Some tests will be skipped.");
+}
+
 
 plan tests => 107;
 
@@ -39,9 +50,6 @@ if ($Is_Cygwin) {
 my($DEV, $INO, $MODE, $NLINK, $UID, $GID, $RDEV, $SIZE,
    $ATIME, $MTIME, $CTIME, $BLKSIZE, $BLOCKS) = (0..12);
 
-my $Curdir = File::Spec->curdir;
-
-
 my $tmpfile = tempfile();
 my $tmpfile_link = tempfile();
 
@@ -105,6 +113,7 @@ SKIP: {
     }
 
     SKIP: {
+       skip_if_miniperl("File::Spec not built for minitest", 2);
         my $cwd = File::Spec->rel2abs($Curdir);
         skip "Solaris tmpfs has different mtime/ctime link semantics", 2
                                      if $Is_Solaris and $cwd =~ m#^/tmp# and
@@ -201,8 +210,8 @@ ok(  -f $tmpfile,   '   -f');
 ok(! -d $tmpfile,   '   !-d');
 
 # Is this portable?
-ok(  -d $Curdir,          '-d cwd' );
-ok(! -f $Curdir,          '!-f cwd' );
+ok(  -d '.',          '-d cwd' );
+ok(! -f '.',          '!-f cwd' );
 
 
 SKIP: {
@@ -352,7 +361,6 @@ SKIP: {
     }
 }
 
-my $Null = File::Spec->devnull;
 SKIP: {
     skip "No null device to test with", 1 unless -e $Null;
     skip "We know Win32 thinks '$Null' is a TTY", 1 if $Is_MSWin32;
@@ -364,7 +372,7 @@ SKIP: {
 
 
 # These aren't strictly "stat" calls, but so what?
-my $statfile = File::Spec->catfile($Curdir, 'op', 'stat.t');
+my $statfile = './op/stat.t';
 ok(  -T $statfile,    '-T');
 ok(! -B $statfile,    '!-B');