diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
| commit | 4304b0f336ddba7b4ec6780795059ff2066d105b (patch) | |
| tree | 10edea744a1c2bf3fc363b4dc7f64abac8b1a0d3 /tests/state_machine.rs | |
| parent | e757979f1a2afdbe7146066345bb9acd19d3b151 (diff) | |
| download | aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.tar.gz aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.zip | |
comments: keep only what the code cannot show
Stripped every comment that described what an item does, documented its
arguments or fields, or cited the design docs (§n, I-n, m-n, decision n).
2247 comments down to 83.
What survives: the section dividers that segment the large modules, the
secret-handling warnings, the agent wire-frame directions, and the few notes
without which the code they attach to reads as redundant, reorderable, or
unsound.
Diffstat (limited to 'tests/state_machine.rs')
| -rw-r--r-- | tests/state_machine.rs | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/tests/state_machine.rs b/tests/state_machine.rs index a8d9b35..70d7aa6 100644 --- a/tests/state_machine.rs +++ b/tests/state_machine.rs @@ -32,12 +32,10 @@ fn the_machine_refuses_a_transition_it_does_not_define() { let id = build(&env, "b1"); assert_eq!(state(&env, "b1"), BuildState::Queued); - // Queued → Succeeded: a build cannot finish without running. let err = builds::set_state(&env.db, &id, BuildState::Succeeded, None).unwrap_err(); assert!(err.to_string().contains("illegal build transition"), "{err}"); assert_eq!(state(&env, "b1"), BuildState::Queued, "a refused transition writes nothing"); - // And a build that does not exist is named as such, not silently updated. let err = builds::set_state(&env.db, "nope", BuildState::Cancelled, None).unwrap_err(); assert!(err.to_string().contains("no build nope"), "{err}"); } @@ -59,16 +57,11 @@ fn a_terminal_build_is_history_and_does_not_move() { assert!(builds::set_state(&env.db, &id, to, None).is_err(), "accepted {to:?} after success"); } assert_eq!(state(&env, "b1"), BuildState::Succeeded); - // Rows are never deleted (§15); a finished build stays what it was. assert_eq!(env.query_i64("SELECT count(*) FROM build", &[]), Some(1)); } #[test] fn a_zombie_worker_cannot_finish_a_build_it_no_longer_owns() { - // The failure this pins: a worker's lease expires mid-step, the reaper hands - // the build back, and the original worker comes back and writes `succeeded` - // over whatever the new owner did. The compare-and-swap in `set_state` makes - // that an error. let env = Env::new(); let id = build(&env, "b1"); builds::claim(&env.db, "worker-1", &id, 90).unwrap(); @@ -85,23 +78,17 @@ fn a_zombie_worker_cannot_finish_a_build_it_no_longer_owns() { #[test] fn a_state_the_code_does_not_know_is_an_error_not_an_empty_string() { - // A row written by an older binary, a hand-edit, or a future migration must - // stop the process, not render as a build in no state at all. let env = Env::new(); let id = build(&env, "b1"); env.exec("UPDATE build SET state='exploded' WHERE id=?1", &[common::P::S(id.clone())]); let err = builds::get(&env.db, &id).unwrap_err(); assert!(err.to_string().contains("outside the state machine"), "{err}"); - // The package page lists a pkgbase's builds with no state filter: an - // unreadable row must fail the query, not vanish. let pb = env.query_i64("SELECT id FROM pkgbase WHERE name='x'", &[]).unwrap(); assert!(aur_build::db::builds_for_pkgbase(&env.db, pb, 10).is_err()); } #[test] fn the_transition_table_is_the_machine_the_code_actually_uses() { - // Every state may be re-written with its own name — a no-op, not a move. What - // matters is what else is reachable, and this table is the whole machine. let reachable = |from: BuildState| -> Vec<&'static str> { BuildState::ALL .iter() @@ -119,17 +106,13 @@ fn the_transition_table_is_the_machine_the_code_actually_uses() { ["queued", "running", "blocked_missing_dep", "succeeded", "failed", "cancelled"] ); assert_eq!(reachable(BuildState::BlockedMissingDep), ["queued", "blocked_missing_dep", "cancelled"]); - // A failed build is resumed on its own row (I5) or requeued by a human (§8.4). assert_eq!(reachable(BuildState::Failed), ["queued", "running", "failed"]); assert_eq!(reachable(BuildState::Cancelled), ["queued", "cancelled"]); - // A published build is history: a new version is a new build id (§8.1). assert_eq!(reachable(BuildState::Succeeded), ["succeeded"]); } #[test] fn requeueing_a_succeeded_build_is_refused_not_silently_requeued() { - // `builds::retry` resets the failed steps and moves the row back to the queue. - // On a build that already published there is nothing to retry. let env = Env::new(); let id = build(&env, "b1"); builds::claim(&env.db, "worker-1", &id, 90).unwrap(); @@ -142,8 +125,6 @@ fn requeueing_a_succeeded_build_is_refused_not_silently_requeued() { #[test] fn a_failed_build_is_resumed_on_its_own_row() { - // I5: the resume happens on the same row, because the step checkpoints say - // where to continue. let env = Env::new(); let id = build(&env, "b1"); builds::claim(&env.db, "worker-1", &id, 90).unwrap(); @@ -157,11 +138,8 @@ fn a_failed_build_is_resumed_on_its_own_row() { assert_eq!(state(&env, &id), BuildState::Succeeded); } - // ---------------------------------------------------------- the other machines -- -/// A candidate row in `state`, inserted directly: these tests are about the state -/// column, not about how a candidate is discovered. fn candidate(env: &Env, state: &str) -> i64 { env.exec( "INSERT OR IGNORE INTO pkgbase (name, aur_url, created_at) VALUES ('x', 'u', '2026-01-01T00:00:00Z')", @@ -192,14 +170,12 @@ fn candidate_state(env: &Env, id: i64) -> CandidateState { #[test] fn a_decided_review_is_never_re_decided() { - // The one write in this system that must never overwrite a human's decision. let env = Env::new(); let id = candidate(&env, "approved"); let err = resolve(&env, id, CandidateState::Rejected).unwrap_err(); assert!(err.to_string().contains("illegal candidate transition approved"), "{err}"); assert_eq!(candidate_state(&env, id), CandidateState::Approved); - // Superseding a decided review is the one move it makes (§7.1). resolve(&env, id, CandidateState::Superseded).unwrap(); assert_eq!(candidate_state(&env, id), CandidateState::Superseded); assert!(resolve(&env, id, CandidateState::Approved).is_err()); @@ -211,13 +187,11 @@ fn only_an_open_review_can_be_approved() { let id = candidate(&env, "rejected"); assert!(resolve(&env, id, CandidateState::Approved).is_err(), "a rejection was re-decided"); assert_eq!(candidate_state(&env, id), CandidateState::Rejected); - // Re-writing the state it already has is a no-op, not a re-decision. resolve(&env, id, CandidateState::Rejected).unwrap(); } #[test] fn a_completed_step_checkpoint_is_frozen() { - // I5: a resumed build reads these rows to decide what not to redo. let env = Env::new(); let id = build(&env, "b1"); builds::begin_step(&env.db, &id, "build", 1).unwrap(); @@ -234,22 +208,18 @@ fn an_interrupted_step_resumes_and_a_blocked_step_waits() { let env = Env::new(); let id = build(&env, "b1"); builds::begin_step(&env.db, &id, "build", 1).unwrap(); - // The reaper's write, then the resume's re-begin. env.exec( "UPDATE build_step SET status='interrupted' WHERE build_id=?1 AND step='build'", &[common::P::S(id.clone())], ); assert_eq!(builds::step_status(&env.db, &id, "build").unwrap(), Some(StepState::Interrupted)); builds::begin_step(&env.db, &id, "build", 2).unwrap(); - // The blocked path puts the checkpoint back to waiting rather than failing it. builds::finish_step(&env.db, &id, "build", StepState::Pending, None, Some("blocked")).unwrap(); assert_eq!(builds::step_status(&env.db, &id, "build").unwrap(), Some(StepState::Pending)); } #[test] fn an_unnamed_state_in_any_row_is_an_error() { - // Every state column is parsed through `db::state_col`, so an unknown value - // stops the read instead of rendering as some other state. let env = Env::new(); let cid = candidate(&env, "approved"); env.exec( |
