@@ -5,15 +5,16 @@ use lib 't/spec/packages';
5
5
use Test ;
6
6
use Test ::Util;
7
7
8
- plan 7 ;
8
+ plan 6 ;
9
9
10
10
# Tests for IO::Path.mkdir and IO::Path.rmdir
11
11
#
12
12
# See also S16-filehandles/mkdir_rmdir.t
13
13
# L<S32::IO/IO::Path>
14
14
15
15
{
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' ;
17
18
ok $ dir . e , " $ dir exists" ;
18
19
ok $ dir . d , " $ dir is a directory" ;
19
20
}
@@ -22,62 +23,20 @@ plan 7;
22
23
{
23
24
my $ dir = make-temp-dir;
24
25
$ dir . rmdir;
25
- throws -like { $ dir . rmdir }, X::IO::Rmdir ;
26
+ fails -like { $ dir . rmdir }, X::IO::Rmdir ;
26
27
}
27
28
28
29
# rmdir soft-fail when dir contains files.
29
30
{
30
31
my $ dir = make-temp-dir;
31
32
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 ;
43
34
}
44
35
45
- # mkdir a dir that already exists
46
- # ?rakudo skip "mkdir NYI RT #124792"
36
+ # RT #126976
47
37
{
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' ;
52
40
}
53
41
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
-
83
42
# vim: ft=perl6
0 commit comments