diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 17:09:59 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 17:09:59 +0000 |
| commit | e757979f1a2afdbe7146066345bb9acd19d3b151 (patch) | |
| tree | 30d5f5fbccd25ea7bf01c5202684af463b74e7d3 /tests/shims.rs | |
| parent | 94c318f13264bb3c00a9f3057ba2e1aafb57c9e4 (diff) | |
| download | aur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.tar.gz aur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.zip | |
comments: say why, not what
Every module-level `//!` header is gone, and the comments that remained
either re-explained the line below them or had grown into paragraphs.
Density went from one comment line per 6.7 lines of code to one per 10.
827 insertions against 2194 deletions across 86 files.
What survived: the invariants (I1-I12), the design cross-references into
DESIGN.md, and the notes recording a bug that was found and fixed — those
are the comments that carry weight, because they answer a question the
code cannot answer about itself. What did not: restating a function
signature in prose, and narration of the statement underneath.
Diffstat (limited to 'tests/shims.rs')
| -rw-r--r-- | tests/shims.rs | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/tests/shims.rs b/tests/shims.rs index d512bd7..d06a81e 100644 --- a/tests/shims.rs +++ b/tests/shims.rs @@ -1,7 +1,3 @@ -//! The §16a test harness itself: toolchain shims and the fake-package corpus. -//! -//! If these tests fail, nothing above the harness can be trusted. - mod common; use std::path::{Path, PathBuf}; @@ -62,9 +58,7 @@ 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: the - // harness is only a faithful stand-in if it reads a package the way the - // pipeline will (§6 M-4). + // 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")); @@ -86,8 +80,8 @@ 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. + // 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(); @@ -176,9 +170,8 @@ 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, - // and `-Q` must report exactly what landed. + // 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(); @@ -208,8 +201,8 @@ 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: name it with some other digest's hex. + // 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( @@ -251,8 +244,8 @@ fn mkarchroot_creates_a_warm_root() { assert!(root.join("SHIM-ROOT").exists()); } -/// Every fixture in the corpus must be drivable through the shims. This is the -/// executable documentation of the §16 edge cases. +/// 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(); @@ -359,16 +352,10 @@ fn shim_environment_reaches_child_processes_through_the_config() { assert!(s.contains("manifest.json"), "{s}"); } -// --------------------------------------------------------------------------- -// repo-add's database filename. -// -// The shim used to write the database wherever it was told to, and the pipeline -// took that literally: it rendered the index to `<db>.tar.gz.tmp` and renamed it -// into place. Real repo-add rejects that filename as a usage error, so every -// publish test in this suite passed while the first real package anyone tried to -// publish died at the last step. A shim must be as strict as the tool it stands -// in for, or it is not a test of the tool. -// --------------------------------------------------------------------------- +// 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. @@ -407,8 +394,7 @@ 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. Gated and noted rather than skipped silently, in the -/// shape of `versions::vercmp_matches_the_system_oracle`. +/// 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() { @@ -431,8 +417,7 @@ 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, and does it clean up after -/// itself while doing it? +/// 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"); @@ -458,9 +443,8 @@ 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. A - // leftover would mean a publish that died on a path that never cleaned up. + // 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() |
