From 5a4d89ffd528bc2d01a8d263e43fd5db34e0c446 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 27 Oct 2026 09:41:51 -0700 Subject: [PATCH] test(session): do not assume a Mac, or a lock that can be read Four tests only passed on a Mac: - the pid is kept out of the locked file: Windows locks are mandatory, so the test could not read the file it was holding; it checks the pid file only - an older build's pid in the lock file: an older build only ever ran on a Mac, and Windows cannot read it back while the file is locked; unix only - the README describes the OS trace the host's session has: the Mac side of it took the build host's manifest; it now says it is one - the README embeds the session path: the quoting it looks for is the host's own (single quotes in a unix shell, double on Windows) --- komorebi-recorder/src/lock.rs | 6 +++++- komorebi-recorder/src/session.rs | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/komorebi-recorder/src/lock.rs b/komorebi-recorder/src/lock.rs index 9b17b47c..6b6e0370 100644 --- a/komorebi-recorder/src/lock.rs +++ b/komorebi-recorder/src/lock.rs @@ -248,7 +248,9 @@ mod tests { let dir = temp("pidfile"); let _lock = RecorderLock::acquire(&dir).expect("acquire"); - // Windows would refuse to read a file that is locked, so the pid cannot live in it + // Windows would refuse to read a file that is locked, so the pid cannot live in it (and + // this test cannot read it there either) + #[cfg(unix)] assert_eq!( std::fs::read_to_string(dir.join(LOCK_FILE)).expect("lock file"), "" @@ -261,6 +263,8 @@ mod tests { ); } + // an older build only ever ran on a Mac, and Windows cannot read a pid out of a locked file + #[cfg(unix)] #[test] fn a_pid_written_into_the_lock_file_by_an_older_build_is_still_read() { let dir = temp("legacy"); diff --git a/komorebi-recorder/src/session.rs b/komorebi-recorder/src/session.rs index 643dbf5f..7ef56acd 100644 --- a/komorebi-recorder/src/session.rs +++ b/komorebi-recorder/src/session.rs @@ -688,7 +688,15 @@ mod tests { assert!(text.contains("QueryPerformanceCounter")); assert!(!text.contains("unified log"), "{text}"); - let mac = readme(Path::new("/tmp/s"), &self::tests::manifest()); + // a Mac's, whichever host runs this test + let mut mac_manifest = self::tests::manifest(); + mac_manifest.host = Some(Host { + os: "macos".to_string(), + arch: "aarch64".to_string(), + os_version: Some("26.0".to_string()), + clock: crate::platform::ClockKind::Mach, + }); + let mac = readme(Path::new("/tmp/s"), &mac_manifest); assert!(mac.contains("macOS unified log")); } @@ -785,7 +793,7 @@ mod tests { fn the_readme_embeds_the_session_path_and_every_query() { let text = readme(Path::new("/tmp/a b/session"), &manifest()); assert!( - text.contains("'/tmp/a b/session'"), + text.contains(&shell_quote("/tmp/a b/session")), "paths with spaces are quoted" ); for command in [