summaryrefslogtreecommitdiffstats
path: root/tests/dispatch.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 17:09:59 +0000
committeraur-build <aur-build@localhost>2026-11-19 17:09:59 +0000
commite757979f1a2afdbe7146066345bb9acd19d3b151 (patch)
tree30d5f5fbccd25ea7bf01c5202684af463b74e7d3 /tests/dispatch.rs
parent94c318f13264bb3c00a9f3057ba2e1aafb57c9e4 (diff)
downloadaur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.tar.gz
aur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.zip
comments: say why, not what
Every module-level `//!` header is gone, and the comments that remained either re-explained the line below them or had grown into paragraphs. Density went from one comment line per 6.7 lines of code to one per 10. 827 insertions against 2194 deletions across 86 files. What survived: the invariants (I1-I12), the design cross-references into DESIGN.md, and the notes recording a bug that was found and fixed — those are the comments that carry weight, because they answer a question the code cannot answer about itself. What did not: restating a function signature in prose, and narration of the statement underneath.
Diffstat (limited to 'tests/dispatch.rs')
-rw-r--r--tests/dispatch.rs50
1 files changed, 16 insertions, 34 deletions
diff --git a/tests/dispatch.rs b/tests/dispatch.rs
index 5f65b6f..197d226 100644
--- a/tests/dispatch.rs
+++ b/tests/dispatch.rs
@@ -1,8 +1,3 @@
-//! The dispatcher, the worker pool and the reaper (§8.2), plus the retry policy
-//! (§8.4). These drive the real threads and the real claim transaction — the
-//! crash-recovery claims in §2 are only worth anything if the lease machinery is
-//! actually exercised, not asserted in a comment.
-
mod common;
use std::sync::atomic::AtomicBool;
@@ -32,8 +27,7 @@ fn pass(env: &Env) -> Vec<String> {
#[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, which is
- // what makes a careless "rebuild that again" harmless.
+ // §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);
@@ -72,9 +66,7 @@ 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. A build
- // that cannot fit on disk stays queued instead of filling the filesystem
- // halfway through a compile (§8.2).
+ // 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");
@@ -89,8 +81,7 @@ fn disk_headroom_is_part_of_backpressure() {
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 so the checkpoint decides where it
- // resumes (I5).
+ // 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()]);
@@ -117,8 +108,7 @@ fn an_expired_lease_is_requeued_and_its_running_step_marked_interrupted() {
#[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 rather than
- // finishing work nobody asked for.
+ // 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);
@@ -134,9 +124,8 @@ 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; the release stays approved_but_unbuilt and the UI says so.
+ // §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());
@@ -153,10 +142,8 @@ fn a_deterministic_build_failure_is_not_retried() {
#[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: detection recorded a `SKIP` source's digest, then
- // the bytes became unreachable and the cache was dropped, so the build's
- // `sources` step has to fetch and gets an `Http` failure — the class a
- // flaky mirror produces.
+ // 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");
@@ -178,10 +165,9 @@ 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" — so a
- // misconfigured host or a full disk burned every attempt and then went
- // quiet. It is deterministic: the tool is not going to appear.
+ // 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();
@@ -215,9 +201,8 @@ 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 — the
- // expensive steps are not done again.
+ // 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();
@@ -233,13 +218,10 @@ 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 with a lease nobody will
- // extend. A fresh dispatcher reaps it and a worker finishes from the
- // checkpoints.
+ // 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();
- // The crash shape: 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.exec(
"UPDATE build SET state='leased', lease_owner='dead-worker',
lease_expires_at='2000-01-01T00:00:00Z' WHERE id=?1",