From 4304f51ff0cd4c9d1cde4215816010169363d9c4 Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 23 Nov 2026 10:54:17 +0000 Subject: [PATCH 1/3] cl doctor: rules for the split UI test kit Since #2363, craft-ui-contract's testing no longer carries snapshot and the framework crates have a suite feature. Every cl command still resolves one framework feature set (feature-root brings the gallery's craft-ui suite), so the three doctor reports were out of date, not second builds: - drop the pin on craft-ui-contract's testing including snapshot: each framework crate's suite forwards to the runtime's suite, which cl picks first - the gallery's must-be-optional rule covers domain crates, not the framework - the story renderer's lines are compared with the features the gallery's lines turn on, implied features included (suite implies testing) CL_DRY_RUN with cl render no longer runs the renderer after printing the command. --- crates/story-render/Cargo.toml | 4 ++-- docs/development.md | 2 +- tools/cl | 27 ++++++++++++++++++++------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/crates/story-render/Cargo.toml b/crates/story-render/Cargo.toml index 94779a1be5..a6f8626743 100644 --- a/crates/story-render/Cargo.toml +++ b/crates/story-render/Cargo.toml @@ -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 } diff --git a/docs/development.md b/docs/development.md index 0cf6e7a250..6f25853b3a 100644 --- a/docs/development.md +++ b/docs/development.md @@ -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 -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 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`. 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. diff --git a/tools/cl b/tools/cl index da8489603e..9f54f69cc9 100755 --- a/tools/cl +++ b/tools/cl @@ -120,8 +120,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 +201,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: @@ -221,7 +231,8 @@ def doctor(top, packages, quiet=False): 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 +254,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 +745,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) From 52d8e207df945594d75aa2c469028eb4a82d3c56 Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 23 Nov 2026 10:54:18 +0000 Subject: [PATCH 2/3] feature-root: ask epaint_default_fonts for the monochrome emoji faces craft-ui-contract's tests ask for them as a dev-dependency (their font oracle), which gave cl test ui-contract its own epaint_default_fonts and so its own egui and framework build. The feature only adds two byte constants; egui's emoji fallback is epaint's own feature and stays off. --- Cargo.lock | 1 + crates/feature-root/Cargo.toml | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index e65b6a3907..11afedc478 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6004,6 +6004,7 @@ dependencies = [ "craft-timeline", "craft-ui-gallery", "craft-update", + "epaint_default_fonts", ] [[package]] diff --git a/crates/feature-root/Cargo.toml b/crates/feature-root/Cargo.toml index 3392e7ef42..bf49741838 100644 --- a/crates/feature-root/Cargo.toml +++ b/crates/feature-root/Cargo.toml @@ -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"] } From 60e39bc320674b348525838f724ed161a3ba9012 Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 23 Nov 2026 10:55:18 +0000 Subject: [PATCH 3/3] cl doctor: dev-dependency features across the egui crates The dev-dependency rule covered egui alone; epaint_default_fonts slipped past it. It now checks the egui crates every framework crate builds on (egui, epaint, epaint_default_fonts, emath, ecolor): a feature a dev-dependency line asks of one must also be asked by a normal line, feature-root's included. --- docs/development.md | 2 +- tools/cl | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/development.md b/docs/development.md index 6f25853b3a..e0abe9d46b 100644 --- a/docs/development.md +++ b/docs/development.md @@ -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 -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. -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 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. diff --git a/tools/cl b/tools/cl index 9f54f69cc9..39078a29b2 100755 --- a/tools/cl +++ b/tools/cl @@ -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`)", @@ -222,12 +224,19 @@ 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"]: