File tree 1 file changed +34
-8
lines changed
1 file changed +34
-8
lines changed Original file line number Diff line number Diff line change @@ -5163,15 +5163,41 @@ auto dirEntries(bool useDIP1000 = dip1000Enabled)
5163
5163
5164
5164
// https://issues.dlang.org/show_bug.cgi?id=15146
5165
5165
dirEntries(" " , SpanMode.shallow).walkLength();
5166
+ }
5166
5167
5167
- // https://github.com/dlang/phobos/issues/9584
5168
- string cwd = getcwd();
5169
- foreach (string entry; dirEntries(testdir, SpanMode.shallow))
5170
- {
5171
- if (entry.isDir)
5172
- chdir(entry);
5173
- }
5174
- chdir(cwd); // needed for the directories to be removed
5168
+ // https://github.com/dlang/phobos/issues/9584
5169
+ @safe unittest
5170
+ {
5171
+ import std.path : absolutePath, buildPath;
5172
+
5173
+ string root = deleteme();
5174
+ mkdirRecurse(root);
5175
+ scope (exit) rmdirRecurse(root);
5176
+
5177
+ mkdirRecurse(root.buildPath(" 1" , " 2" ));
5178
+ mkdirRecurse(root.buildPath(" 3" , " 4" ));
5179
+ mkdirRecurse(root.buildPath(" 3" , " 5" , " 6" ));
5180
+
5181
+ const origWD = getcwd();
5182
+ chdir(root);
5183
+ scope (exit) chdir (origWD);
5184
+
5185
+ // When issue #9584 is triggered,
5186
+ // one of the `isDir` calls fails with "No such file or directory".
5187
+ foreach (string entry; " ." .dirEntries(SpanMode.shallow))
5188
+ {
5189
+ if (entry.isDir)
5190
+ {
5191
+ foreach (string subEntry; entry.dirEntries(SpanMode.shallow))
5192
+ {
5193
+ if (subEntry.isDir)
5194
+ {
5195
+ chdir(absolutePath(subEntry));
5196
+ assert (absolutePath(subEntry));
5197
+ }
5198
+ }
5199
+ }
5200
+ }
5175
5201
}
5176
5202
5177
5203
// / Ditto
You can’t perform that action at this time.
0 commit comments