diff options
| author | aur-build <aur-build@localhost> | 2026-11-20 23:38:01 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-20 23:38:01 +0000 |
| commit | c295510e2bb0ee61234536c832dad87a45977fc8 (patch) | |
| tree | d9e73e141da7eb2b09e553998a1435ad023cc0ac /tools | |
| parent | 92ecaabd7c62d029eba239e95cc8a7d2520fe4a9 (diff) | |
| download | aur-build-c295510e2bb0ee61234536c832dad87a45977fc8.tar.gz aur-build-c295510e2bb0ee61234536c832dad87a45977fc8.zip | |
sandbox: keep `Exit` out of the release build
`Exit` is the result of running a command in a sandbox. `pipeline` consumes it
through `Sandbox::run` — `.success()`, `.stderr` — without ever writing the name,
which is why the census called it dead outside `sandbox`.
The type now lives in a private `mod exit` and reaches the world through an
alias that is `pub` only under `test-support` and `pub(crate)` otherwise. A
`pub` definition inside a private module is not a nameable path from outside,
but it is visible enough to appear in a public trait signature, which is what
makes this possible where a plain `pub(crate) struct` is not.
Verified with an external crate: naming `aur_build::sandbox::Exit` in a release
build is `error[E0603]: struct Exit is private`; with `test-support` it compiles.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/test-surface.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/tools/test-surface.py b/tools/test-surface.py index 16929bd..b21133a 100644 --- a/tools/test-surface.py +++ b/tools/test-surface.py @@ -280,7 +280,19 @@ def analyse(): dotted_only = bool(internal) and not bare internal = [h for h, _ in internal] - if gated: + # Feature-conditional visibility: the item is `pub` under `test-support` + # and `pub(crate)` otherwise, declared twice with the same body. It is + # not the same as being gated — production *does* use this item, just + # not from outside its module — and the table should say which is which. + narrowed = gated and any( + re.search(r"pub\(crate\)\s+(?:fn|const|static|type)\s+%s\b" % re.escape(name), t) + or re.search(r"pub\(crate\)\s+use\s+[^;]*::%s\b" % re.escape(name), t) + for t in (open(pp).read() for pp in paths) + ) + + if gated and narrowed: + disp = "narrowed" + elif gated: disp = "already-gated" elif string_only: disp = "narrow" @@ -294,7 +306,7 @@ def analyse(): rows.append(dict( module=mod, name=name, where=("%s:%d" % (occ[0][0], occ[0][1])) if occ else "?", - gated=gated, string_only=string_only, tests=users, + gated=gated, narrowed=narrowed, string_only=string_only, tests=users, internal=internal, dotted_only=dotted_only, confirmed=("%s.%s" % (mod, name)) in CONFIRMED, sites=[list(s) for s in sites], @@ -310,12 +322,13 @@ def analyse(): def render(rows): - order = ["gate", "move-test", "narrow", "residue", "already-gated"] + order = ["gate", "move-test", "narrow", "residue", "narrowed", "already-gated"] title = {"gate": "Gate behind `test-support`", "move-test": "Move the test into the module, then narrow", "narrow": "Narrow — no test actually calls it", "residue": "Residue — `pub` because Rust has no test-conditional visibility", - "already-gated": "Already gated"} + "already-gated": "Already gated", + "narrowed": "Feature-conditional visibility — production uses it, only from inside its module"} out = [open(DOC).read().split("## gate-marker")[0]] if False else [] L = [] A = L.append @@ -395,6 +408,7 @@ if __name__ == "__main__": counts["gate_pending"] = sum(1 for r in rows if r["disp"] == "gate" and not r["gated"]) counts["ungated"] = sum(1 for r in rows if not r["gated"]) counts["total"] = len(rows) + counts["release_exposed"] = sum(1 for r in rows if not r["gated"]) print(json.dumps({"rows": rows, "counts": counts}, indent=1)) elif a.write_budget: rows = analyse() @@ -408,7 +422,7 @@ if __name__ == "__main__": budget = json.load(open(path)) budget["test_surface"] = {k: counts[k] for k in ("gate", "gate_pending", "move-test", "narrow", - "residue", "already-gated", "total", "ungated") + "residue", "narrowed", "already-gated", "total", "ungated") if counts[k]} with open(path, "w") as handle: json.dump(budget, handle, indent=2, sort_keys=True) |
