diff options
Diffstat (limited to 'tests/vcs.rs')
| -rw-r--r-- | tests/vcs.rs | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/tests/vcs.rs b/tests/vcs.rs index b1edd51..62efe5f 100644 --- a/tests/vcs.rs +++ b/tests/vcs.rs @@ -1,10 +1,3 @@ -//! Stage A / Stage B: the VCS watcher (§5.2). -//! -//! The whole point of the two-stage funnel is that the expensive thing (clone + -//! run `pkgver()`) happens only when the cheap thing (`git ls-remote`) says -//! something moved. These tests assert both halves: that the answer is right, -//! and that it was paid for only once. - mod common; use aur_build::db::{self, model::*}; @@ -30,8 +23,7 @@ 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 — a pkgbase that builds from more than one - // upstream can have either one move alone (§5.2). + // 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(); @@ -74,8 +66,8 @@ 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 — this is the common case, every day. + // 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(); @@ -93,12 +85,12 @@ fn stage_b_resolves_pkgver_and_captures_the_pins() { // The candidate's version is what `pkgver()` computed, not the frozen field. assert_eq!(c.pkgver, "r1.0"); assert_eq!(c.pkgrel, "1"); - // And the pins it will be built from are recorded now, while the clone is - // already there — not later, which would mean cloning again. + // 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, even under the same version string. + // 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(), @@ -124,9 +116,8 @@ fn stage_b_is_cached_on_pkgbase_recipe_and_tip() { 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, which is what keeps a chatty upstream from turning - // detection into a build loop. + // 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"); @@ -139,9 +130,8 @@ 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. Two threads, one slot: the second must not enter - // until the first releases. + // 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(); @@ -164,9 +154,8 @@ 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; claiming "nothing moved" would be a lie - // that silently stops detection. + // 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(), ) @@ -189,8 +178,8 @@ 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 - // there is nothing to approve. It becomes a notice, and is never dropped. + // §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(); @@ -199,8 +188,8 @@ 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 (that is what a - // degenerate `pkgver()` does), so nothing is publishable. + // 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"); |
