Merge pull request #3167 from aiongg/cl-doctor-split

cl doctor after the split UI test kit
This commit is contained in:
aiongg authored and GitHub committed 2026-11-23 08:55:01 -05:00
commit e3ca63165d
5 files changed
+41 -13

No files matched your search

Generated
+1
View File
@@ -6004,6 +6004,7 @@ dependencies = [
"craft-timeline",
"craft-ui-gallery",
"craft-update",
"epaint_default_fonts",
]
[[package]]
+5
View File
@@ -46,6 +46,11 @@ craft-text = { workspace = true, features = ["suite", "find"] }
craft-theme-store = { workspace = true, features = ["suite"] }
craft-timeline = { workspace = true, features = ["suite", "xml", "otio"] }
# craft-ui-contract's tests ask for the bundled monochrome emoji faces (their font oracle); asked here, every build has
# them, so those tests share egui and the framework with the rest. The feature only adds two byte constants, which
# nothing else reads; egui's emoji fallback is epaint's own feature of the same name, not this one.
epaint_default_fonts = { version = "0.37", features = ["monochrome_emoji_fonts"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
craft-dialogs = { workspace = true, features = ["suite"] }
craft-font-manager = { workspace = true, features = ["suite"] }
+2 -2
View File
@@ -42,8 +42,8 @@ font-manager = ["craft-ui-gallery/font-manager"]
update = ["craft-ui-gallery/update"]
[dependencies]
# The same framework features as the gallery (the runtime's `testing` includes the snapshot renderer), so the
# framework builds once for the gallery, the tests and this bin.
# The same framework features as the gallery (the gallery's `suite` brings the snapshot renderer), so the framework
# builds once for the gallery, the tests and this bin.
craft-behavior = { workspace = true }
craft-ui = { workspace = true, features = ["app", "testing"] }
craft-ui-gallery = { path = "../ui-gallery", default-features = false }
+1 -1
View File
@@ -30,7 +30,7 @@ cargo compiles a crate once per distinct feature set, and every crate above it o
`cl` selects the `feature-root` package beside the package of every command (`-p <crate> -p feature-root`). Its dependencies are the gallery's, with every domain crate's `suite`, so every local build resolves features as the gallery does, and a target directory holds one build of each crate. Nothing of `feature-root` is compiled: its one target is a bin no `cl` command selects (`cl` names the crate's own targets), and only the targets a command names are built, so a render still links one domain crate and a framework crate's tests still link no app. On top, `cl` adds the crate's own test feature (`suite`, else `screen-testing`, else `testing`). The Mac's and CI's commands never select `feature-root` and are unaffected.
Four manifest facts keep this true, and `cl doctor` checks them: `feature-root` lists every optional domain crate of the gallery with the gallery's features, and depends on the gallery without its default features (so the gallery lib's own features stay each command's: `apps` for the gallery, one crate for a render); the story renderer asks its shared dependencies for no feature the gallery's lines lack; dev-dependency lines ask egui for no features (a feature there differs between a crate's tests and everything else); the proc-macro crate pins syn's and proc-macro2's features to everything other derive crates may add, so the one syn every proc macro shares is the same with or without design-lint in the graph. `cl` names any new build of a framework crate in the target directory after each command; after a manifest change one is expected, otherwise run `cl doctor`.
Five manifest facts keep this true, and `cl doctor` checks them: the gallery links each domain crate's stories as an optional dependency behind a feature of its own (so a render links one domain crate); `feature-root` lists every optional domain crate of the gallery with the gallery's features, and depends on the gallery without its default features (so the gallery lib's own features stay each command's: `apps` for the gallery, one crate for a render); the story renderer asks its shared dependencies for no feature beyond what the gallery's lines turn on (one those features imply, as `suite` implies `testing`, adds nothing); dev-dependency lines ask the egui crates (egui, epaint, epaint_default_fonts, emath, ecolor) for no feature that `feature-root`'s or the normal lines lack (a feature there differs between a crate's tests and everything else); the proc-macro crate pins syn's and proc-macro2's features to everything other derive crates may add, so the one syn every proc macro shares is the same with or without design-lint in the graph. `cl` names any new build of a framework crate in the target directory after each command; after a manifest change one is expected, otherwise run `cl doctor`.
The `testing` feature (or `screen-testing` on domain crates) supplies fixtures and helpers for app tests. The `suite` feature implies that kit and adds framework stories, registrations, trials, snapshots, and the suite runner. Framework and gallery tests enable `suite`; apps should use the kit without it.
+32 -10
View File
@@ -70,6 +70,8 @@ RENDER_FEATURES = {
"automation", "browse", "color-ui", "draw", "imaging", "layers", "menu", "pages", "print", "review", "table", "text",
"theme-editor", "theme-store", "timeline", "dialogs", "font-manager", "update",
}
# The egui crates every framework crate builds on: a feature only a dev-dependency line asks of one rebuilds the framework.
EGUI_FAMILY = {"egui", "epaint", "epaint_default_fonts", "emath", "ecolor"}
REFUSED = {
"--all-features": "it enables snapshot, system_fonts, color_fonts, all-languages and more, a set no loop uses, which rebuilds every dependency and the whole framework once; CI runs it",
"--bins": "the gallery's binaries are 1 GB links each; build the one you need (`cl build gallery`)",
@@ -120,8 +122,6 @@ PINS = [
"craft-ui-macros must ask proc-macro2 for span-locations, or a build with design-lint in it changes the shared proc-macro2 and rebuilds the framework"),
("crates/ui-contract/Cargo.toml", r'^craft-window = \{[^\n]*features = \[[^\]]*"ui"',
"craft-ui-contract must depend on craft-window with ui, or the shell's app flips craft-window under the whole framework"),
("crates/ui-contract/Cargo.toml", r'^testing = \[[^\]]*"snapshot"',
"craft-ui-contract's testing must include snapshot, or crates above widgets cannot ask the runtime for the renderer and build a second variant"),
]
@@ -203,6 +203,18 @@ def own_targets(p):
return flags
def implied(p, features):
"""The features a dependency line turns on in workspace package `p`: `features` and every feature of `p`'s own that
they imply. Without `p` (a crate outside the workspace) just `features`."""
on, todo = set(), list(features)
while todo:
f = todo.pop()
if f not in on:
on.add(f)
todo += [e for e in (p["features"].get(f, []) if p else []) if "/" not in e and not e.startswith("dep:")]
return on
def doctor(top, packages, quiet=False):
"""Manifest lines that would bring the variant churn back. Returns the number of problems."""
if APP:
@@ -212,16 +224,24 @@ def doctor(top, packages, quiet=False):
text = open(os.path.join(top, path)).read()
if not re.search(pattern, text, re.M):
problems.append(f"{path}: {why}")
asked = {}
for p in packages.values():
for d in p["dependencies"]:
if d["name"] in EGUI_FAMILY and d["kind"] is None:
asked.setdefault(d["name"], set()).update(d["features"])
for p in packages.values():
manifest = os.path.relpath(p["manifest_path"], top)
for d in p["dependencies"]:
if d["name"] == "egui" and d["kind"] == "dev" and d["features"]:
problems.append(f"{manifest}: the egui dev-dependency asks for {d['features']}; a feature on a dev-dependency "
"line changes egui under the framework between a crate's tests and its render")
extra = set(d["features"]) - asked.get(d["name"], set())
if d["name"] in EGUI_FAMILY and d["kind"] == "dev" and extra:
problems.append(f"{manifest}: the {d['name']} dev-dependency asks for {sorted(extra)}, which no normal line "
f"(feature-root's included) asks for; it changes {d['name']} under the framework between the "
"crate's tests and every other build")
gallery = packages.get("craft-ui-gallery")
if gallery:
for d in gallery["dependencies"]:
if d["name"].startswith("craft-") and "suite" in d["features"] and not d["optional"]:
domain = d["name"].startswith("craft-") and d["name"] not in FRAMEWORK
if domain and "suite" in d["features"] and not d["optional"]:
problems.append(f"crates/ui-gallery/Cargo.toml: {d['name']} must be optional (one feature per domain crate), or the story renderer links every crate")
root = packages.get(ROOT)
if not root:
@@ -243,9 +263,11 @@ def doctor(top, packages, quiet=False):
theirs = {d["name"]: d for d in gallery["dependencies"] if d["kind"] is None}
for d in render["dependencies"]:
g = theirs.get(d["name"])
if d["kind"] is None and g and not set(d["features"]) <= set(g["features"]):
problems.append(f"crates/story-render/Cargo.toml: {d['name']} asks for {sorted(set(d['features']) - set(g['features']))} "
"beyond the gallery's line, so renders build a second copy of it and everything above")
if d["kind"] is None and g:
extra = set(d["features"]) - implied(packages.get(d["name"]), g["features"])
if extra:
problems.append(f"crates/story-render/Cargo.toml: {d['name']} asks for {sorted(extra)} beyond what the "
"gallery's line turns on, so renders build a second copy of it and everything above")
for problem in problems:
print(f"cl doctor: {problem}", file=sys.stderr)
if not problems and not quiet:
@@ -732,7 +754,7 @@ def run(top, cargo_args, then=None, timings=True):
"""Runs cargo; `then` (a binary in the target's debug dir and its arguments) runs after a successful cargo. Exits
with the last return code."""
rc, target, _ = cargo(top, cargo_args, timings=timings)
if rc == 0 and then:
if rc == 0 and then and not DRY_RUN:
rc = run_binary([os.path.join(target, "debug", then[0])] + then[1:], top)
sys.exit(rc)