Get mkdir.t working under minitest
authorFather Chrysostomos <sprout@cpan.org>
Tue, 2 Sep 2014 08:05:35 +0000 (01:05 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 3 Sep 2014 03:11:18 +0000 (20:11 -0700)
If things are broken enough that make_ext.pl cannot run, then mini-
test may run this script before Errno.pm is generated and copied
into lib/.

t/op/mkdir.t

index d5c04b3..8096213 100644 (file)
@@ -22,13 +22,25 @@ unless (eval {
 $ENV{'LC_ALL'} = 'C';
 $ENV{LANGUAGE} = 'C'; # GNU locale extension
 
+sub errno_or_skip {
+    SKIP: {
+       if (is_miniperl && !eval 'require Errno') {
+           skip "Errno not built yet", 1;
+       }
+       eval "ok($_[0])";
+    }
+}
+
 ok(mkdir('blurfl',0777));
 ok(!mkdir('blurfl',0777));
-ok($!{EEXIST} || $! =~ /cannot move|exist|denied|unknown/i);
+errno_or_skip('$!{EEXIST} || $! =~ /cannot move|exist|denied|unknown/i');
 ok(-d 'blurfl');
 ok(rmdir('blurfl'));
 ok(!rmdir('blurfl'));
-ok($!{ENOENT} || $! =~ /cannot find|such|exist|not found|not a directory|unknown/i);
+errno_or_skip('
+    $!{ENOENT}
+       || $! =~ /cannot find|such|exist|not found|not a directory|unknown/i
+');
 ok(mkdir('blurfl'));
 ok(rmdir('blurfl'));