Skip to content

Commit ea292f6

Browse files
committed
[v6.d REVIEW] Re-spec mkdir / reformat tests
- We do not fail on dirs that already exist - Use more appropriate test routines
1 parent 32af7b5 commit ea292f6

File tree

1 file changed

+8
-49
lines changed

1 file changed

+8
-49
lines changed

S32-io/mkdir_rmdir.t

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ use lib 't/spec/packages';
55
use Test;
66
use Test::Util;
77

8-
plan 7;
8+
plan 6;
99

1010
# Tests for IO::Path.mkdir and IO::Path.rmdir
1111
#
1212
# See also S16-filehandles/mkdir_rmdir.t
1313
# L<S32::IO/IO::Path>
1414

1515
{
16-
my $dir = make-temp-dir;
16+
my $dir = make-temp-path;
17+
is-deeply mkdir($dir), $dir, 'mkdir returns the IO::Path it made';
1718
ok $dir.e, "$dir exists";
1819
ok $dir.d, "$dir is a directory";
1920
}
@@ -22,62 +23,20 @@ plan 7;
2223
{
2324
my $dir = make-temp-dir;
2425
$dir.rmdir;
25-
throws-like { $dir.rmdir }, X::IO::Rmdir;
26+
fails-like { $dir.rmdir }, X::IO::Rmdir;
2627
}
2728

2829
# rmdir soft-fail when dir contains files.
2930
{
3031
my $dir = make-temp-dir;
3132
spurt "$dir/file", "hello world";
32-
throws-like { $dir.rmdir }, X::IO::Rmdir;
33-
}
34-
35-
# mkdir in a dir that doesn't exist
36-
#?rakudo skip "mkdir NYI RT #124791"
37-
{
38-
# XXX: mkdir creates nested directories if they don't exist,
39-
# so does this test make sense anymore?
40-
my $dir = make-temp-dir;
41-
$dir.rmdir;
42-
throws-like { $dir.child('foo').mkdir }, X::IO::Mkdir;
33+
fails-like { $dir.rmdir }, X::IO::Rmdir;
4334
}
4435

45-
# mkdir a dir that already exists
46-
#?rakudo skip "mkdir NYI RT #124792"
36+
# RT #126976
4737
{
48-
# XXX: mkdir returns True (pre 2017.05) or the IO::Path itself
49-
# when dir already exists, so does this test make sense?
50-
my $dir = make-temp-dir;
51-
throws-like { $dir.mkdir }, X::IO::Mkdir;
38+
"/".IO.mkdir for ^10;
39+
pass '"/".IO.mkdir does not segfault';
5240
}
5341

54-
# RT #126976
55-
subtest {
56-
# This test is a bit tricky:
57-
# it generally should throw since we can't create '/' directory
58-
# on Windows, however, such .mkdir returns True due to a
59-
# backward compatibility wart. BUT, it fails if the test is run
60-
# from a root directory, such as C:\ [discussion:
61-
# http://irclog.perlgeek.de/perl6-dev/2016-07-05#i_12784679]
62-
#
63-
# So what we're doing here is skipping the exception testing if
64-
# we are on Windows and got True. We also attempt to .mkdir
65-
# a few times to ensure segfaults aren't lurking in there.
66-
67-
my $result;
68-
try {
69-
$result = "/".IO.mkdir;
70-
CATCH { default { $result = $_; } };
71-
} for ^5;
72-
73-
if $*DISTRO ~~ /'mswin32'/ and $result ~~ Bool and $result {
74-
skip '"/".IO.mkdir succeeds on Windows when not run in root dir', 2;
75-
}
76-
else {
77-
isa-ok $result, X::IO::Mkdir, 'we received an exception';
78-
like $result.message, /'Failed to create directory'/,
79-
'exception has right message';
80-
}
81-
}, '"/".IO.mkdir must not segfault';
82-
8342
# vim: ft=perl6

0 commit comments

Comments
 (0)