Merge pull request #8956 from the-horo/file.d-unittest-fix

std/file.d: Don't check for OS-dependent error message in unittest
This commit is contained in:
Dennis 2024-03-22 12:07:28 +01:00 committed by GitHub
commit fb24ef3d0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1083,6 +1083,7 @@ 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
@ -1090,12 +1091,10 @@ private void removeImpl(scope const(char)[] name, scope const(FSChar)* namez) @t
{
// 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);