From 4304b0f336ddba7b4ec6780795059ff2066d105b Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 17:33:17 +0000 Subject: comments: keep only what the code cannot show MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tests/dispatch.rs | 37 ------------------------------------- 1 file changed, 37 deletions(-) (limited to 'tests/dispatch.rs') diff --git a/tests/dispatch.rs b/tests/dispatch.rs index 197d226..f702151 100644 --- a/tests/dispatch.rs +++ b/tests/dispatch.rs @@ -9,7 +9,6 @@ use aur_build::pipeline::{self, dispatch}; use aur_build::review::{candidates, diff}; use common::*; -/// Approve a fixture's candidate and enqueue its build without running it. fn queued_build(env: &Env, name: &str) -> String { aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, name).unwrap(); let c = candidates::pending_candidates(&env.db).unwrap().remove(0); @@ -27,7 +26,6 @@ fn pass(env: &Env) -> Vec { #[test] fn the_deterministic_build_id_makes_re_enqueue_a_noop() { - // §8.2: re-submitting the same intent is an INSERT OR IGNORE no-op. let (env, _fx) = env_with_fixture("plain-make"); aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, "plain-make").unwrap(); let c = candidates::pending_candidates(&env.db).unwrap().remove(0); @@ -51,13 +49,10 @@ fn backpressure_admits_no_more_than_max_concurrent_builds() { let claimed = pass(&env); assert_eq!(claimed.len(), 1, "one slot must admit exactly one build"); - // The dispatcher will not run ahead into the second slot while the first is - // still in flight. assert_eq!(pass(&env).len(), 0, "admitted a second build while one is in flight"); assert_eq!(env.query_i64("SELECT count(*) FROM build WHERE state='leased'", &[]), Some(1)); assert_eq!(env.query_i64("SELECT count(*) FROM build WHERE state='queued'", &[]), Some(1)); - // Widen the pool and the second one goes. env.cfg.max_concurrent_builds = 2; assert_eq!(pass(&env).len(), 1); } @@ -66,12 +61,10 @@ fn backpressure_admits_no_more_than_max_concurrent_builds() { fn disk_headroom_is_part_of_backpressure() { let (mut env, _fx) = env_with_fixture("plain-make"); queued_build(&env, "plain-make"); - // Ask for more free space than any machine has: nothing is admitted (§8.2). env.cfg.min_free_disk_mb = u64::MAX / 2; assert_eq!(dispatch::admissible(&env.cfg, &env.db), 0); assert!(pass(&env).is_empty(), "claimed a build with no disk headroom"); assert_eq!(env.query_i64("SELECT count(*) FROM build WHERE state='queued'", &[]), Some(1)); - // And the measurement itself is real, not a stub returning zero. env.cfg.min_free_disk_mb = 1; assert!(dispatch::free_disk_mb(&env.cfg.root) > 0, "free_disk_mb never measures anything"); assert_eq!(dispatch::admissible(&env.cfg, &env.db), 1); @@ -79,19 +72,14 @@ fn disk_headroom_is_part_of_backpressure() { #[test] fn an_expired_lease_is_requeued_and_its_running_step_marked_interrupted() { - // The reaper pass is the whole crash-recovery story: a worker that died - // mid-step leaves a leased row and a running step, and the next pass turns - // that back into queued + interrupted (I5). let (env, _fx) = env_with_fixture("plain-make"); let id = queued_build(&env, "plain-make"); assert_eq!(pass(&env), vec![id.clone()]); builds::begin_step(&env.db, &id, "build", 1).unwrap(); assert_eq!(builds::step_status(&env.db, &id, "build").unwrap(), Some(StepState::Running)); - // Time passes — the lease expires, as it would if the process were killed. env.exec("UPDATE build SET lease_expires_at='2000-01-01T00:00:00Z'", &[]); - // A fresh dispatcher (as after a restart) reaps it before claiming anything. let reaped = builds::reap_expired(&env.db).unwrap(); assert_eq!(reaped, 1, "the expired lease was not requeued"); assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().state, BuildState::Queued); @@ -100,15 +88,12 @@ fn an_expired_lease_is_requeued_and_its_running_step_marked_interrupted() { Some(StepState::Interrupted), "the in-flight step was not marked interrupted" ); - // And it is claimable again. assert_eq!(pass(&env), vec![id.clone()]); assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().attempt, 2, "the retry was not counted"); } #[test] fn a_newer_approval_cancels_an_in_flight_build_at_the_step_boundary() { - // §8.2 cancellation: a superseded candidate marks the running build - // cancel_requested; the worker stops at the next boundary. let (env, _fx) = env_with_fixture("plain-make"); let id = queued_build(&env, "plain-make"); pass(&env); @@ -116,7 +101,6 @@ fn a_newer_approval_cancels_an_in_flight_build_at_the_step_boundary() { env.exec("UPDATE candidate SET state='superseded' WHERE id=(SELECT candidate_id FROM build WHERE id=?1)", ¶ms(vec![id.as_str()])); assert_eq!(builds::cancel_superseded(&env.db).unwrap(), 1); assert!(builds::cancel_requested(&env.db, &id).unwrap()); - // run() honours it at the step boundary rather than mid-step. let out = pipeline::run(&env.cfg, &env.db, &id).unwrap(); assert!(matches!(out, pipeline::Outcome::Cancelled), "run ignored the cancellation"); assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().state, BuildState::Cancelled); @@ -124,8 +108,6 @@ fn a_newer_approval_cancels_an_in_flight_build_at_the_step_boundary() { #[test] fn a_deterministic_build_failure_is_not_retried() { - // §8.4: a build that fails for a deterministic reason stays failed at attempt - // 1; burning another chroot to reproduce the same failure helps nobody. let (env, _fx) = env_with_fixture("build-fails"); let id = queued_build(&env, "build-fails"); let pool = dispatch::Pool::spawn(Arc::new(env.cfg.clone()), env.db.clone()); @@ -135,15 +117,11 @@ fn a_deterministic_build_failure_is_not_retried() { let b = builds::get(&env.db, &id).unwrap().unwrap(); assert_eq!(b.attempt, 1, "a deterministic failure must not be retried"); assert!(b.error.unwrap_or_default().contains("build"), "no step named in the error"); - // And the old version keeps looking served: nothing was published. assert_eq!(db::index_version(&env.db, "build-fails").unwrap(), None); } #[test] fn a_transient_failure_is_retried_up_to_the_cap() { - // §8.4: a failure the outside world caused is retried, up to a bound. This - // drives the real path: the build's `sources` step has to fetch and gets an - // `Http` failure — the class a flaky mirror produces. let (mut env, fx) = env_with_fixture("skip-checksum"); let id = queued_build(&env, "skip-checksum"); std::fs::remove_file(fx.data.join("payload.bin")).expect("payload exists"); @@ -151,8 +129,6 @@ fn a_transient_failure_is_retried_up_to_the_cap() { env.cfg.max_transient_attempts = 3; env.cfg.dispatch_tick_secs = 0; let pool = dispatch::Pool::spawn(Arc::new(env.cfg.clone()), env.db.clone()); - // The state flickers to 'failed' between retries; what settles is the - // attempt count reaching the cap with the build left failed. let b = wait_attempt(&env, &id, 3); pool.shutdown(); assert_eq!(b.state, BuildState::Failed); @@ -165,9 +141,6 @@ fn a_transient_failure_is_retried_up_to_the_cap() { #[test] fn a_missing_toolchain_is_not_retried() { - // m-14: this used to be the transient test. A missing `makepkg` surfaces as - // an `Io` error, and `Io` used to mean "retry". It is deterministic: the tool - // is not going to appear. let (mut env, _fx) = env_with_fixture("plain-make"); let id = queued_build(&env, "plain-make"); env.cfg.makepkg_bin = "/nonexistent/makepkg-for-test".into(); @@ -186,8 +159,6 @@ fn a_missing_toolchain_is_not_retried() { #[test] fn the_pool_takes_a_queued_build_all_the_way_to_publication() { - // The threads, not a test calling run() directly: dispatcher claims, worker - // runs the ten steps, publish lands the release. let (env, _fx) = env_with_fixture("plain-make"); let id = queued_build(&env, "plain-make"); let cfg = Arc::new(env.cfg.clone()); @@ -201,8 +172,6 @@ fn the_pool_takes_a_queued_build_all_the_way_to_publication() { #[test] fn a_reaped_build_resumes_at_the_next_incomplete_step_with_no_duplicate_work() { - // I5 through the dispatcher rather than a direct run(): a build that dies late - // is requeued, re-claimed, and finishes from its checkpoints. let (mut env, fx) = env_with_fixture("plain-make"); let c = queued_candidate(&env, "plain-make"); let first = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap(); @@ -218,9 +187,6 @@ fn a_reaped_build_resumes_at_the_next_incomplete_step_with_no_duplicate_work() { )); let builds_before = aur_build::shims::called_with(&env.cfg.hooks.shim_dir.clone().unwrap(), "makepkg", ""); - // The worker "died" at publish: the row is leased to a worker that is no - // longer running, with a lease nobody will extend. A fresh dispatcher reaps it - // and a worker finishes from the checkpoints. env.clear_publish_fault(); env.exec( "UPDATE build SET state='leased', lease_owner='dead-worker', @@ -252,7 +218,6 @@ fn a_reaped_build_resumes_at_the_next_incomplete_step_with_no_duplicate_work() { assert_eq!(db::index_version(&env.db, "plain-make").unwrap().as_deref(), Some("1.0.1-1")); } -/// Approve a fixture's candidate and hand back the approved row. fn queued_candidate(env: &Env, name: &str) -> CandidateRow { aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, name).unwrap(); let c = candidates::pending_candidates(&env.db).unwrap().remove(0); @@ -262,7 +227,6 @@ fn queued_candidate(env: &Env, name: &str) -> CandidateRow { candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap() } -/// Poll until the build has been attempted `n` times and settled. fn wait_attempt(env: &Env, id: &str, n: i64) -> builds::BuildRow { for _ in 0..600 { if let Some(b) = builds::get(&env.db, id).unwrap() { @@ -275,7 +239,6 @@ fn wait_attempt(env: &Env, id: &str, n: i64) -> builds::BuildRow { panic!("build {id} never reached {n} attempts in state failed"); } -/// Poll until the build reaches one of `want` (or the test gives up). fn wait_for(env: &Env, id: &str, want: &[BuildState]) -> BuildState { for _ in 0..600 { if let Some(b) = builds::get(&env.db, id).unwrap() { -- cgit v1.2.3