From bd6116452e990a0af69dd21eef4cc673364fe013 Mon Sep 17 00:00:00 2001 From: WebIdentity1 <212448219+WebIdentity1@users.noreply.github.com> Date: Mon, 23 Nov 2026 21:41:52 -0500 Subject: [PATCH] Tests: capture the truncate error before checking for Wine The first under_wine call looks up wine_get_version and leaves error 127 on native Windows. Saving CreateFileW's error immediately keeps the test independent of whether another fixture has already initialized that check. The exact isolated test failed before this change and passes after it. --- crates/xcl/src/vfs.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/xcl/src/vfs.rs b/crates/xcl/src/vfs.rs index 469e6269b..92bb7d43b 100644 --- a/crates/xcl/src/vfs.rs +++ b/crates/xcl/src/vfs.rs @@ -963,11 +963,12 @@ mod tests { std::ptr::null_mut(), ) }; + let error = unsafe { windows_sys::Win32::Foundation::GetLastError() }; assert_eq!(h, windows_sys::Win32::Foundation::INVALID_HANDLE_VALUE); // Windows' own codes are the reference; Wine answers a directory opened with // FILE_FLAG_BACKUP_SEMANTICS and TRUNCATE_EXISTING with ERROR_FILE_EXISTS if !crate::util::under_wine() { - assert_eq!(unsafe { windows_sys::Win32::Foundation::GetLastError() }, expected); + assert_eq!(error, expected); } assert_eq!(v.open_decision("G:\\data", GENERIC_WRITE, TRUNCATE_EXISTING, flags), Decision::Fail(expected)); }