From: Nicholas Clark Date: Sun, 6 Mar 2011 18:15:43 +0000 (+0000) Subject: Ensure t/op/stat.t passes under minitest if File::Spec is unavailable. X-Git-Tag: accepted/trunk/20130322.191538~5114 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=563ff921d7b97889a3a611987ca6f2f250c5b876;p=platform%2Fupstream%2Fperl.git Ensure t/op/stat.t passes under minitest if File::Spec is unavailable. 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. --- diff --git a/t/op/stat.t b/t/op/stat.t index 583191c..1808ee4 100644 --- a/t/op/stat.t +++ b/t/op/stat.t @@ -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');