summaryrefslogtreecommitdiffstats
path: root/src/shims
diff options
context:
space:
mode:
Diffstat (limited to 'src/shims')
-rw-r--r--src/shims/mod.rs24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/shims/mod.rs b/src/shims/mod.rs
index 675d69d..b56b067 100644
--- a/src/shims/mod.rs
+++ b/src/shims/mod.rs
@@ -7,7 +7,6 @@ use crate::hash;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
-// FakePackage stays `pub`: the whole `shims` module is `test-support`-gated, so a release build never compiles it.
pub struct FakePackage {
pub name: String,
pub version: String,
@@ -53,7 +52,6 @@ impl FakePackage {
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
-// FakeInstalled stays `pub`: the whole `shims` module is `test-support`-gated, so a release build never compiles it.
pub struct FakeInstalled {
pub name: String,
pub version: String,
@@ -62,7 +60,6 @@ pub struct FakeInstalled {
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
-// Manifest stays `pub`: returned by `manifest()`, which the shim tests read; the module is `test-support`-gated.
pub struct Manifest {
pub name: String,
pub build: String,
@@ -141,13 +138,7 @@ fn forced_fail(tool: &str) -> bool {
std::env::var("AUR_SHIM_FAIL").is_ok_and(|v| v == tool)
}
-/// Read back the shim's invocation log.
-///
-/// Test-tier only. The shim *appends* to `invocations.jsonl` in production —
-/// that is how a fake tool leaves evidence — but nothing in the crate reads the
-/// file back; `called_with` below is the only reader and it is gated with this.
-/// The census credited this function with production callers at the two lines
-/// that name the *filename* in a string, which is not a call.
+/// Read back the shim's invocation log; the shim only ever appends to it.
#[cfg(feature = "test-support")]
pub fn invocations(dir: &Path) -> Vec<serde_json::Value> {
let path = dir.join("invocations.jsonl");
@@ -157,12 +148,7 @@ pub fn invocations(dir: &Path) -> Vec<serde_json::Value> {
}
}
-/// How many times the shim recorded `tool` being called with `needle` in its
-/// arguments.
-///
-/// Test-tier only. The shim *writes* the invocation log in production — that is
-/// how a fake tool leaves evidence — but nothing in the crate reads it back;
-/// only tests ask what a build actually did.
+/// How many times the shim recorded `tool` being called with `needle`.
#[cfg(feature = "test-support")]
pub fn called_with(dir: &Path, tool: &str, needle: &str) -> usize {
invocations(dir)
@@ -197,7 +183,7 @@ pub fn run(tool: &str) -> i32 {
}
}
-/// Reached only through `run`, which matches the tool name to it. The tool name appears in test strings, which is not a caller.
+/// Reached only through `run`, which matches the tool name to it.
fn mkarchroot(args: &[String]) -> Result<i32, String> {
let mut target = None;
let mut skip = false;
@@ -221,7 +207,6 @@ fn mkarchroot(args: &[String]) -> Result<i32, String> {
Ok(0)
}
-/// Reached only through `run`, which matches the tool name to it. The tool name appears in test strings, which is not a caller.
fn makechrootpkg(args: &[String], m: &Manifest) -> Result<i32, String> {
if !args.iter().any(|a| a == "-r") {
return Err("makechrootpkg: expected -r <chroot>".into());
@@ -397,7 +382,6 @@ fn fake_sig(bytes: &[u8]) -> Vec<u8> {
format!("-----BEGIN FAKE PGP SIGNATURE-----\n{}\n-----END FAKE PGP SIGNATURE-----\n", hash::hex(bytes)).into_bytes()
}
-/// Reached only through `run`, which matches the tool name to it. The tool name appears in test strings, which is not a caller.
fn makepkg(args: &[String], m: &Manifest) -> Result<i32, String> {
if args.iter().any(|a| a == "--vercheck" || a == "-V-check") {
let v = m.vercheck.clone().unwrap_or_else(|| "1.0-1".into());
@@ -447,7 +431,6 @@ fn makepkg(args: &[String], m: &Manifest) -> Result<i32, String> {
}
}
-/// Reached only through `run`, which matches the tool name to it. The tool name appears in test strings, which is not a caller.
fn pacman(args: &[String]) -> Result<i32, String> {
if args.iter().any(|a| a == "-U") {
for path in args.iter().filter(|a| !a.starts_with('-')) {
@@ -598,7 +581,6 @@ fn pkginfo_fields(pkg_bytes: &[u8]) -> Result<(String, String, String, String),
Ok((info.name, info.version, info.arch, extra))
}
-/// Reached only through `run`, which matches the tool name to it. The tool name appears in test strings, which is not a caller.
fn gpg(args: &[String]) -> Result<i32, String> {
let out = args.iter().position(|a| a == "--output" || a == "-o").and_then(|i| args.get(i + 1)).cloned();
let target = args.iter().rev().find(|a| !a.starts_with('-') && Some(*a) != out.as_ref());