diff --git a/ci/check-ports.py b/ci/check-ports.py index f799bb17b4..9569a27baf 100644 --- a/ci/check-ports.py +++ b/ci/check-ports.py @@ -51,21 +51,51 @@ def ports(root, ini): result.add(name) return result +# `wall_sites` needs one of these words in the source: `WALL` spells `Instant::`, `SystemTime::` or +# `.elapsed(`, and the alias test needs the token `Instant` or `SystemTime`. A file without any of +# them cannot hold a wall-clock operation, so this rule does not lex or classify it: lexing the +# ~690 files of the scopes (and the wholly-test classification of every scope) was most of this +# gate's 4.6 s of CPU, run once per `ci/check-deps.sh` and so ~100 times by tests/test_harness.py. +# The skip changes what an UNLEXABLE file does here, never what a wall site does: a file with no +# wall word and an unterminated raw string no longer fails THIS rule. `ci/check-list-caps.py` (a step +# of ci/check-python-steps.txt) reports it instead: it runs `rtm.lex` over every production file under +# every `rust-modules/*/src` and `rust-modules/src` (all these scopes), and `rtm.wholly_test_files` over +# each of those roots, and lets the ValueError fail the step. Test-named files (`*_tests.rs`, `tests.rs`, +# a `tests/` directory) and wholly-test files are the ones it does not lex: test code, which rustc rejects +# when it is not Rust. `wholly_test_files(scope)` is computed only for a scope holding a wall site, so an +# unbalanced token group fails this rule only then (ci/test_check_ports.py pins both halves). +NEEDS_WALL_WORD = re.compile(r'Instant|SystemTime|elapsed') + def check(root=ROOT, ini=None): exempt = ports(root, ini or root / 'ci/ports.ini') - tests = set() - for scope in SCOPES: - path = root / scope - if path.is_dir(): tests.update(rtm.wholly_test_files(path)) + scope_paths = [root / scope for scope in SCOPES] + wholly_tests = {} + def is_wholly_test(path): + """`path` is in the union of `wholly_test_files(scope)` over the directory scopes holding it, + each computed on its first use: a scope whose files carry no wall-clock word never is.""" + for scope in scope_paths: + if scope.is_dir() and scope in path.parents: + if scope not in wholly_tests: wholly_tests[scope] = rtm.wholly_test_files(scope) + if path.resolve() in wholly_tests[scope]: return True + return False problems = [] files = set() - for scope in SCOPES: - path = root / scope + for path in scope_paths: files.update(path.rglob('*.rs') if path.is_dir() else ([path] if path.exists() else [])) for path in sorted(files): name = path.relative_to(root).as_posix() - if name in exempt or path.resolve() in tests: continue - if wall_sites(shape.production_tokens(path.read_text(encoding='utf-8'))): + if name in exempt: continue + source = path.read_text(encoding='utf-8') + if not NEEDS_WALL_WORD.search(source): continue + try: has_wall_site = wall_sites(shape.production_tokens(source)) + except ValueError: + # A file with a wall word that cannot be lexed fails this gate, EXCEPT a wholly-test file, + # which this rule never lexed (it skipped those first). Classifying before lexing every + # such file would compute all seven scopes' wholly-test sets (about twice this gate's time); + # classifying only the file that failed to lex costs nothing on a valid tree. + if is_wholly_test(path): continue + raise + if has_wall_site and not is_wholly_test(path): problems.append(f'{name}: wall clock outside ci/ports.ini') return problems diff --git a/ci/check-python-steps.txt b/ci/check-python-steps.txt index 6017d0aa3b..92c0ba9ce1 100644 --- a/ci/check-python-steps.txt +++ b/ci/check-python-steps.txt @@ -21,11 +21,63 @@ # `ci/test_check_collisions.py` runs these steps side by side to check the first rule; a step that # breaks one of them shows up there rather than as a flake in somebody else's `make check`. # -# ORDER is only the START order: the sixteen slowest steps (measured 2026-10-07) come first, so the -# last one to start is a short one; the run lasts as long as the longest step plus the queue. A new -# step goes at the END; move it up only after measuring (`make check-python-rest` prints each step's -# wall and CPU time and the slowest three). +# ORDER is only the START order: the nine slowest steps of the CI run measured 2026-11-14 (the first +# block below) come first, then the thirteen others of the sixteen slowest measured 2026-10-07 (three of +# those sixteen are among the nine), so the last one to start is a short one; the run lasts as long as +# the longest step plus the queue. A new step goes at the END; move it up only after measuring +# (`make check-python-rest` prints each step's wall and CPU time and the slowest three). +# The nine slowest steps (CI, 2026-11-14: machine-shape 225 s, build-gc 98 s, arm-profile 71 s, check-elf 56 s, +# transition-arguments 47 s, disk-budget 44 s, disk-preflight 44 s, tv-lock 43 s, collisions 40 s) start first: +# test_check_machine_shape.py sat 110th and ended the job at 413 s (it starts ~190 s in, then runs 225 s). + +# The machine-shape gate (ci/machines.ini, docs/sans-io.md): a state machine listed there keeps its state private (a `pub`, +# `pub(crate)` or `pub(super)` field of the listed struct fails, as does a stale entry), so its one writer stays `step` and a new +# way to change it is a new event. It also REPORTS, and never fails on, each machine's `bool` and `Option<..>` field counts: a +# report-only flag ratchet. Pure lexing, no cargo; the self-tests run on synthetic trees in a private temp dir. +python3 ci/test_check_machine_shape.py +# tools/build-gc.sh against disposable repositories, fleet dirs and caches: every OTHER reclaim mode refuses under a held FFmpeg lock, a +# live checkout is spared, `--auto`'s order is the planner's (and its `--worktrees` stage spares a lane inside the idle window, and one holding an ignored file that is not build output), +# `--worktrees` judges a lane against `origin/main` without refreshing its index, and `--evict PLAN` deletes exactly what the plan +# names after re-probing it: it refuses paths that are not derived build trees, skips a tree that turned live, goes on under an +# FFmpeg lock, and never takes a /tmp tree that only looks old. `--evict` runs only inside the fixture's own directories. +python3 ci/test_build_gc.py +# `ARM_PROFILE`: a plain local build compiles the ARM staticlib with the fast `tvdev` profile and +# everything that ships or runs in CI keeps fat-LTO `release`; resolved through print-bench-config. +python3 ci/test_arm_profile.py +python3 ci/test_check_elf.py +python3 ci/test_transition_arguments.py +# tools/disk-budget.py, the disk budget's inventory and planner (docs/disk-budget.md): the ladder's order, stopping at the line, +# refusing only when the whole ladder cannot free the build's estimate plus the reserve, and NEVER planning the current checkout +# below rung 6 (nor, there, the tree being built), a live, tracked, pkg/, vendor/ or non-PlxNative tree; private-byte accounting under hard links; `origin/main` merged detection +# (squash merges, a stale local main, nothing written to the repository); `report` changes nothing; the plan file `build-gc.sh --evict` +# reads (format, order, the stale slot, rung-6 `current`), `settle`, the cargo seed never planned, a /tmp tree aged by ctime so a +# backdated fixture is never a candidate, the probes (`probe`, `tmp-trees`), and that collecting an inventory never rewrites a +# lane's index. Synthetic inventories plus private temp repositories, a stubbed lsof, no real /tmp scan. +python3 ci/test_disk_budget.py +# The disk budget at every build entry: `make disk-preflight` is `tools/disk-budget.py preflight` and an ORDER-ONLY prerequisite of +# every Makefile target that runs cargo. Static: the Makefile is parsed and every target whose recipe runs cargo (directly or through a +# script) must be in `make -s print-disk-entries`, with the prerequisite after the `|`, before the build starts, and the recursive +# `$(MAKE)` lines carrying PLX_DISK_BUDGET_DONE. Dynamic, on a fixture repository with PLX_GC_TEST_FREE_KIB and stubbed lsof/pgrep: +# at comfort nothing starts and the planner is not imported; below the reserve with nothing to evict it refuses with the reason; below +# comfort it evicts idle trees and never the tree being built; the marker and PLX_MIN_FREE_MB=0 are no-ops; the auto lock is +# taken, a live holder is waited on for a bounded time (one --wait-secs deadline for the whole preflight) and no plan is made while it runs (a finished or stale holder is taken over); the inventory cache; a pretend emergency is never planned over real +# trees; the cold store's unpark of an absent parked tree: the cheap no-gos (config removed, volume unmounted) come before any lock wait, the +# lock is held to claim the copy and not across it (two trees restore at once), a claimed or dead-claimed tree, and the free-space rule. `make -n` and `make -s print-*` only, no cargo. +python3 ci/test_disk_preflight.py +# The TV lock's own protocol suite, with NO television: the device half runs under a local sh in a temp dir, and the +# HEADS-UP cases run the real `acquire`/`break` as children with their own lane, lease directory and lock path (one +# line on a new lease, including your own expired one, none on a live renew or a refusal). It also runs the pre-flight's +# verdict table (IDLE / IN USE / UNKNOWN) on fixture replies, cuts a hung probe off at PLX_TV_PREFLIGHT_SECS, and runs +# `with` for real: it refuses to start on IN USE, PLX_TV_IN_USE_OK overrides, and its renewer's whole process tree dies +# with it. That spawns and kills background processes, so it takes about 20 s, not milliseconds. Then the PostToolUse hook +# that turns the HEADS-UP and IN USE lines into reminders: payload shapes, the failure and unrelated cases, malformed +# stdin. Both host-only. +tools/tv-lock.sh selftest +# Nothing that runs at once may collide: two checkouts running the scratch-writing steps (test-compat.py, +# the C unit tests) at once, and a mix of different steps run together as the runner runs this file, +# each against one shared TMPDIR; and no test source binds a fixed port. +python3 ci/test_check_collisions.py # The `check` lock wrapper's own suite: two shared runs at once and a third waiting (naming both # holders), a SIGKILLed holder freeing its slot, PLX_CHECK_SLOTS=1 serializing, exclusive mode for # the benchmarks (blocks and is blocked by shared runs, not starved by a stream of them, two @@ -39,17 +91,6 @@ python3 ci/test_build_bench.py # one record per day (a same-day re-run replaces it), nothing written for a failed benchmark, a red `check` costing only # its own rows, a noisy day marked and kept, nothing identifying in the runner block. Synthetic documents, no cargo. python3 ci/test_build_history.py -# tools/build-gc.sh against disposable repositories, fleet dirs and caches: every OTHER reclaim mode refuses under a held FFmpeg lock, a -# live checkout is spared, `--auto`'s order is the planner's (and its `--worktrees` stage spares a lane inside the idle window, and one holding an ignored file that is not build output), -# `--worktrees` judges a lane against `origin/main` without refreshing its index, and `--evict PLAN` deletes exactly what the plan -# names after re-probing it: it refuses paths that are not derived build trees, skips a tree that turned live, goes on under an -# FFmpeg lock, and never takes a /tmp tree that only looks old. `--evict` runs only inside the fixture's own directories. -python3 ci/test_build_gc.py -python3 ci/test_check_elf.py -# Nothing that runs at once may collide: two checkouts running the scratch-writing steps (test-compat.py, -# the C unit tests) at once, and a mix of different steps run together as the runner runs this file, -# each against one shared TMPDIR; and no test source binds a fixed port. -python3 ci/test_check_collisions.py # `tools/tv-config.sh`, the ONE resolver for the TV address and Wake-on-LAN MAC (this checkout's # .tv-host/.tv-mac, the main checkout's, then ~/.config/plxnative/), and every reader of it # (tv-ssh, wake-tv, the Makefile's TV, tests/run.py, stream-screen.py), against a throwaway repo @@ -212,9 +253,6 @@ python3 tools/test_ci_test_results.py # a pass, every `test result:` line is printed), both against a fake cargo; nothing is compiled. python3 ci/test_test_crate.py python3 ci/test_cargo_test_parallel.py -# `ARM_PROFILE`: a plain local build compiles the ARM staticlib with the fast `tvdev` profile and -# everything that ships or runs in CI keeps fat-LTO `release`; resolved through print-bench-config. -python3 ci/test_arm_profile.py # `HOST_THREADS`: rustc's parallel front end for the local host test builds only; off for CI, RELEASE, # SYMBOLS and every non-debug flavour, and named by no ARM, simulator, clippy or workflow line. python3 ci/test_host_threads.py @@ -307,49 +345,17 @@ python3 ci/gen-third-party-notices.py --check # --skip-if-missing only so a runner without Rust is not red here: CI's host-lint job runs it strict. python3 ci/test_check_vfp.py python3 ci/check-vfp.py --skip-if-missing -# tools/disk-budget.py, the disk budget's inventory and planner (docs/disk-budget.md): the ladder's order, stopping at the line, -# refusing only when the whole ladder cannot free the build's estimate plus the reserve, and NEVER planning the current checkout -# below rung 6 (nor, there, the tree being built), a live, tracked, pkg/, vendor/ or non-PlxNative tree; private-byte accounting under hard links; `origin/main` merged detection -# (squash merges, a stale local main, nothing written to the repository); `report` changes nothing; the plan file `build-gc.sh --evict` -# reads (format, order, the stale slot, rung-6 `current`), `settle`, the cargo seed never planned, a /tmp tree aged by ctime so a -# backdated fixture is never a candidate, the probes (`probe`, `tmp-trees`), and that collecting an inventory never rewrites a -# lane's index. Synthetic inventories plus private temp repositories, a stubbed lsof, no real /tmp scan. -python3 ci/test_disk_budget.py -# The disk budget at every build entry: `make disk-preflight` is `tools/disk-budget.py preflight` and an ORDER-ONLY prerequisite of -# every Makefile target that runs cargo. Static: the Makefile is parsed and every target whose recipe runs cargo (directly or through a -# script) must be in `make -s print-disk-entries`, with the prerequisite after the `|`, before the build starts, and the recursive -# `$(MAKE)` lines carrying PLX_DISK_BUDGET_DONE. Dynamic, on a fixture repository with PLX_GC_TEST_FREE_KIB and stubbed lsof/pgrep: -# at comfort nothing starts and the planner is not imported; below the reserve with nothing to evict it refuses with the reason; below -# comfort it evicts idle trees and never the tree being built; the marker and PLX_MIN_FREE_MB=0 are no-ops; the auto lock is -# taken, a live holder is waited on for a bounded time (one --wait-secs deadline for the whole preflight) and no plan is made while it runs (a finished or stale holder is taken over); the inventory cache; a pretend emergency is never planned over real -# trees; the cold store's unpark of an absent parked tree: the cheap no-gos (config removed, volume unmounted) come before any lock wait, the -# lock is held to claim the copy and not across it (two trees restore at once), a claimed or dead-claimed tree, and the free-space rule. `make -n` and `make -s print-*` only, no cargo. -python3 ci/test_disk_preflight.py # RUST_INPUTS (the Makefile's hand-kept list of directories whose edits rebuild the app library) must search every crate # the app reaches through `path` dependencies: a crate left out is one whose edits `make` never sees, so `make ipk` packages # the previous library and says nothing. Reads manifests only, no cargo; the self-test plants a missing crate in a temp tree. python3 ci/test_check_rust_inputs.py python3 ci/check-rust-inputs.py -# The machine-shape gate (ci/machines.ini, docs/sans-io.md): a state machine listed there keeps its state private (a `pub`, -# `pub(crate)` or `pub(super)` field of the listed struct fails, as does a stale entry), so its one writer stays `step` and a new -# way to change it is a new event. It also REPORTS, and never fails on, each machine's `bool` and `Option<..>` field counts: a -# report-only flag ratchet. Pure lexing, no cargo; the self-tests run on synthetic trees in a private temp dir. -python3 ci/test_check_machine_shape.py python3 ci/test_check_machine_writer.py python3 ci/check-machine-shape.py # tools/pr-land.py (gate / wait / merge / restack) against a fake `gh` on PATH and an injected sleeper: a failed, pending, missing, draft, behind # or head-moved PR never reaches `gh pr merge` (#387), the polling and backoff, the head-oid race, the verify against a temporary # origin, and a planted secret refused before any `gh` call. Real gh JSON as fixtures; temp dirs only, no network, no sleeping on the poll or race timers (one test lets a hung gh hit a 1 s timeout). python3 tools/test_pr_land.py -# The TV lock's own protocol suite, with NO television: the device half runs under a local sh in a temp dir, and the -# HEADS-UP cases run the real `acquire`/`break` as children with their own lane, lease directory and lock path (one -# line on a new lease, including your own expired one, none on a live renew or a refusal). It also runs the pre-flight's -# verdict table (IDLE / IN USE / UNKNOWN) on fixture replies, cuts a hung probe off at PLX_TV_PREFLIGHT_SECS, and runs -# `with` for real: it refuses to start on IN USE, PLX_TV_IN_USE_OK overrides, and its renewer's whole process tree dies -# with it. That spawns and kills background processes, so it takes about 20 s, not milliseconds. Then the PostToolUse hook -# that turns the HEADS-UP and IN USE lines into reminders: payload shapes, the failure and unrelated cases, malformed -# stdin. Both host-only. -tools/tv-lock.sh selftest python3 .claude/hooks/tv-lock-notify-test.py # The custom agents' files (AGENTS.md, "Harness-specific files"): every `.agents/agents/.md` carries a matching frontmatter # `name`, an explicit `model:` (one documented exemption), a description, a RELATIVE `.claude/agents/.md` symlink that resolves @@ -398,7 +404,6 @@ python3 ci/test_step_scope.py python3 ci/test_machine_readonly.py python3 ci/test_readonly_dependencies.py python3 ci/test_readonly_generated.py -python3 ci/test_transition_arguments.py # tools/cold-store.py, the opt-in cold store that parks idle build trees on a second volume: unconfigured it creates no file anywhere; each # reason `available()` can give (no config, no ditto, an unmounted /Volumes root, the same device as the build tree, under min_free_gib, a diff --git a/ci/test_check_ports.py b/ci/test_check_ports.py index 0323917733..0d06aa96e0 100644 --- a/ci/test_check_ports.py +++ b/ci/test_check_ports.py @@ -7,6 +7,10 @@ spec = importlib.util.spec_from_file_location('check_ports', Path(__file__).with_name('check-ports.py')) gate = importlib.util.module_from_spec(spec) spec.loader.exec_module(gate) +caps_spec = importlib.util.spec_from_file_location('check_list_caps', Path(__file__).with_name('check-list-caps.py')) +caps = importlib.util.module_from_spec(caps_spec) +caps_spec.loader.exec_module(caps) +UNTERMINATED = 'const S: &str = r#"never closed;\n' class Ports(unittest.TestCase): def fixture(self, name='rust-modules/data/src/job_ports.rs', source='fn run() { Instant::now(); }', ini=None): temp = tempfile.TemporaryDirectory() @@ -38,6 +42,24 @@ def test_spacing_and_noncall_clock_references_are_reads(self): for source in ('fn f() { let now = Instant :: now; }', 'fn f() { i . elapsed ( ); }'): root = self.fixture(ini='', source=source) self.assertTrue(gate.check(root)) + def test_unlexable_file_with_a_wall_word_fails_unless_it_is_wholly_test(self): + root = self.fixture(ini='', source='fn run() { Instant::now(); }\n' + UNTERMINATED) + with self.assertRaisesRegex(ValueError, 'unterminated Rust raw string'): gate.check(root) + root = self.fixture(name='rust-modules/session/src/lib.rs', ini='', source='#[cfg(test)] mod fixture;') + (root / 'rust-modules/session/src/fixture.rs').write_text('fn test() { Instant::now(); }\n' + UNTERMINATED) + self.assertEqual(gate.check(root), []) + def test_unlexable_file_without_a_wall_word_is_left_to_the_list_caps_gate(self): + root = self.fixture(ini='', source='fn run() {}\n' + UNTERMINATED) + self.assertEqual(gate.check(root), []) + with self.assertRaisesRegex(ValueError, 'unterminated Rust raw string'): caps.read_hits(root / 'rust-modules') + def test_unbalanced_token_group_fails_the_wall_rule_only_when_a_wall_site_needs_classifying(self): + root = self.fixture(name='rust-modules/data/src/lib.rs', ini='', source='mod other; fn f() { ( }') + other = root / 'rust-modules/data/src/other.rs' + other.write_text('fn run() {}') + self.assertEqual(gate.check(root), []) + with self.assertRaisesRegex(ValueError, 'unbalanced Rust token group'): caps.read_hits(root / 'rust-modules') + other.write_text('fn run() { Instant::now(); }') + with self.assertRaisesRegex(ValueError, 'unbalanced Rust token group'): gate.check(root) def test_directories_globs_traversal_and_absolute_paths_are_rejected(self): for name in ('rust-modules/data/src', 'rust-modules/data/src/*.rs', '../outside.rs', '/absolute.rs', 'rust-modules/data/src/../x.rs', 'rust-modules/data/src/./x.rs'): diff --git a/tests/test_harness.py b/tests/test_harness.py index dfa1b3b491..bec1db99a2 100644 --- a/tests/test_harness.py +++ b/tests/test_harness.py @@ -8690,8 +8690,22 @@ def run(self, result=None): self.doCleanups() raise + _real_tree_lock = threading.Lock() + _real_tree_run = None + + @classmethod + def _real_tree(cls): + """One run of the gate over the CHECKOUT, shared by the two tests that read it. Nothing in + this class edits the checkout (`test_self_tests_never_touch_the_real_tree`), so the second + reader would only repeat the first's ~25 s of CPU.""" + with cls._real_tree_lock: + if cls._real_tree_run is None: + cls._real_tree_run = subprocess.run([os.path.join(cls.ROOT, "ci", "check-deps.sh")], + capture_output=True, text=True) + return cls._real_tree_run + def test_check_deps_is_green(self): - r = subprocess.run([os.path.join(self.ROOT, "ci", "check-deps.sh")], capture_output=True, text=True) + r = self._real_tree() self.assertEqual(r.returncode, 0, r.stdout + r.stderr) def test_self_tests_never_touch_the_real_tree(self): @@ -8708,7 +8722,7 @@ def test_self_tests_never_touch_the_real_tree(self): def test_the_private_copy_grades_exactly_like_the_real_tree(self): """The copy must carry every input `ci/check-deps.sh` reads: a missing one makes a gate see nothing and pass (or fail) for a reason the real tree would not share.""" - real = subprocess.run([os.path.join(self.ROOT, "ci", "check-deps.sh")], capture_output=True, text=True) + real = self._real_tree() copy = subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], capture_output=True, text=True) self.assertEqual((copy.returncode, copy.stdout), (real.returncode, real.stdout), copy.stderr) @@ -8749,9 +8763,7 @@ def _plant(self, name, content, crate_dir=None): it is invisible to cargo (nothing declares it part of the crate) but not to `find … -name '*.rs'`, which is all these gates scan with — so this is the cheapest way to prove a gate catches a shape without touching a real, permanent source file.""" - # `player/` and `route/` are the media layer crate's now (docs/module-layers.md, Split 11). - crate = crate_dir or ("media" if name.split("/")[0] in ("player", "route") else None) - target = os.path.join(self.tree, "rust-modules", *([crate] if crate else []), "src", name) + target = self._plant_target(name, crate_dir) self.assertFalse(os.path.exists(target), f"stale self-test artifact at {target} — remove it by hand") try: with open(target, "w", encoding="utf-8") as f: @@ -8762,6 +8774,34 @@ def _plant(self, name, content, crate_dir=None): if os.path.exists(target): os.remove(target) + def _plant_target(self, name, crate_dir=None): + """Where `_plant` writes `name` in the private copy.""" + # `player/` and `route/` are the media layer crate's now (docs/module-layers.md, Split 11). + crate = crate_dir or ("media" if name.split("/")[0] in ("player", "route") else None) + return os.path.join(self.tree, "rust-modules", *([crate] if crate else []), "src", name) + + def _plant_all(self, plants): + """`_plant` for several files at once, graded by ONE `ci/check-deps.sh` run. + + `plants` is a list of `(name, content, crate_dir)`, each with its own file name, so the one + run still shows which variants the gate caught: a gate prints the `path:line:text` (or the + path) of every file it flags, and the caller requires each variant's file by name. Run + one variant at a time, a test with N variants cost N runs (about 25 s of CPU apiece).""" + written = [] + try: + for name, content, crate_dir in plants: + target = self._plant_target(name, crate_dir) + self.assertFalse(os.path.exists(target), f"stale self-test artifact at {target} — remove it by hand") + written.append(target) + with open(target, "w", encoding="utf-8") as f: + f.write(content) + return subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], + capture_output=True, text=True) + finally: + for target in written: + if os.path.exists(target): + os.remove(target) + def _mutate(self, relpath, needle, replacement): """Temporarily replace ONE occurrence of `needle` with `replacement` in a REAL tracked file, run ci/check-deps.sh, then unconditionally restore the original bytes — even if the @@ -10012,27 +10052,36 @@ def test_dt_gate_catches_idle_dt_by_name(self): self.assertIn("_check_deps_selftest_dt_fn.rs", out) def test_ui_owner_gate_rejects_retired_global_readers(self): - for name, body in ( + readers = ( ("nav", "plx_ui::nav::page_alpha()"), ("press", "plx_ui::press::scale()"), ("idle", "plx_machine::idle::invalidate()"), - ): + ) + result = self._plant_all([ + (f"_check_deps_selftest_owner_{name}.rs", f"pub fn retired_reader() {{ {body}; }}\n", None) + for name, body in readers + ]) + output = result.stdout + result.stderr + self.assertNotEqual(result.returncode, 0, output) + for name, _ in readers: + rule = "nav" if name == "nav" else "ui-owner-legacy" with self.subTest(reader=name): - result = self._plant( - f"_check_deps_selftest_owner_{name}.rs", - f"pub fn retired_reader() {{ {body}; }}\n", - ) - output = result.stdout + result.stderr - self.assertNotEqual(result.returncode, 0, output) - self.assertIn("nav:" if name == "nav" else "ui-owner-legacy:", output) + # The rule's own report, `path:line:text`, names each planted file: a reader the + # gate missed is absent from the one run's output by name. + self.assertIn(f"{rule}:", output) + self.assertTrue( + any(f"_check_deps_selftest_owner_{name}.rs:" in line for line in output.splitlines()), + f"{rule} did not flag the {name} reader\n{output}") def test_ui_owner_gate_rejects_resurrected_modules(self): - for crate, name in (("ui", "nav.rs"), ("ui", "press.rs"), ("machine", "idle.rs")): + modules = (("ui", "nav.rs"), ("ui", "press.rs"), ("machine", "idle.rs")) + result = self._plant_all([(name, "// Retired module must remain absent.\n", crate) for crate, name in modules]) + output = result.stdout + result.stderr + self.assertNotEqual(result.returncode, 0, output) + self.assertIn("ui-owner-files:", output) + for crate, name in modules: with self.subTest(crate=crate, module=name): - result = self._plant(name, "// Retired module must remain absent.\n", crate_dir=crate) - output = result.stdout + result.stderr - self.assertNotEqual(result.returncode, 0, output) - self.assertIn("ui-owner-files:", output) + self.assertIn(f"ui-owner-files: retired module rust-modules/{crate}/src/{name} exists", output) def test_owned_damage_gate_rejects_a_retired_transport_call(self): result = self._plant("_check_deps_selftest_damage_adapter.rs", diff --git a/tools/test_tv_sched_trace.py b/tools/test_tv_sched_trace.py index 933ad75c5c..eb2d1d1876 100755 --- a/tools/test_tv_sched_trace.py +++ b/tools/test_tv_sched_trace.py @@ -191,6 +191,10 @@ def test_bad_arguments(self): self.assertEqual(rig.run("--tid", "x").returncode, 2) self.assertEqual(rig.run("--read-timeout", "0").returncode, 2) self.assertEqual(rig.run("--app=Debug").returncode, 2) + # Locale-dependent: a bash range like `[a-z]` collates uppercase letters in between in a UTF-8 + # locale (macOS /bin/bash under en_US.UTF-8, the CI runner's), which accepted "Debug" there + # (the daily build bench failed on it, 2026-11-13). A host without that locale falls back to C. + self.assertEqual(rig.run("--app=Debug", env={"LC_ALL": "en_US.UTF-8", "LANG": "en_US.UTF-8"}).returncode, 2) def test_tid_and_app_are_exclusive(self): rig = self.rig(0) diff --git a/tools/tv-sched-trace.sh b/tools/tv-sched-trace.sh index 0057f85d0d..f80139d58c 100755 --- a/tools/tv-sched-trace.sh +++ b/tools/tv-sched-trace.sh @@ -100,7 +100,9 @@ case "$read_timeout" in ''|*[!0-9]*) echo "tv-sched-trace: --read-timeout needs [ "$read_timeout" -ge 1 ] || { echo "tv-sched-trace: --read-timeout must be >= 1" >&2; exit 2; } case "$tid" in *[!0-9]*) echo "tv-sched-trace: --tid needs a thread id" >&2; exit 2 ;; esac [ -z "$app" ] || [ -z "$tid" ] || { echo "tv-sched-trace: --tid and --app are mutually exclusive" >&2; exit 2; } -case "$flavor" in ''|*[!a-z]*) echo "tv-sched-trace: --app needs a flavour name (debug, stable, nightly)" >&2; exit 2 ;; esac +# Spelled out, not `[!a-z]`: a range collates by LOCALE, and in a UTF-8 one (macOS bash 3.2 under +# en_US.UTF-8) it takes "Debug" for lower case. +case "$flavor" in ''|*[!abcdefghijklmnopqrstuvwxyz]*) echo "tv-sched-trace: --app needs a flavour name (debug, stable, nightly)" >&2; exit 2 ;; esac [ -n "$out" ] || out="tv-sched-trace-$(date +%Y%m%d-%H%M%S).gz" HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"