Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion quest/m0/ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,3 @@ The historical samples locate candidates; they are not controlled benchmarks.
- [Padding runs](/quest/m0/ci/quic-padding.md) - moq-quic parses a PADDING run as one frame, keeping the padding stats' meaning
- [tracing-test filter](/quest/m0/ci/tracing-filter.md) - moq-tokio's tests stop forcing every crate to format at TRACE
- [Stats oversize](/quest/m0/ci/stats-oversize.md) - moq-stats refuses an oversized plain snapshot before parsing it back
- [Out-of-crate targets](/quest/m0/ci/out-of-crate-targets.md) - branch checks format and lint a crate whose target file lives outside it, such as the Rust interop clients
26 changes: 0 additions & 26 deletions quest/m0/ci/out-of-crate-targets.md

This file was deleted.

4 changes: 3 additions & 1 deletion sh/dispatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ declare -A scope=(
[workers]='^(infra/|demo/pub/|sh/js/workers\.sh$)'
[moq_sh]='^infra/moq-sh/'
# sh/rs/select.sh widens to the whole workspace for inputs every crate shares.
[rs]='^(\.cargo/|sh/local\.(sh|ts)$|rs/|demo/carla/bridge/|sh/rs/|Cargo\.(toml|lock)$|rust-toolchain\.toml$|\.config/nextest\.toml$)'
# moq-cli builds the Rust interop clients as examples from outside its
# crate; sh/rs/select.test.py fails when a target's directory is missing.
[rs]='^(\.cargo/|sh/local\.(sh|ts)$|rs/|demo/carla/bridge/|test/interop/clients/rust/|sh/rs/|Cargo\.(toml|lock)$|rust-toolchain\.toml$|\.config/nextest\.toml$)'
[bench]='^bench/'
# The CARLA demo's simulator worker and launchers. Its player is a JS
# package and its GPU bridge a Rust crate, so those modules cover them.
Expand Down
23 changes: 18 additions & 5 deletions sh/rs/select.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ select_packages() {
return
fi

grep -qE '^(rs|demo)/' "$list" || return 0

# `--no-deps` keeps this to workspace members and off the network.
local metadata
metadata=$(cargo metadata --format-version 1 --no-deps)
Expand All @@ -53,11 +51,26 @@ select_packages() {
# depend on and the test build never compiles, so it selects that crate alone
# (for its lint) rather than every dependent's tests.
benches=$(sed -n 's|^rs/\([^/]*\)/benches/.*|\1|p' "$list")
# A target can also sit outside its crate, as moq-cli's interop examples
# under test/interop/clients/rust/ do, so a change in the directory of a
# target's root file, which holds that file's modules, seeds its crate.
# Cargo leaves the manifest's `..` in `src_path`, so they are resolved here.
# sh/dispatch.sh's `rs` scope must match those directories too; the
# selector's tests check that.
seeds=$({
sed -n '\|^rs/[^/]*/benches/|d; s|^rs/\([^/]*\)/.*|\1|p' "$list"
jq -r --rawfile list "$list" '($list | split("\n")) as $paths | .packages[]
| (.manifest_path | split("/")) as $p | select($p[-4] == "demo")
| select(any($paths[]; startswith("demo/\($p[-3])/\($p[-2])/"))) | .name' <<<"$metadata"
jq -r --rawfile list "$list" '
def resolve: gsub("\\\\"; "/") | reduce split("/")[] as $s ([];
if $s == ".." then .[:-1] elif $s == "." then . else . + [$s] end) | join("/");
($list | split("\n") | map(select(. != ""))) as $paths
| ((.workspace_root | resolve) + "/") as $root
| .packages[]
| (.manifest_path | split("/")) as $p
| ($p[:-1] | join("/") + "/") as $crate
| select(($p[-4] == "demo" and any($paths[]; startswith("demo/\($p[-3])/\($p[-2])/")))
or any(.targets[].src_path | resolve | select(startswith($crate) | not)
| ltrimstr($root) | sub("[^/]*$"; ""); . as $dir | any($paths[]; startswith($dir))))
| .name' <<<"$metadata"
} | sort -u)
edges=$(jq -r '.packages[] | .name as $name | .dependencies[] | "\($name) \(.name)"' <<<"$metadata")

Expand Down
28 changes: 28 additions & 0 deletions sh/rs/select.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import os
from pathlib import Path
import re
import subprocess
import tempfile
import unittest
Expand Down Expand Up @@ -113,6 +114,33 @@ def test_demo_crate_follows_its_dependencies(self):
self.assertTrue(any("/demo/carla/bridge#moq-carla-bridge" in call for call in calls), calls)
self.assertEqual(self.selected("demo/carla/web/src/main.ts"), [])

def test_out_of_crate_target_selects_its_crate(self):
# moq-cli builds the Rust interop clients as examples from outside its crate.
for path in ("test/interop/clients/rust/tail.rs", "test/interop/clients/rust/added.rs"):
for action in ("lint", "fix"):
with self.subTest(path=path, action=action):
calls = self.selected(path, action=action)
self.assertTrue(any(call.startswith(f"rs {action} ") and "/rs/moq-cli#" in call
for call in calls), calls)
self.assertEqual(self.selected("test/interop/compat/container.rs"), [])

def test_dispatch_scope_covers_out_of_crate_targets(self):
scope = re.search(r"^\s*\[rs\]='([^']*)'", (ROOT / "sh/dispatch.sh").read_text(), re.M).group(1)
metadata = json.loads(subprocess.check_output(
["cargo", "metadata", "--format-version", "1", "--no-deps"], cwd=ROOT, text=True))
root = Path(metadata["workspace_root"])
directories = set()
for package in metadata["packages"]:
crate = Path(package["manifest_path"]).parent
for target in package["targets"]:
source = Path(os.path.normpath(target["src_path"]))
if not source.is_relative_to(crate):
directories.add(source.parent.relative_to(root).as_posix())
self.assertIn("test/interop/clients/rust", directories)
for directory in sorted(directories):
with self.subTest(directory=directory):
self.assertRegex(f"{directory}/added.rs", scope)

def test_a_bench_selects_only_its_crate(self):
bench = "rs/moq-stats/benches/producer_tick.rs"
for action in ("lint", "test"):
Expand Down
Loading