diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
| commit | 4304b0f336ddba7b4ec6780795059ff2066d105b (patch) | |
| tree | 10edea744a1c2bf3fc363b4dc7f64abac8b1a0d3 /tests/versions.rs | |
| parent | e757979f1a2afdbe7146066345bb9acd19d3b151 (diff) | |
| download | aur-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/versions.rs')
| -rw-r--r-- | tests/versions.rs | 33 |
1 files changed, 0 insertions, 33 deletions
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(); |
