Skip to content

Commit 0cf64dd

Browse files
committed
Add experimental assertThrown(traverseByString()) unittest
If this passes CI, we can keep it in, I suppose.
1 parent 011a66b commit 0cf64dd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

std/file.d

+21
Original file line numberDiff line numberDiff line change
@@ -5417,6 +5417,27 @@ if (is(Path == DirEntry))
54175417
if (subEntry.isDir)
54185418
chdir(subEntry.absolutePath);
54195419
}
5420+
5421+
/*
5422+
This tests whether the “relative-path string” pitfall is still a thing.
5423+
It can be removed later in case the underlying issue got fixed somehow.
5424+
When doing so, one should make sure to delete the warning from the doc
5425+
comment of `dirEntries` as well.
5426+
*/
5427+
void traverseByString() @safe
5428+
{
5429+
chdir(root);
5430+
scope(exit) chdir(origWD);
5431+
foreach (string entry; ".".dirEntries(SpanMode.shallow))
5432+
{
5433+
if (entry.isDir)
5434+
foreach (string subEntry; entry.dirEntries(SpanMode.shallow))
5435+
if (subEntry.isDir)
5436+
chdir(subEntry.absolutePath);
5437+
}
5438+
}
5439+
import std.exception : assertThrown;
5440+
assertThrown(traverseByString());
54205441
}
54215442

54225443
/**

0 commit comments

Comments
 (0)