Skip to content

build: Generate the port_comparison unit list from the directory (#1997) - #2554

Merged
zackees merged 2 commits into
masterfrom
infra/1997-port-comparison-discovery
Oct 27, 2026
Merged

zackees merged 2 commits into
masterfrom
infra/1997-port-comparison-discovery

Conversation

@zackees

@zackees zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member

Refs #1997 (part 2, after #2552).

rust/obs-c-oracle/benches/port_comparison.rs carried the last two hand-kept lists every port appended to: the #[path] mod lines and the modules![...] call. #1922 vs #1928 and #1929 vs #1922 collided on them. build.rs now enumerates benches/port_comparison/*.rs and writes the module lines and a run_units() call list into OUT_DIR, so a port adds one file and edits nothing shared.

RED

e62e9115c replaces the sortedness assertions for that file in ci/test_sorted_shared_lists.py with the discovery contract: no #[path] mod list, no modules![, both generated includes present, build.rs enumerates the directory, and every file in the directory defines benchmarks().

uv run -m unittest discover -s ci -p test_sorted_shared_lists.py
FAIL: test_port_comparison_units_are_discovered
AssertionError: Regex matched: '#[path = "port_comparison/'

GREEN

d6031c188:

  • build.rs generates port_comparison_modules.rs and port_comparison_units.rs, and reruns when the directory changes.
  • The file stem is the module name, so core.rs becomes core_units.rs: a mod core at the crate root would make the units' use core::ffi::... paths ambiguous.
  • Absolute #[path] rather than mod x { include!(..) }, because the units open with //! inner docs, which include! cannot carry.

Verified

  • soldr cargo check -p obs-c-oracle --benches: clean.
  • Discovery is behavioral, not just structural: a throwaway zzz_probe.rs was picked up as module(criterion, "zzz_probe", zzz_probe::benchmarks); and compiled with no edit to a shared file, then removed.
  • uv run -m unittest discover -s ci -p test_sorted_shared_lists.py passes (5 tests).

Tiers

Not applicable: this moves build-side registration, not C behavior. No Rust unit, Tier 2 cmocka, Tier 3 differential or Tier 4 protocol surface changes; the bench fixtures and their assertions are untouched.

./lint reaches one pre-existing failure in test_macos_browser_helpers.py from this checkout's modified plugins/obs-browser submodule pointer, which is excluded from the diff. CI is the merge gate.

…1997)

RED: the ci test demanded the hand-kept `#[path] mod` lines and the
`modules![...]` call in `port_comparison.rs` stay sorted. It now fails if
either list exists and requires the two generated includes instead.

`uv run -m unittest discover -s ci -p test_sorted_shared_lists.py`:
test_port_comparison_units_are_discovered FAILs, assertNotRegex matched
`#[path = "port_comparison/audio.rs"]`.
GREEN: build.rs enumerates benches/port_comparison/*.rs and writes the
#[path] module lines and the run_units() call list into OUT_DIR, so a port
adds its own file and edits nothing shared. That was the last hand-kept
list every port appended to; two ports on one file collided in the merge
queue (#1922 vs #1928, #1929 vs #1922).

The file stem is the module name, so core.rs becomes core_units.rs (a
`mod core` at the crate root would make the units' `use core::ffi` paths
ambiguous). Absolute #[path] rather than `mod x { include!() }` because
the units open with //! inner docs, which include! cannot carry.

Verified: `soldr cargo check -p obs-c-oracle --benches` is clean, and a
throwaway zzz_probe.rs appeared in the generated run_units() and compiled
with no edit to a shared file. ci/test_sorted_shared_lists.py passes.
@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Handed off to the coordinator.

Green now that the macOS/Windows lanes finished: 11 checks pass, the rest skip by path scope, base master, CLEAN, and the PR is in the merge queue (since 05:02Z). No submodule pointer change in the diff.

Merged via the queue into master with commit 27c400b Oct 27, 2026
33 checks passed
@zackees
zackees deleted the infra/1997-port-comparison-discovery branch October 27, 2026 05:41
@rdoupe rdoupe mentioned this pull request Oct 27, 2026
5 of 7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant