This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Under minitest, tests requiring File::Spec->devnull(), as it may not be built.
authorNicholas Clark <nick@ccl4.org>
Sun, 6 Mar 2011 17:38:36 +0000 (17:38 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 6 Mar 2011 20:39:56 +0000 (20:39 +0000)
Although File::Spec is pure Perl, it is part of the Cwd distribution, and
that isn't built for minitest. So we can't rely on it.

t/io/argv.t

index 8356938..95e962d 100644 (file)
@@ -9,9 +9,14 @@ BEGIN { require "./test.pl"; }
 
 plan(tests => 23);
 
-use File::Spec;
+my ($devnull, $no_devnull);
 
-my $devnull = File::Spec->devnull;
+if (is_miniperl()) {
+    $no_devnull = "no dynamic loading on miniperl, File::Spec not built, so can't determine /dev/null";
+} else {
+    require File::Spec;
+    $devnull = File::Spec->devnull;
+}
 
 open(TRY, '>Io_argv1.tmp') || (die "Can't open temp file: $!");
 print TRY "a line\n";
@@ -45,7 +50,8 @@ is($x, "1a line\n2a line\n", '<> from two files');
     is( 0+$?, 0, q(eof() doesn't segfault) );
 }
 
-@ARGV = ('Io_argv1.tmp', 'Io_argv1.tmp', $devnull, 'Io_argv1.tmp');
+@ARGV = is_miniperl() ? ('Io_argv1.tmp', 'Io_argv1.tmp', 'Io_argv1.tmp')
+    : ('Io_argv1.tmp', 'Io_argv1.tmp', $devnull, 'Io_argv1.tmp');
 while (<>) {
     $y .= $. . $_;
     if (eof()) {
@@ -90,35 +96,40 @@ ok( !eof(),     'STDIN has something' );
 
 is( <>, "ok 7\n" );
 
-open STDIN, $devnull or die $!;
-@ARGV = ();
-ok( eof(),      'eof() true with empty @ARGV' );
+SKIP: {
+    skip_if_miniperl($no_devnull, 4);
+    open STDIN, $devnull or die $!;
+    @ARGV = ();
+    ok( eof(),      'eof() true with empty @ARGV' );
 
-@ARGV = ('Io_argv1.tmp');
-ok( !eof() );
+    @ARGV = ('Io_argv1.tmp');
+    ok( !eof() );
 
-@ARGV = ($devnull, $devnull);
-ok( !eof() );
+    @ARGV = ($devnull, $devnull);
+    ok( !eof() );
 
-close ARGV or die $!;
-ok( eof(),      'eof() true after closing ARGV' );
+    close ARGV or die $!;
+    ok( eof(),      'eof() true after closing ARGV' );
+}
 
-{
+SKIP: {
     local $/;
-    open F, 'Io_argv1.tmp' or die "Could not open Io_argv1.tmp: $!";
-    <F>;       # set $. = 1
-    is( <F>, undef );
+    open my $fh, 'Io_argv1.tmp' or die "Could not open Io_argv1.tmp: $!";
+    <$fh>;     # set $. = 1
+    is( <$fh>, undef );
+
+    skip_if_miniperl($no_devnull, 5);
 
-    open F, $devnull or die;
-    ok( defined(<F>) );
+    open $fh, $devnull or die;
+    ok( defined(<$fh>) );
 
-    is( <F>, undef );
-    is( <F>, undef );
+    is( <$fh>, undef );
+    is( <$fh>, undef );
 
-    open F, $devnull or die;   # restart cycle again
-    ok( defined(<F>) );
-    is( <F>, undef );
-    close F or die "Could not close: $!";
+    open $fh, $devnull or die; # restart cycle again
+    ok( defined(<$fh>) );
+    is( <$fh>, undef );
+    close $fh or die "Could not close: $!";
 }
 
 # This used to dump core