test(license): poll the one-check-at-a-time tests in a fixed order
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 1m46s
PR Check — Rust / rust (pull_request) Successful in 3m19s

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 <noreply@anthropic.com>
This commit is contained in:
le king fu 2026-10-04 16:33:02 -04:00
parent ab78aa9ddc
commit 0b94ccf006

View file

@ -2624,7 +2624,9 @@ mod tests {
// === One check at a time (#373) =========================================================== // === One check at a time (#373) ===========================================================
// //
// Each test has its own turn, standing for `REVOCATION_CHECK_TURN`: tests run on parallel // 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. /// A turn of its own for one test.
fn new_turn() -> tauri::async_runtime::Mutex<()> { fn new_turn() -> tauri::async_runtime::Mutex<()> {
@ -2649,6 +2651,7 @@ mod tests {
let turn = new_turn(); let turn = new_turn();
let (first, second) = tokio::join!( 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),
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 turn = new_turn();
let (first, second) = tokio::join!( 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),
async { async {
store_license_in(&dir.0, &new_key, &dec).unwrap(); store_license_in(&dir.0, &new_key, &dec).unwrap();
@ -2735,6 +2739,7 @@ mod tests {
let running = turn.lock().await; let running = turn.lock().await;
let (dir_ref, clock_ref, key_ref) = (&dir, &clock, &key); let (dir_ref, clock_ref, key_ref) = (&dir, &clock, &key);
let (result, ()) = tokio::join!( let (result, ()) = tokio::join!(
biased;
check_revocation_in_turn(&turn, &dir.0, &url, &dec, || { check_revocation_in_turn(&turn, &dir.0, &url, &dec, || {
clock.load(std::sync::atomic::Ordering::SeqCst) clock.load(std::sync::atomic::Ordering::SeqCst)
}), }),