From 0b94ccf00612d9f2afe118b6b4196706f1421f22 Mon Sep 17 00:00:00 2001 From: le king fu Date: Sun, 4 Oct 2026 16:33:02 -0400 Subject: [PATCH] test(license): poll the one-check-at-a-time tests in a fixed order The three tests of #373 run two branches with tokio::join! and rely on the first branch being polled first: the check that starts first, or the check that waits for a held turn before the time moves. tokio's join! already starts with the first branch on its first poll, but rotates on the next ones; `biased;` keeps the declared order on every poll and says so in the code. The three mutations (no turn, time read before the turn, guard dropped at once) were run again: same red tests. Resolves #373 Co-Authored-By: Claude Opus 5.5 --- src-tauri/src/commands/license_commands.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/commands/license_commands.rs b/src-tauri/src/commands/license_commands.rs index ba35d9e..b786e6b 100644 --- a/src-tauri/src/commands/license_commands.rs +++ b/src-tauri/src/commands/license_commands.rs @@ -2624,7 +2624,9 @@ mod tests { // === One check at a time (#373) =========================================================== // // Each test has its own turn, standing for `REVOCATION_CHECK_TURN`: tests run on parallel - // threads, and a turn shared between them would decide which check goes first. + // threads, and a turn shared between them would decide which check goes first. `join!` is + // `biased`: its first branch is polled first, every time, so it is the check that starts + // first. /// A turn of its own for one test. fn new_turn() -> tauri::async_runtime::Mutex<()> { @@ -2649,6 +2651,7 @@ mod tests { let turn = new_turn(); let (first, second) = tokio::join!( + biased; check_revocation_in_turn(&turn, &dir.0, &url, &dec, || NOW), check_revocation_in_turn(&turn, &dir.0, &url, &dec, || NOW), ); @@ -2694,6 +2697,7 @@ mod tests { let turn = new_turn(); let (first, second) = tokio::join!( + biased; check_revocation_in_turn(&turn, &dir.0, &url, &dec, || NOW), async { store_license_in(&dir.0, &new_key, &dec).unwrap(); @@ -2735,6 +2739,7 @@ mod tests { let running = turn.lock().await; let (dir_ref, clock_ref, key_ref) = (&dir, &clock, &key); let (result, ()) = tokio::join!( + biased; check_revocation_in_turn(&turn, &dir.0, &url, &dec, || { clock.load(std::sync::atomic::Ordering::SeqCst) }),