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)
This commit is contained in:
LGUG2Z committed 2026-10-27 22:22:57 -07:00
1 parent d4fc229a77
commit 5a4d89ffd5
2 files changed
+15 -3

No files matched your search

+5 -1
View File
@@ -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");
+10 -2
View File
@@ -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 [