From 10c2a3480599bb6f00e63135dab3942f5bb4f03f Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 8 Oct 2025 08:57:19 -0500 Subject: [PATCH] fix(support): Add track_caller to know the actual failure We've been seeing failures on Windows with our cache locking tests. This adds `#[track_caller]` for those calls to make it clearer what is failing. I went ahead and added the attribute pre-emptively to other assertions I saw. --- crates/cargo-test-support/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/cargo-test-support/src/lib.rs b/crates/cargo-test-support/src/lib.rs index 014497a298a..905c76f4dd6 100644 --- a/crates/cargo-test-support/src/lib.rs +++ b/crates/cargo-test-support/src/lib.rs @@ -1603,6 +1603,7 @@ pub fn no_such_file_err_msg() -> String { /// Helper to retry a function `n` times. /// /// The function should return `Some` when it is ready. +#[track_caller] pub fn retry(n: u32, mut f: F) -> R where F: FnMut() -> Option, @@ -1631,6 +1632,7 @@ fn retry_fails() { } /// Helper that waits for a thread to finish, up to `n` tenths of a second. +#[track_caller] pub fn thread_wait_timeout(n: u32, thread: JoinHandle) -> T { retry(n, || thread.is_finished().then_some(())); thread.join().unwrap() @@ -1638,6 +1640,7 @@ pub fn thread_wait_timeout(n: u32, thread: JoinHandle) -> T { /// Helper that runs some function, and waits up to `n` tenths of a second for /// it to finish. +#[track_caller] pub fn threaded_timeout(n: u32, f: F) -> R where F: FnOnce() -> R + Send + 'static, @@ -1714,6 +1717,7 @@ pub fn assert_deps(project: &Project, fingerprint: &str, test_cb: impl Fn(&Path, } } +#[track_caller] pub fn assert_deps_contains(project: &Project, fingerprint: &str, expected: &[(u8, &str)]) { assert_deps(project, fingerprint, |info_path, entries| { for (e_kind, e_path) in expected {