Skip to content

Commit 5b52a2a

Browse files
committed
Add experimental assertThrown(traverseByString()) unittest
If this passes CI, we can keep it in, I suppose.
1 parent eeb4363 commit 5b52a2a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

std/file.d

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

54235444
/**

0 commit comments

Comments
 (0)