From 927d4d60a6da2db2971b82994f0b79ac7aba3faf Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sun, 22 Nov 2026 23:34:15 +0700 Subject: [PATCH] test(io): tolerate errno 45 as ENOTSUP when this host's std does (#4656) Fixes #4655. Since #3178, the scheduled FreeBSD 15 x86_64 job has failed io::tests::full_sync_tolerates_apple_enotsup with "45 on other Unix". The test assumed errno 45 is never ErrorKind::Unsupported unless the Apple flag is set. That is true on Linux (EL2NSYNC) but not on FreeBSD, where 45 is ENOTSUP and equals EOPNOTSUPP. Production full_sync_unsupported is already correct on FreeBSD via kind(). This change makes those two unit-test cases follow the host mapping, so Linux still requires a failed save and BSD hosts match production. No production code change. The FreeBSD aarch64 job only cross-compiles tests; it does not run them, so a green aarch64 leg is not a test pass. --- crates/engine/src/io/tests.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/io/tests.rs b/crates/engine/src/io/tests.rs index 9c4127f1d..4a775bd56 100644 --- a/crates/engine/src/io/tests.rs +++ b/crates/engine/src/io/tests.rs @@ -409,16 +409,19 @@ fn full_sync_tolerates_only_unsupported_errors() { } /// Apple's ENOTSUP is 45 (EOPNOTSUPP is 102), and std maps only the latter to -/// `ErrorKind::Unsupported`: F_FULLFSYNC refused with ENOTSUP must still save. Elsewhere 45 is -/// another error (EL2NSYNC on Linux) and stays a failed save. +/// `ErrorKind::Unsupported`: F_FULLFSYNC refused with ENOTSUP must still save. On Linux, 45 is +/// EL2NSYNC and stays a failed save. On FreeBSD and other BSDs, 45 is ENOTSUP (the same value as +/// EOPNOTSUPP), so this host's std reports `ErrorKind::Unsupported` and the flush is tolerated +/// even when the `apple` flag is false — which is the real helper's behaviour on those systems. #[cfg(not(target_arch = "wasm32"))] #[test] fn full_sync_tolerates_apple_enotsup() { - use std::io::Error; + use std::io::{Error, ErrorKind}; let enotsup = Error::from_raw_os_error(45); assert!(flush_unsupported_on(&enotsup, true, true), "ENOTSUP on Apple"); - assert!(!flush_unsupported_on(&enotsup, true, false), "45 on other Unix"); - assert!(!flush_unsupported_on(&enotsup, false, false), "45 on Windows"); + let host_maps_45_unsupported = enotsup.kind() == ErrorKind::Unsupported; + assert_eq!(flush_unsupported_on(&enotsup, true, false), host_maps_45_unsupported, "45 on other Unix"); + assert_eq!(flush_unsupported_on(&enotsup, false, false), host_maps_45_unsupported, "45 on Windows"); assert!(flush_unsupported_on(&Error::from_raw_os_error(25), true, true), "ENOTTY on Apple"); assert!(!flush_unsupported_on(&Error::from_raw_os_error(5), true, true), "EIO on Apple"); assert!(!flush_unsupported_on(&Error::from_raw_os_error(28), true, true), "ENOSPC on Apple");