From 6872e81644546a9ccd0e1420c3ef64a26358f78a Mon Sep 17 00:00:00 2001 From: aur-build Date: Mon, 23 Nov 2026 13:56:40 +0000 Subject: tests: the ratchet says what the code says now MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The architecture test's own essays were the largest block of prose left in the tree, and the test-file headers were notes about which tests moved into `src/` — history the file no longer needs. Removing those mentions moved two measured numbers, and the ratchet was right to complain. `db.Writer` now sits in the allowlist with the compiler fact that keeps it `pub` — narrowing it makes every call site say `type db::Writer is private` — and the counts that got smaller are written back at the smaller value, as the ratchet demands. --- tests/common/mod.rs | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) (limited to 'tests/common/mod.rs') diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 5194035..6d05c3b 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,9 +1,7 @@ -// Every test binary compiles this file, so a helper that one of them uses is -// dead code in the other twenty — 46 of the items below warn that way, and an -// item-scoped allowance on each would say the same thing 46 times. The check -// that does the work is `the_test_helpers_are_used` in tests/architecture.rs: -// it reads this file and fails on any item, `pub` or private, that no test -// names, so the allowance hides noise and cannot hide dead weight. +// Every test binary compiles this file, so a helper one of them uses is dead +// code in the other twenty. `the_test_helpers_are_used` in tests/architecture.rs +// fails on any item here that no test names, so the allowance below hides noise +// but cannot hide dead weight. #![allow(dead_code)] use std::collections::HashMap; @@ -131,11 +129,8 @@ impl Env { self.cfg.hooks.shim_fail = Some(tool.to_string()); } - /// Run a statement the library deliberately does not expose. - /// - /// Fixtures use this to put a row in a state production would take a long - /// way to reach — forcing a risk level, say — rather than the library - /// growing a public setter that exists only for tests. + /// Run a statement the library deliberately does not expose, so a fixture + /// can reach a state without the library growing a test-only setter. pub fn execute(&self, sql: &str, params: &[P]) { let c = rusqlite::Connection::open(self.cfg.db_path()).unwrap(); let refs: Vec<&dyn rusqlite::ToSql> = params @@ -298,9 +293,8 @@ pub fn materialize_fixture(root: &Path, name: &str) -> Fixture { copy_tree(&pristine.upstream2, &upstream2); } if pristine.path_dependent { - // The recipe names directories this test owns, so the copied commit - // still speaks the cache's paths. Rewrite the work tree and fold it into - // the single commit rather than rebuilding the repo from nothing. + // The recipe names directories this test owns, so the copied commit has + // to speak the cache's paths. for (fname, body) in &pristine.recipe_files { std::fs::write(aur.join(fname), substitute(body, &subs)).unwrap(); } @@ -349,8 +343,6 @@ fn read_corpus(name: &str) -> Corpus { } /// The fixture repos, built once per test binary rather than once per test. -/// Everything in them is path-independent except a recipe that names its own -/// directories, so a test copies the trees and only rewrites when it must. #[derive(Clone)] struct Pristine { aur: PathBuf, @@ -426,9 +418,8 @@ fn copy_tree(from: &Path, to: &Path) { let entry = entry.unwrap(); let path = entry.path(); let name = entry.file_name(); - // A git lock is a claim, not content: it can appear in the listing and - // vanish before the copy, and a copied `index.lock` would make the copy - // refuse to run at all. + // A git lock is a claim, not content: a copied `index.lock` would make + // the copy refuse to run at all. if name.to_string_lossy().ends_with(".lock") { continue; } @@ -549,9 +540,8 @@ pub fn git(dir: &Path, args: &[&str]) -> String { let out = std::process::Command::new("git") .arg("-C") .arg(dir) - // No test is about git's own housekeeping, and a detached maintenance run - // outlives the command that spawned it: it can repack or lock a repo - // while another test is still copying it. + // A detached maintenance run outlives the command that spawned it and + // can repack or lock a repo another test is still copying. .args(["-c", "maintenance.auto=false", "-c", "gc.auto=0"]) .args(args) .env("GIT_AUTHOR_NAME", "t") -- cgit v1.2.3