From 47f6c6db7faedc292fb55b6637a5f6e292ffcaec Mon Sep 17 00:00:00 2001 From: aur-build Date: Sat, 21 Nov 2026 14:01:34 +0000 Subject: tests: make the blanket `allow(dead_code)` in the test tier worth keeping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `tests/common/mod.rs` opened with `#![allow(dead_code)]` and nothing else, which means it could have been hiding helpers no test called. It was not hiding many — `upstream2_commit` and nothing else at file scope — but "not many" is not a check, and the file cannot simply drop the allowance: it is compiled into every test binary, so a helper one binary uses is dead code in the other twenty and the lint fires everywhere and means nothing. So the allowance stays and the check moves up a level. `the_test_helpers_are_used` reads the file and fails on any `pub` item no test writes, counting a type as used when a field or method of it is — `Web::raw_request` hands back a `Raw` no test ever names. `every_fixture_is_referenced` does the same for `testcorpus/`, which had one entry, `git-submodules`, that no test had ever driven; it is gone. Both were checked by planting a dead helper and a dead fixture and watching the suite refuse them. `tests/dispatch.rs` also carried a function whose entire body was an `#[allow(dead_code)]` on `fn unused(_: AtomicBool, _: Config) {}` — the deadest code in the repository, with its two imports behind it. --- tests/common/mod.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'tests/common') diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 5c48923..0b46aeb 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,3 +1,7 @@ +// Every test binary compiles this file, so a helper that one of them uses is +// dead code in the other twenty and the lint would fire everywhere and mean +// nothing. `the_test_helpers_are_used` in tests/architecture.rs is the check +// that does matter: a helper no test names is deleted, not excused. #![allow(dead_code)] use std::collections::HashMap; @@ -507,12 +511,6 @@ impl Fixture { git(&up, &["rev-parse", "HEAD"]) } - 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"]) - } - pub fn upstream_head(&self) -> String { let up = self.upstream.clone().expect("fixture has no upstream repo"); git(&up, &["rev-parse", "HEAD"]) -- cgit v1.2.3