mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-27 21:40:01 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9797c2bedb | ||
|
|
97f2754c1d |
@@ -8,14 +8,14 @@ workflows:
|
||||
'.github/workflows/house-rules.yml': []
|
||||
'.github/workflows/lockfile.yml':
|
||||
- 'actions/[email protected]'
|
||||
- 'step-security/[email protected]3.0'
|
||||
- 'step-security/[email protected]2.4'
|
||||
'.github/workflows/nightly-sign.yml': []
|
||||
'.github/workflows/nightly.yml': []
|
||||
'.github/workflows/nix.yml': []
|
||||
'.github/workflows/notify-services.yml': []
|
||||
'.github/workflows/packaging-lint.yml':
|
||||
- 'actions/[email protected]'
|
||||
- 'step-security/[email protected]3.0'
|
||||
- 'step-security/[email protected]2.4'
|
||||
'.github/workflows/release.yml': []
|
||||
'.github/workflows/sonarcloud.yml': []
|
||||
'.github/workflows/windows-arm64.yml': []
|
||||
@@ -25,8 +25,8 @@ dependencies:
|
||||
commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
|
||||
owner_id: 44036562
|
||||
repo_id: 197814629
|
||||
'step-security/[email protected]3.0':
|
||||
ref: 'v2.23.0'
|
||||
commit: 'sha1-aebdcf6156ab6691adf63218240e476564a1ed4c'
|
||||
'step-security/[email protected]2.4':
|
||||
ref: 'v2.22.4'
|
||||
commit: 'sha1-1d88384fd173af6ecb012dfd0264a306b711241a'
|
||||
owner_id: 88700172
|
||||
repo_id: 422287306
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Harden runner
|
||||
uses: step-security/[email protected]3.0
|
||||
uses: step-security/[email protected]2.4
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/[email protected]
|
||||
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Harden runner
|
||||
uses: step-security/[email protected]3.0
|
||||
uses: step-security/[email protected]2.4
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/[email protected]
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Harden runner
|
||||
uses: step-security/[email protected]3.0
|
||||
uses: step-security/[email protected]2.4
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/[email protected]
|
||||
|
||||
@@ -81,4 +81,5 @@ Paths and conventions:
|
||||
- Test corpora live in a separate corpus repository, pinned and sha256-verified. Test workbooks are built in code.
|
||||
- Progress log: `ROADMAP.md`. `plan/` is an optional gitignored notebook.
|
||||
- Run with a control channel: `cargo run --release -p gridcraft -- --sample sales --control 7979`. Drive it with `gridcraft-cli send 7979 <method> '<json>'`; methods are in `crates/ui-egui/src/control.rs`, the protocol in `docs/control-protocol.md`. Offscreen render: `cargo run -p gridcraft-ui-egui --example snapshot -- --sample sales out.png`. Headless: `gridcraft-cli eval '=SUM(1,2,3)'`, `gridcraft-cli mcp`.
|
||||
- Headless column ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): `cargo xtask parity` marks a catalog id `headless: yes` only when the engine registry (what `gridcraft-cli` and the MCP server load) has it. A missing id takes its `no`/`partial` value and `reach:` (`window`, `os` or `engine-gap`) from `HEADLESS` in `xtask/src/parity.rs`, or reads `unknown`. When a command lands, delete its mark; the check fails on a stale one.
|
||||
- Docs: `ROADMAP.md`, `docs/gaps.md` (ranked work), `docs/architecture.md`, `docs/target-app-parity.md`, `docs/roadmap.md`, `docs/contributors.md`.
|
||||
|
||||
+16
-14
@@ -6,6 +6,8 @@ Each entry is an Excel ribbon or menu command (feature names only). It counts as
|
||||
|
||||
**Overall: 282 / 296 commands implemented (95.3%).**
|
||||
|
||||
**Headless ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): 282 yes, 14 no (window 0, os 10, engine-gap 4), 0 partial, 0 unknown.** An implemented command is `headless: yes`: it is in the engine registry that `gridcraft-cli` and the MCP server load. A missing one carries its hand mark from `HEADLESS` in `xtask/src/parity.rs`, or `unknown`.
|
||||
|
||||
| Tab | Implemented | Total | Parity |
|
||||
|---|---|---|---|
|
||||
| File | 11 | 11 | 100% |
|
||||
@@ -166,12 +168,12 @@ Implemented:
|
||||
|
||||
Missing:
|
||||
|
||||
- `insert.smartArt` Diagram (Illustrations)
|
||||
- `insert.screenshot` Screenshot (Illustrations)
|
||||
- `insert.map` Maps (Charts)
|
||||
- `insert.timeline` Timeline (Filters)
|
||||
- `insert.signatureLine` Signature Line (Text)
|
||||
- `insert.object` Object (Text)
|
||||
- `insert.smartArt` Diagram (Illustrations): headless: no, reach: engine-gap (diagrams could be built by a command)
|
||||
- `insert.screenshot` Screenshot (Illustrations): headless: no, reach: os (screen capture of other windows)
|
||||
- `insert.map` Maps (Charts): headless: no, reach: os (online map service)
|
||||
- `insert.timeline` Timeline (Filters): headless: no, reach: engine-gap (a date filter for pivot tables could be a command)
|
||||
- `insert.signatureLine` Signature Line (Text): headless: no, reach: engine-gap (a signature line object could be inserted by a command)
|
||||
- `insert.object` Object (Text): headless: no, reach: os (embedding another program's object)
|
||||
|
||||
## Draw (4 / 4, 100%)
|
||||
|
||||
@@ -268,11 +270,11 @@ Implemented:
|
||||
|
||||
Missing:
|
||||
|
||||
- `data.fromWeb` From Web (Get & Transform Data)
|
||||
- `data.stocks` Stocks (Data Types)
|
||||
- `data.geography` Geography (Data Types)
|
||||
- `data.relationships` Relationships (Data Tools)
|
||||
- `data.analyzeData` Analyze Data (Analysis)
|
||||
- `data.fromWeb` From Web (Get & Transform Data): headless: no, reach: os (fetching a web page)
|
||||
- `data.stocks` Stocks (Data Types): headless: no, reach: os (online stock data service)
|
||||
- `data.geography` Geography (Data Types): headless: no, reach: os (online geography data service)
|
||||
- `data.relationships` Relationships (Data Tools): headless: no, reach: engine-gap (data-model relationships could be commands)
|
||||
- `data.analyzeData` Analyze Data (Analysis): headless: no, reach: os (online analysis service)
|
||||
|
||||
## Review (15 / 18, 83%)
|
||||
|
||||
@@ -296,9 +298,9 @@ Implemented:
|
||||
|
||||
Missing:
|
||||
|
||||
- `review.smartLookup` Smart Lookup (Insights)
|
||||
- `review.translate` Translate (Language)
|
||||
- `review.showChanges` Show Changes (Changes)
|
||||
- `review.smartLookup` Smart Lookup (Insights): headless: no, reach: os (online search service)
|
||||
- `review.translate` Translate (Language): headless: no, reach: os (online translation service)
|
||||
- `review.showChanges` Show Changes (Changes): headless: no, reach: os (co-authoring change history service)
|
||||
|
||||
## View (21 / 21, 100%)
|
||||
|
||||
|
||||
@@ -33,11 +33,12 @@ OUTPUT="$DIST/gridcraft-$VERSION-macos-aarch64-nightly.zip"
|
||||
nightly_compile_gui
|
||||
|
||||
APP="$NIGHTLY_WORK/stage/$MAC_NIGHTLY_APP"
|
||||
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
|
||||
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources/docs"
|
||||
cp "$NIGHTLY_GUI" "$APP/Contents/MacOS/GridCraft"
|
||||
chmod 755 "$APP/Contents/MacOS/GridCraft"
|
||||
cp "$ROOT/assets/app-icon/gridcraft-nightly.icns" "$APP/Contents/Resources/gridcraft-nightly.icns"
|
||||
nightly_copy_notices "$APP/Contents/Resources"
|
||||
# Launcher admits notices under Resources/docs, not beside the icon.
|
||||
nightly_copy_notices "$APP/Contents/Resources/docs"
|
||||
# The private mktemp cwd is the helper authority root: stage the template inside it.
|
||||
cp "$HERE/Info.plist.in" "$NIGHTLY_WORK/Info.plist.in"
|
||||
(cd "$NIGHTLY_WORK" && python3 "$HERE/nightly_plist.py" --template Info.plist.in \
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
"""The macOS Nightly signing and verification scripts, run on any POSIX host against generated
|
||||
fixtures and stand-in Apple tools (codesign, notarytool, stapler, spctl, security, ditto, plutil,
|
||||
lipo) that log their arguments. This proves the scripts' order, refusals and cleanup; it is not a
|
||||
real signature, notarization or Mac run."""
|
||||
lipo) that log their arguments. The unsigned producer also runs with a stub GUI build. These
|
||||
check the scripts and bundle layout, not native signing, notarization or Mac execution."""
|
||||
import base64
|
||||
import importlib.util
|
||||
import json
|
||||
@@ -27,6 +27,8 @@ COMMIT = "b" * 40
|
||||
VERSION = "0.23.1-nightly.20261123.4567.1.g" + COMMIT[:12]
|
||||
ASSET = f"gridcraft-{VERSION}-macos-aarch64-nightly.zip"
|
||||
APP = "GridCraft Nightly.app"
|
||||
APP_NOTICES = ("README.md", "LICENSE-MIT", "LICENSE-APACHE", "NOTICE", "ATTRIBUTION.md")
|
||||
OPTIONAL_NOTICES = ("LICENSE", "COPYRIGHT")
|
||||
TEAM = "ABCDE12345"
|
||||
IDENTITY = "0123456789ABCDEF0123456789ABCDEF01234567"
|
||||
SECRETS = {
|
||||
@@ -183,6 +185,50 @@ class Fixture:
|
||||
z.writestr(info, b"" if path.is_dir() else path.read_bytes())
|
||||
return self.input
|
||||
|
||||
def package(self, font_licences):
|
||||
"""Drive the real producer from a clean fixture checkout, without Cargo or Apple tools."""
|
||||
source = HERE.parents[1]
|
||||
checkout = self.root / "source"
|
||||
checkout.mkdir()
|
||||
notices = APP_NOTICES + tuple(name for name in OPTIONAL_NOTICES if (source / name).is_file())
|
||||
for relative in (*notices, "packaging/env.sh", "packaging/nightly-common.sh", "packaging/nightly_paths.py",
|
||||
"packaging/macos/nightly.sh", "packaging/macos/nightly-lib.sh",
|
||||
"packaging/macos/Info.plist.in", "packaging/macos/nightly_plist.py",
|
||||
"assets/app-icon/gridcraft-nightly.icns"):
|
||||
target = checkout / relative
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(source / relative, target)
|
||||
env = self.env(**dict.fromkeys(SECRETS))
|
||||
|
||||
def git(*args):
|
||||
return subprocess.run(["git", "-c", "core.hooksPath=/dev/null", "-c", "commit.gpgsign=false", *args],
|
||||
cwd=checkout, env=env, check=True, capture_output=True, text=True, timeout=30).stdout
|
||||
|
||||
git("init", "-q")
|
||||
git("add", "--", ".")
|
||||
git("-c", "user.name=Fixture", "-c", "[email protected]", "commit", "-qm", "Packaging fixture")
|
||||
commit = git("rev-parse", "HEAD").strip()
|
||||
version = VERSION[:-12] + commit[:12]
|
||||
# Generated licence text exercises the copier without depending on a font checkout.
|
||||
fonts = self.root / "craft-fonts"
|
||||
for family, data in font_licences.items():
|
||||
licence = fonts / "fonts" / family / "OFL.txt"
|
||||
licence.parent.mkdir(parents=True)
|
||||
licence.write_bytes(data)
|
||||
# The existing cargo stub fails for every invocation. Only this producer fixture emits a GUI.
|
||||
(self.bin / "cargo").write_text(
|
||||
'#!/bin/sh\nset -eu\n'
|
||||
'gui="$CARGO_TARGET_DIR/aarch64-apple-darwin/release/gridcraft"\n'
|
||||
'mkdir -p "$(dirname "$gui")"\n'
|
||||
"printf \"#!/bin/sh\\necho 'GridCraft %s (nightly-v1)'\\n\" \"$GRIDCRAFT_VERSION\" >\"$gui\"\n",
|
||||
)
|
||||
result = self.run(checkout / "packaging/macos/nightly.sh", "--arch", "aarch64", **dict.fromkeys(SECRETS),
|
||||
DIST=str(self.dist), CARGO_TARGET_DIR=str(self.root / "target"), CRAFT_FONTS_DIR=str(fonts),
|
||||
GRIDCRAFT_BUILD_CHANNEL="nightly-v1", GRIDCRAFT_VERSION=version,
|
||||
GRIDCRAFT_BUILD_SHA=commit, GRIDCRAFT_BUILD_DATE="2026-11-23")
|
||||
assert result.returncode == 0, result.stdout
|
||||
return self.dist / ASSET.replace(VERSION, version)
|
||||
|
||||
def env(self, **changes):
|
||||
env = {"PATH": f"{self.bin}:{os.environ['PATH']}", "HOME": str(self.root), "SHIM_LOG": str(self.log),
|
||||
"SHIM_TEAM": TEAM, "SHIM_IDENTITY": IDENTITY, "RUNNER_TEMP": str(self.temp), **SECRETS}
|
||||
@@ -430,6 +476,40 @@ class Verify(unittest.TestCase):
|
||||
|
||||
|
||||
class Build(unittest.TestCase):
|
||||
def test_unsigned_archive_has_launcher_layout_and_keeps_all_notices(self):
|
||||
f = Fixture(self)
|
||||
fonts = {"fixture-one": b"generated font notice one", "fixture-two": b"generated font notice two"}
|
||||
archive = f.package(fonts)
|
||||
source = HERE.parents[1]
|
||||
resources = f"{APP}/Contents/Resources"
|
||||
icon = "gridcraft-nightly.icns"
|
||||
notice_files = {name: (source / name).read_bytes() for name in APP_NOTICES}
|
||||
notice_files.update({name: (source / name).read_bytes() for name in OPTIONAL_NOTICES if (source / name).is_file()})
|
||||
notice_files.update({f"OFL-{family}.txt": data for family, data in fonts.items()})
|
||||
# Shipped Launcher v0.20.3 accepts these leaves only in Resources/docs, except for the root icon.
|
||||
expected_files = {f"{resources}/docs/{name}": data for name, data in notice_files.items()}
|
||||
expected_files[f"{resources}/{icon}"] = (source / "assets/app-icon" / icon).read_bytes()
|
||||
contents = f"{APP}/Contents"
|
||||
gui = f"{contents}/MacOS/GridCraft"
|
||||
with zipfile.ZipFile(archive) as zipped:
|
||||
entries = zipped.infolist()
|
||||
names = {entry.filename for entry in entries}
|
||||
self.assertEqual(len(entries), len({name.casefold() for name in names}), "unique paths, ignoring case")
|
||||
self.assertEqual({entry.filename for entry in entries if not entry.is_dir()},
|
||||
set(expected_files) | {gui, f"{contents}/Info.plist", f"{contents}/PkgInfo"})
|
||||
self.assertTrue({entry.filename for entry in entries if entry.is_dir()} <= {
|
||||
f"{APP}/", f"{contents}/", f"{contents}/MacOS/", f"{resources}/", f"{resources}/docs/"})
|
||||
for path, data in expected_files.items():
|
||||
with self.subTest(path=path):
|
||||
self.assertEqual(zipped.read(path), data)
|
||||
mode = zipped.getinfo(path).external_attr >> 16
|
||||
self.assertTrue(stat.S_ISREG(mode))
|
||||
self.assertFalse(mode & 0o111)
|
||||
mode = zipped.getinfo(gui).external_attr >> 16
|
||||
self.assertTrue(stat.S_ISREG(mode) and mode & stat.S_IXUSR)
|
||||
result = f.run("nightly-verify.sh", "--input", archive, "--expect", "unsigned", **dict.fromkeys(SECRETS))
|
||||
self.assertEqual(result.returncode, 0, result.stdout)
|
||||
|
||||
def test_compilation_refuses_signing_material_before_building(self):
|
||||
f = Fixture(self)
|
||||
for name in ("APPLE_CERTIFICATE", "APPLE_PASSWORD", "MACOS_SIGN_IDENTITY", "WINDOWS_CERTIFICATE", "AZURE_CLIENT_SECRET", "LINUX_SIGNING_KEY"):
|
||||
|
||||
+158
-2
@@ -19,6 +19,89 @@ pub struct Entry {
|
||||
pub done: bool,
|
||||
}
|
||||
|
||||
/// RFC-0052 hand marks for catalog ids with no engine command: `id|headless|reach|why`.
|
||||
///
|
||||
/// `headless` is `no` or `partial`; `reach` is `window` (needs a desktop window, dialog or pointer),
|
||||
/// `os` (needs an OS or online service the engine doesn't wrap) or `engine-gap` (could be an engine
|
||||
/// command, isn't one yet). `yes` is never written here: an id is `yes` only when the engine registry
|
||||
/// that `gridcraft-cli` and the MCP server load has it, and a mark on such an id is stale
|
||||
/// (`mark_errors`). A missing id with no mark is `unknown`.
|
||||
pub const HEADLESS: &str = "\
|
||||
insert.smartArt|no|engine-gap|diagrams could be built by a command
|
||||
insert.screenshot|no|os|screen capture of other windows
|
||||
insert.map|no|os|online map service
|
||||
insert.timeline|no|engine-gap|a date filter for pivot tables could be a command
|
||||
insert.signatureLine|no|engine-gap|a signature line object could be inserted by a command
|
||||
insert.object|no|os|embedding another program's object
|
||||
data.fromWeb|no|os|fetching a web page
|
||||
data.stocks|no|os|online stock data service
|
||||
data.geography|no|os|online geography data service
|
||||
data.relationships|no|engine-gap|data-model relationships could be commands
|
||||
data.analyzeData|no|os|online analysis service
|
||||
review.smartLookup|no|os|online search service
|
||||
review.translate|no|os|online translation service
|
||||
review.showChanges|no|os|co-authoring change history service
|
||||
";
|
||||
|
||||
/// A row's RFC-0052 `headless:` value, and for `no`/`partial` its `reach:` and reason.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Headless<'a> {
|
||||
pub value: &'a str,
|
||||
pub reach: Option<&'a str>,
|
||||
pub why: &'a str,
|
||||
}
|
||||
|
||||
const YES: Headless<'static> = Headless { value: "yes", reach: None, why: "" };
|
||||
const UNKNOWN: Headless<'static> = Headless { value: "unknown", reach: None, why: "" };
|
||||
|
||||
/// Parse `HEADLESS`-format marks. A malformed line, a hand-written `yes`, an unknown reach or a
|
||||
/// repeated id is an error.
|
||||
pub fn parse_marks(src: &str) -> Result<Vec<(&str, Headless<'_>)>, String> {
|
||||
let mut out: Vec<(&str, Headless<'_>)> = Vec::new();
|
||||
for line in src.lines().filter(|l| !l.trim().is_empty()) {
|
||||
let f: Vec<&str> = line.splitn(4, '|').collect();
|
||||
let [id, value, reach, why] = f[..] else {
|
||||
return Err(format!("headless mark `{line}`: want `id|headless|reach|why`"));
|
||||
};
|
||||
if !matches!(value, "no" | "partial") {
|
||||
return Err(format!("headless mark `{id}`: `{value}` is not `no` or `partial` (`yes` comes from the registry)"));
|
||||
}
|
||||
if !matches!(reach, "window" | "os" | "engine-gap") {
|
||||
return Err(format!("headless mark `{id}`: reach `{reach}` is not window, os or engine-gap"));
|
||||
}
|
||||
if out.iter().any(|(m, _)| *m == id) {
|
||||
return Err(format!("headless mark `{id}` is written twice"));
|
||||
}
|
||||
out.push((id, Headless { value, reach: Some(reach), why }));
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// `yes` for an id the engine registry has, else its mark, else `unknown`.
|
||||
pub fn headless_of<'a>(e: &Entry, marks: &[(&str, Headless<'a>)]) -> Headless<'a> {
|
||||
if e.done {
|
||||
return YES;
|
||||
}
|
||||
marks.iter().find(|(m, _)| *m == e.id).map_or(UNKNOWN, |(_, h)| *h)
|
||||
}
|
||||
|
||||
/// Marks that name no catalog id, or an id the engine registry has (it would hide a `yes`).
|
||||
pub fn mark_errors(src: &str, entries: &[Entry]) -> Vec<String> {
|
||||
let marks = match parse_marks(src) {
|
||||
Ok(m) => m,
|
||||
Err(e) => return vec![e],
|
||||
};
|
||||
let mut errs = Vec::new();
|
||||
for (id, _) in &marks {
|
||||
match entries.iter().find(|e| e.id == *id) {
|
||||
None => errs.push(format!("headless mark `{id}` is not a catalog id")),
|
||||
Some(e) if e.done => errs.push(format!("headless mark `{id}` is stale: the engine registry has it, so it is `yes`")),
|
||||
Some(_) => {}
|
||||
}
|
||||
}
|
||||
errs
|
||||
}
|
||||
|
||||
fn pct(done: usize, total: usize) -> f64 {
|
||||
if total == 0 { 0.0 } else { 100.0 * done as f64 / total as f64 }
|
||||
}
|
||||
@@ -26,6 +109,12 @@ fn pct(done: usize, total: usize) -> f64 {
|
||||
/// The markdown for docs/parity-checklist.md. Ids are counted once (the first catalog row wins), tabs keep
|
||||
/// catalog order.
|
||||
pub fn render(entries: &[Entry]) -> String {
|
||||
render_with(entries, HEADLESS)
|
||||
}
|
||||
|
||||
/// `render` with the given `HEADLESS`-format marks (bad marks are left out; `mark_errors` reports them).
|
||||
pub fn render_with(entries: &[Entry], marks: &str) -> String {
|
||||
let marks = parse_marks(marks).unwrap_or_default();
|
||||
let mut seen: Vec<&str> = Vec::new();
|
||||
let mut unique: Vec<&Entry> = Vec::new();
|
||||
for e in entries {
|
||||
@@ -50,6 +139,22 @@ pub fn render(entries: &[Entry]) -> String {
|
||||
registers a command with the same id. This measures breadth only; the overall assessment (depth, \
|
||||
fidelity, effort) is in [target-app-parity.md](target-app-parity.md).\n\n";
|
||||
s += &format!("**Overall: {done} / {total} commands implemented ({:.1}%).**\n\n", pct(done, total));
|
||||
let hs: Vec<Headless<'_>> = unique.iter().map(|e| headless_of(e, &marks)).collect();
|
||||
let count = |v: &str| hs.iter().filter(|h| h.value == v).count();
|
||||
let no = |r: &str| hs.iter().filter(|h| h.value == "no" && h.reach == Some(r)).count();
|
||||
s += &format!(
|
||||
"**Headless ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): {} yes, {} no \
|
||||
(window {}, os {}, engine-gap {}), {} partial, {} unknown.** An implemented command is `headless: yes`: it is in the \
|
||||
engine registry that `gridcraft-cli` and the MCP server load. A missing one carries its hand mark from `HEADLESS` in \
|
||||
`xtask/src/parity.rs`, or `unknown`.\n\n",
|
||||
count("yes"),
|
||||
count("no"),
|
||||
no("window"),
|
||||
no("os"),
|
||||
no("engine-gap"),
|
||||
count("partial"),
|
||||
count("unknown")
|
||||
);
|
||||
s += "| Tab | Implemented | Total | Parity |\n|---|---|---|---|\n";
|
||||
for t in &tabs {
|
||||
let rows: Vec<&&Entry> = unique.iter().filter(|e| e.tab == *t).collect();
|
||||
@@ -61,7 +166,21 @@ pub fn render(entries: &[Entry]) -> String {
|
||||
let d = rows.iter().filter(|e| e.done).count();
|
||||
s += &format!("\n## {t} ({d} / {}, {:.0}%)\n", rows.len(), pct(d, rows.len()));
|
||||
for (title, want) in [("Implemented", true), ("Missing", false)] {
|
||||
let list: Vec<String> = rows.iter().filter(|e| e.done == want).map(|e| format!("- `{}` {} ({})", e.id, e.label, e.group)).collect();
|
||||
let list: Vec<String> = rows
|
||||
.iter()
|
||||
.filter(|e| e.done == want)
|
||||
.map(|e| {
|
||||
let line = format!("- `{}` {} ({})", e.id, e.label, e.group);
|
||||
if want {
|
||||
return line;
|
||||
}
|
||||
let h = headless_of(e, &marks);
|
||||
match h.reach {
|
||||
Some(r) => format!("{line}: headless: {}, reach: {r} ({})", h.value, h.why),
|
||||
None => format!("{line}: headless: {}", h.value),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
if !list.is_empty() {
|
||||
s += &format!("\n{title}:\n\n{}\n", list.join("\n"));
|
||||
}
|
||||
@@ -109,7 +228,12 @@ pub fn run(root: &Path, args: &[&str]) -> Result<(), String> {
|
||||
other => return Err(format!("parity: unknown argument `{other}` (usage: cargo xtask parity [--check] [--out PATH])")),
|
||||
}
|
||||
}
|
||||
let text = render(&entries());
|
||||
let entries = entries();
|
||||
let errs = mark_errors(HEADLESS, &entries);
|
||||
if !errs.is_empty() {
|
||||
return Err(format!("parity: RFC-0052 headless marks in xtask/src/parity.rs:\n {}", errs.join("\n ")));
|
||||
}
|
||||
let text = render(&entries);
|
||||
if check {
|
||||
let current = std::fs::read_to_string(&out).map_err(|e| format!("{}: {e}", out.display()))?;
|
||||
if !up_to_date(¤t, &text) {
|
||||
@@ -151,6 +275,38 @@ mod tests {
|
||||
assert!(s.find("## File").unwrap_or(usize::MAX) < s.find("## Home").unwrap_or(0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn headless_yes_comes_only_from_the_registry() {
|
||||
let marks = "file.open|no|window|a dialog\n";
|
||||
let s = render_with(&[e("file.new", "File", true), e("file.open", "File", false), e("home.bold", "Home", false)], marks);
|
||||
assert!(s.contains("1 yes, 1 no (window 1, os 0, engine-gap 0), 0 partial, 1 unknown"), "{s}");
|
||||
assert!(s.contains("- `file.open` FILE.OPEN (G): headless: no, reach: window (a dialog)"), "{s}");
|
||||
assert!(s.contains("- `home.bold` HOME.BOLD (G): headless: unknown"), "{s}");
|
||||
// A live id is `yes` whatever a mark says.
|
||||
let parsed = parse_marks("file.new|no|os|x\n").unwrap_or_default();
|
||||
assert_eq!(headless_of(&e("file.new", "File", true), &parsed).value, "yes");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_marks_are_refused() {
|
||||
for bad in ["a.b|yes|window|x", "a.b|no|desk|x", "a.b|no", "a.b|no|os|x\na.b|partial|os|y"] {
|
||||
assert!(parse_marks(bad).is_err(), "{bad}");
|
||||
}
|
||||
let entries = [e("a.b", "T", true), e("c.d", "T", false)];
|
||||
let errs = mark_errors("a.b|no|os|x\nz.z|no|os|y\nc.d|partial|engine-gap|z\n", &entries);
|
||||
assert_eq!(errs.len(), 2, "{errs:?}");
|
||||
assert!(errs.iter().any(|m| m.contains("`a.b` is stale")), "{errs:?}");
|
||||
assert!(errs.iter().any(|m| m.contains("`z.z` is not a catalog id")), "{errs:?}");
|
||||
assert_eq!(mark_errors("junk", &entries).len(), 1);
|
||||
}
|
||||
|
||||
#[cfg(feature = "engine")]
|
||||
#[test]
|
||||
fn checked_in_marks_are_current() {
|
||||
let errs = mark_errors(HEADLESS, &entries());
|
||||
assert!(errs.is_empty(), "{errs:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_catalog_renders() {
|
||||
assert!(render(&[]).contains("0 / 0 commands implemented (0.0%)"));
|
||||
|
||||
Reference in New Issue
Block a user