summaryrefslogtreecommitdiffstats
path: root/tests/crash.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 17:33:17 +0000
committeraur-build <aur-build@localhost>2026-11-19 17:33:17 +0000
commit4304b0f336ddba7b4ec6780795059ff2066d105b (patch)
tree10edea744a1c2bf3fc363b4dc7f64abac8b1a0d3 /tests/crash.rs
parente757979f1a2afdbe7146066345bb9acd19d3b151 (diff)
downloadaur-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/crash.rs')
-rw-r--r--tests/crash.rs21
1 files changed, 0 insertions, 21 deletions
diff --git a/tests/crash.rs b/tests/crash.rs
index 68cac5c..ca7d90a 100644
--- a/tests/crash.rs
+++ b/tests/crash.rs
@@ -8,7 +8,6 @@ use aur_build::pipeline;
use aur_build::review::{candidates, diff};
use common::*;
-/// Approve a fixture's candidate and hand back the approved row.
fn approved(env: &Env, name: &str) -> aur_build::db::model::CandidateRow {
aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, name).unwrap();
let c = candidates::pending_candidates(&env.db).unwrap().remove(0);
@@ -18,7 +17,6 @@ fn approved(env: &Env, name: &str) -> aur_build::db::model::CandidateRow {
candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap()
}
-/// Approve and enqueue the build without running it.
fn queued(env: &Env, name: &str) -> String {
let c = approved(env, name);
pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap()
@@ -37,7 +35,6 @@ fn run_cli(env: &Env, args: &[&str]) -> std::process::Output {
fn a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work() {
let (mut env, _fx) = env_with_fixture("plain-make");
let id = queued(&env, "plain-make");
- // The child will be murdered the moment it invokes makepkg.
env.cfg.hooks.shim_kill_parent = Some("makepkg".into());
env.cfg.save().unwrap();
@@ -51,7 +48,6 @@ fn a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work
String::from_utf8_lossy(&out.stderr)
);
- // The database survived, because no transaction ever spans a build step.
let b = builds::get(&env.db, &id).unwrap().expect("build row survived the kill");
assert!(
b.state == BuildState::Leased || b.state == BuildState::Running,
@@ -70,8 +66,6 @@ fn a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work
);
assert!(db::accepted_release(&env.db, "plain-make").unwrap().is_none(), "nothing was published");
- // Time passes; the lease expires. A fresh process's dispatcher reaps it — the
- // same code path as any other expired lease.
env.exec("UPDATE build SET lease_expires_at='2000-01-01T00:00:00Z' WHERE id=?1", &params(vec![id.as_str()]));
assert_eq!(builds::reap_expired(&env.db).unwrap(), 1);
assert_eq!(
@@ -79,7 +73,6 @@ fn a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work
Some(StepState::Interrupted)
);
- // Resume: the completed steps are not repeated.
env.cfg.hooks.shim_kill_parent = None;
env.cfg.save().unwrap();
let out = run_cli(&env, &["run", &id]);
@@ -108,35 +101,26 @@ fn a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work
#[test]
fn a_cancelled_build_stops_at_a_step_boundary_and_publishes_nothing() {
- // §8.2: cancellation is cooperative at a step boundary. A worker never kills a
- // step halfway through, because that is the state a crash leaves.
let (env, _fx) = env_with_fixture("plain-make");
let id = queued(&env, "plain-make");
builds::request_cancel(&env.db, &id).unwrap();
let out = pipeline::run(&env.cfg, &env.db, &id).unwrap();
assert!(matches!(out, pipeline::Outcome::Cancelled), "{out:?}");
assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().state, BuildState::Cancelled);
- // Nothing ran, so nothing to undo.
let shim = env.cfg.hooks.shim_dir.clone().unwrap();
assert_eq!(aur_build::shims::called_with(&shim, "repo-add", ""), 0);
assert!(db::accepted_release(&env.db, "plain-make").unwrap().is_none());
- // A cancelled build is not a failure and is not retried.
assert_eq!(env.query_i64("SELECT count(*) FROM build WHERE state='failed'", &[]), Some(0));
}
#[test]
fn a_failed_build_leaves_the_index_serving_the_old_version_and_says_so() {
- // §8.4: "v2 approved, build failed, index still serving v1". The dangerous
- // failure mode is a package that looks healthy while the new version never
- // arrived.
let (mut env, fx) = env_with_fixture("plain-make");
- // Publish v1 for real.
let c = approved(&env, "plain-make");
let id = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap();
pipeline::run(&env.cfg, &env.db, &id).unwrap();
assert_eq!(db::index_version(&env.db, "plain-make").unwrap().as_deref(), Some("1.0-1"));
- // v2 is approved and its build fails deterministically.
fx.bump(&[("pkgver", "2.0")]);
env.set_shim_fail("makepkg");
let c2 = approved(&env, "plain-make");
@@ -144,7 +128,6 @@ fn a_failed_build_leaves_the_index_serving_the_old_version_and_says_so() {
let out = pipeline::run(&env.cfg, &env.db, &id2).unwrap();
assert!(matches!(out, pipeline::Outcome::Failed { .. }), "{out:?}");
- // The index still serves v1 — correct — and the system knows v2 never landed.
assert_eq!(db::index_version(&env.db, "plain-make").unwrap().as_deref(), Some("1.0-1"));
let unbuilt = db::approved_but_unbuilt(&env.db).unwrap();
assert_eq!(unbuilt.len(), 1, "the failed approval must be surfaced: {unbuilt:?}");
@@ -152,7 +135,6 @@ fn a_failed_build_leaves_the_index_serving_the_old_version_and_says_so() {
assert_eq!(unbuilt[0].approved, "2.0-1");
assert_eq!(unbuilt[0].serving, "1.0-1");
- // And it is on the surfaces a human actually looks at.
let web = Web::attach(env, fx);
let attention = web.get("/attention");
assert!(attention.body.contains("Approved but unbuilt"), "no Attention section: {}", &attention.body[..600.min(attention.body.len())]);
@@ -164,8 +146,6 @@ fn a_failed_build_leaves_the_index_serving_the_old_version_and_says_so() {
#[test]
fn a_transient_failure_retries_but_a_deterministic_one_never_does() {
- // The retry policy is asserted at the state machine level here; the dispatch
- // tests cover it through the pool.
let (mut env, _fx) = env_with_fixture("build-fails");
let id = queued(&env, "build-fails");
let pool = aur_build::pipeline::dispatch::Pool::spawn(std::sync::Arc::new(env.cfg.clone()), env.db.clone());
@@ -182,7 +162,6 @@ fn a_transient_failure_retries_but_a_deterministic_one_never_does() {
pool.shutdown();
assert_eq!(state, BuildState::Failed);
assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().attempt, 1, "a deterministic failure must not retry");
- // The release stays approved_but_unbuilt rather than vanishing.
assert_eq!(db::approved_but_unbuilt(&env.db).unwrap().len(), 1);
let _ = &mut env;
}