Skip to content

Commit

Permalink
std/file.d: Don't check for OS-dependent error message in remove un…
Browse files Browse the repository at this point in the history
…ittest

Signed-off-by: Horodniceanu Andrei <[email protected]>
  • Loading branch information
the-horo committed Mar 22, 2024
1 parent 3919c7f commit 9e95aad
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions std/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -1083,19 +1083,18 @@ private void removeImpl(scope const(char)[] name, scope const(FSChar)* namez) @t
@safe unittest
{
import std.exception : collectExceptionMsg, assertThrown;
import std.algorithm.searching : startsWith;

string filename = null; // e.g. as returned by File.tmpfile.name

version (linux)
{
// exact exception message is OS-dependent
auto msg = filename.remove.collectExceptionMsg!FileException;
assert("Failed to remove file (null): Bad address" == msg, msg);
assert(msg.startsWith("Failed to remove file (null):"), msg);
}
else version (Windows)
{
import std.algorithm.searching : startsWith;

// don't test exact message on windows, it's language dependent
auto msg = filename.remove.collectExceptionMsg!FileException;
assert(msg.startsWith("(null):"), msg);
Expand Down

0 comments on commit 9e95aad

Please sign in to comment.