Skip to content

Commit 10c2a34

Browse files
committed
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.
1 parent 2394ea6 commit 10c2a34

File tree

1 file changed

+4
-0
lines changed
  • crates/cargo-test-support/src

1 file changed

+4
-0
lines changed

crates/cargo-test-support/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,7 @@ pub fn no_such_file_err_msg() -> String {
16031603
/// Helper to retry a function `n` times.
16041604
///
16051605
/// The function should return `Some` when it is ready.
1606+
#[track_caller]
16061607
pub fn retry<F, R>(n: u32, mut f: F) -> R
16071608
where
16081609
F: FnMut() -> Option<R>,
@@ -1631,13 +1632,15 @@ fn retry_fails() {
16311632
}
16321633

16331634
/// Helper that waits for a thread to finish, up to `n` tenths of a second.
1635+
#[track_caller]
16341636
pub fn thread_wait_timeout<T>(n: u32, thread: JoinHandle<T>) -> T {
16351637
retry(n, || thread.is_finished().then_some(()));
16361638
thread.join().unwrap()
16371639
}
16381640

16391641
/// Helper that runs some function, and waits up to `n` tenths of a second for
16401642
/// it to finish.
1643+
#[track_caller]
16411644
pub fn threaded_timeout<F, R>(n: u32, f: F) -> R
16421645
where
16431646
F: FnOnce() -> R + Send + 'static,
@@ -1714,6 +1717,7 @@ pub fn assert_deps(project: &Project, fingerprint: &str, test_cb: impl Fn(&Path,
17141717
}
17151718
}
17161719

1720+
#[track_caller]
17171721
pub fn assert_deps_contains(project: &Project, fingerprint: &str, expected: &[(u8, &str)]) {
17181722
assert_deps(project, fingerprint, |info_path, entries| {
17191723
for (e_kind, e_path) in expected {

0 commit comments

Comments
 (0)