Skip to content

Commit

Permalink
'/'.IO.mkdir must not segfault
Browse files Browse the repository at this point in the history
RT#126976

geekosaur++ for explaining Windows side of things for this test
(http://irclog.perlgeek.de/perl6-dev/2016-07-05#i_12784679)
  • Loading branch information
zoffixznet committed Jul 5, 2016
1 parent 56b8416 commit 423ee64
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion S32-io/mkdir_rmdir.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 7;
plan 9;

# Tests for IO::Path.mkdir and IO::Path.rmdir
#
Expand Down Expand Up @@ -62,6 +62,35 @@ plan 7;
isa_fatal_ok $err, X::IO::Mkdir;
}

# RT #126976
subtest {
# This test is a bit tricky:
# it generally should throw since we can't create '/' directory
# on Windows, however, such .mkdir returns True due to a
# backward compatibility wart. BUT, it fails if the test is run
# from a root directory, such as C:\ [discussion:
# http://irclog.perlgeek.de/perl6-dev/2016-07-05#i_12784679]
#
# So what we're doing here is skipping the exception testing if
# we are on Windows and got True. We also attempt to .mkdir
# a few times to ensure segfaults aren't lurking in there.

my $result;
try {
$result = "/".IO.mkdir;
CATCH { default { $result = $_; } };
} for ^5;

if $*DISTRO ~~ /'mswin32'/ and $result ~~ Bool and $result {
skip '"/".IO.mkdir succeeds on Windows when not run in root dir', 2;
}
else {
isa-ok $result, X::IO::Mkdir, 'we received an exception';
like $result.message, /'Failed to create directory'/,
'exception has right message';
}
}, '"/".IO.mkdir must not segfault';

sub testdir {
my $testdir = "testdir-" ~ 1000000.rand.floor;
die if $testdir.path.e;
Expand Down

0 comments on commit 423ee64

Please sign in to comment.