Skip to content

Commit

Permalink
Assert that we don't get the value we don't want instead of attemptin…
Browse files Browse the repository at this point in the history
…g to check for a specific error code. Fixes dotnet#39955 (dotnet#40019)
  • Loading branch information
kg authored and Jacksondr5 committed Aug 10, 2020
1 parent 1997332 commit 6ec162e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ public void NotFoundErrorIsExpected()
// Make sure we're returning the native error as expected (and not the PAL error on Unix)
using (LastError le = new LastError(Path.GetRandomFileName()))
{
// Conveniently ERROR_FILE_NOT_FOUND and ENOENT are both 0x2
Assert.Equal(2, le.Error);
// while ERROR_FILE_NOT_FOUND/ENOENT have predictable values on Windows, Linux and Mac,
// we can't rely on ENOENT having the same value on other platforms. Instead, assert
// that we didn't get the PAL error because we know its value.
const int PAL_Error_ENOENT = 0x1002D;
Assert.NotEqual(PAL_Error_ENOENT, le.Error);
}
}

Expand Down

0 comments on commit 6ec162e

Please sign in to comment.