proto becomes bxcore, the one shared crate (M5b task 00)
Done the way the owner asked and the spike mapped: the crate and the manifests renamed, then what the build reported fixed. Layers: 138 "proto unresolved" errors across 169 files; cargo fmt reordering imports; six fixture paths built as strings in brokerd's and bxctl's tests, which the compiler cannot see, and comments naming crates/proto/; the crate-dependency check and its self-test. One more the spike did not reach: a `\nproto =` key inside a printf format in the self-test, which a word-boundary replacement skips because `n` and `p` are both word characters. make gate: gate: ok, 944 tests; no new entry in /tmp. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# Fails if `proto` depends on any workspace crate, or if any other crate depends on
|
||||
# a workspace crate other than `proto`. Every manifest section whose name contains
|
||||
# Fails if `bxcore` depends on any workspace crate, or if any other crate depends on
|
||||
# a workspace crate other than `bxcore`. Every manifest section whose name contains
|
||||
# "dependencies" (including [dev-dependencies] and [build-dependencies]) is
|
||||
# inspected. A dependency name can appear as a plain key (`x = "1"`), a dotted key
|
||||
# (`x.workspace = true` or `x.path = ".."`) or a table header (`[dependencies.x]`);
|
||||
@@ -69,10 +69,10 @@ for crate in "$ROOT"/crates/*/; do
|
||||
if [ "$key" = "$w" ]; then hit=1; break; fi
|
||||
done
|
||||
if [ "$hit" -eq 1 ]; then
|
||||
if [ "$crate_name" = "proto" ]; then
|
||||
if [ "$crate_name" = "bxcore" ]; then
|
||||
echo "check-crate-deps: $crate_name depends on workspace crate $key" >&2
|
||||
status=1
|
||||
elif [ "$key" != "proto" ]; then
|
||||
elif [ "$key" != "bxcore" ]; then
|
||||
echo "check-crate-deps: $crate_name depends on workspace crate $key" >&2
|
||||
status=1
|
||||
fi
|
||||
|
||||
@@ -26,14 +26,14 @@ manifest() { # manifest DIR NAME [DEPENDENCY-LINES...]
|
||||
} > "$dir/Cargo.toml"
|
||||
}
|
||||
|
||||
tree() { # tree ROOT: a good workspace with proto, loopd and brokerd
|
||||
tree() { # tree ROOT: a good workspace with bxcore, loopd and brokerd
|
||||
root="$1"
|
||||
mkdir -p "$root/docs"
|
||||
printf '[workspace]\nmembers = ["crates/*"]\n\n[workspace.dependencies]\nproto = { path = "crates/proto" }\nserde = { version = "1", features = ["derive"] }\n' > "$root/Cargo.toml"
|
||||
printf '[workspace]\nmembers = ["crates/*"]\n\n[workspace.dependencies]\nbxcore = { path = "crates/bxcore" }\nserde = { version = "1", features = ["derive"] }\n' > "$root/Cargo.toml"
|
||||
printf '# Dependencies\n\n| Crate | Why |\n|---|---|\n| `serde` | types |\n' > "$root/docs/dependencies.md"
|
||||
manifest "$root/crates/proto" proto 'serde.workspace = true'
|
||||
manifest "$root/crates/loopd" loopd 'proto.workspace = true'
|
||||
manifest "$root/crates/brokerd" brokerd 'proto = { workspace = true }' 'serde.workspace = true'
|
||||
manifest "$root/crates/bxcore" bxcore 'serde.workspace = true'
|
||||
manifest "$root/crates/loopd" loopd 'bxcore.workspace = true'
|
||||
manifest "$root/crates/brokerd" brokerd 'bxcore = { workspace = true }' 'serde.workspace = true'
|
||||
}
|
||||
|
||||
lines() { # lines N FILE
|
||||
@@ -47,31 +47,31 @@ tree "$tmp/l-ok"; lines 500 "$tmp/l-ok/crates/loopd/src/lib.rs"
|
||||
expect pass "500 lines is allowed" check-lines.sh "$tmp/l-ok"
|
||||
tree "$tmp/l-bad"; lines 501 "$tmp/l-bad/crates/loopd/src/deep/mod.rs"
|
||||
expect fail "501 lines in a nested file" check-lines.sh "$tmp/l-bad"
|
||||
tree "$tmp/l-test"; lines 501 "$tmp/l-test/crates/proto/tests/big.rs"
|
||||
tree "$tmp/l-test"; lines 501 "$tmp/l-test/crates/bxcore/tests/big.rs"
|
||||
expect fail "501 lines in a test file" check-lines.sh "$tmp/l-test"
|
||||
tree "$tmp/l-tgt"; lines 501 "$tmp/l-tgt/crates/proto/target/debug/gen.rs"
|
||||
tree "$tmp/l-tgt"; lines 501 "$tmp/l-tgt/crates/bxcore/target/debug/gen.rs"
|
||||
expect pass "files under target/ are ignored" check-lines.sh "$tmp/l-tgt"
|
||||
|
||||
# check-crate-deps.sh
|
||||
tree "$tmp/c-ok"
|
||||
expect pass "roles depend only on proto" check-crate-deps.sh "$tmp/c-ok"
|
||||
tree "$tmp/c-role"; manifest "$tmp/c-role/crates/loopd" loopd 'proto.workspace = true' 'brokerd.workspace = true'
|
||||
expect pass "roles depend only on bxcore" check-crate-deps.sh "$tmp/c-ok"
|
||||
tree "$tmp/c-role"; manifest "$tmp/c-role/crates/loopd" loopd 'bxcore.workspace = true' 'brokerd.workspace = true'
|
||||
expect fail "role depends on another role" check-crate-deps.sh "$tmp/c-role"
|
||||
tree "$tmp/c-tbl"; manifest "$tmp/c-tbl/crates/loopd" loopd 'brokerd = { path = "../brokerd" }'
|
||||
expect fail "role depends on another role by path" check-crate-deps.sh "$tmp/c-tbl"
|
||||
tree "$tmp/c-dev"; printf '\n[dev-dependencies]\nbrokerd.workspace = true\n' >> "$tmp/c-dev/crates/loopd/Cargo.toml"
|
||||
expect fail "role dev-depends on another role" check-crate-deps.sh "$tmp/c-dev"
|
||||
tree "$tmp/c-proto"; manifest "$tmp/c-proto/crates/proto" proto 'loopd.workspace = true'
|
||||
expect fail "proto depends on a role" check-crate-deps.sh "$tmp/c-proto"
|
||||
tree "$tmp/c-bxcore"; manifest "$tmp/c-bxcore/crates/bxcore" bxcore 'loopd.workspace = true'
|
||||
expect fail "bxcore depends on a role" check-crate-deps.sh "$tmp/c-bxcore"
|
||||
# A dependency can also be written as its own table: [dependencies.NAME]
|
||||
tree "$tmp/c-sect"; printf '\n[dependencies.brokerd]\npath = "../brokerd"\n' >> "$tmp/c-sect/crates/loopd/Cargo.toml"
|
||||
expect fail "role depends on another role, written as a table" check-crate-deps.sh "$tmp/c-sect"
|
||||
tree "$tmp/c-sectw"; printf '\n[dev-dependencies.brokerd]\nworkspace = true\n' >> "$tmp/c-sectw/crates/loopd/Cargo.toml"
|
||||
expect fail "role dev-depends on another role, written as a table" check-crate-deps.sh "$tmp/c-sectw"
|
||||
tree "$tmp/c-dot"; manifest "$tmp/c-dot/crates/loopd" loopd 'proto.workspace = true' 'brokerd.path = "../brokerd"'
|
||||
tree "$tmp/c-dot"; manifest "$tmp/c-dot/crates/loopd" loopd 'bxcore.workspace = true' 'brokerd.path = "../brokerd"'
|
||||
expect fail "role depends on another role, written with a dotted key" check-crate-deps.sh "$tmp/c-dot"
|
||||
tree "$tmp/c-sectok"; manifest "$tmp/c-sectok/crates/loopd" loopd; printf '\n[dependencies.proto]\nworkspace = true\n' >> "$tmp/c-sectok/crates/loopd/Cargo.toml"
|
||||
expect pass "role depends on proto, written as a table" check-crate-deps.sh "$tmp/c-sectok"
|
||||
tree "$tmp/c-sectok"; manifest "$tmp/c-sectok/crates/loopd" loopd; printf '\n[dependencies.bxcore]\nworkspace = true\n' >> "$tmp/c-sectok/crates/loopd/Cargo.toml"
|
||||
expect pass "role depends on bxcore, written as a table" check-crate-deps.sh "$tmp/c-sectok"
|
||||
|
||||
# check-dep-docs.sh
|
||||
tree "$tmp/d-ok"
|
||||
@@ -80,7 +80,7 @@ tree "$tmp/d-miss"; printf 'rand = "0.9"\n' >> "$tmp/d-miss/Cargo.toml"
|
||||
expect fail "workspace dependency without a docs row" check-dep-docs.sh "$tmp/d-miss"
|
||||
tree "$tmp/d-prose"; printf 'rand = "0.9"\n' >> "$tmp/d-prose/Cargo.toml"; printf '\nWe do not use rand.\n' >> "$tmp/d-prose/docs/dependencies.md"
|
||||
expect fail "a mention in prose is not a table row" check-dep-docs.sh "$tmp/d-prose"
|
||||
tree "$tmp/d-loose"; manifest "$tmp/d-loose/crates/loopd" loopd 'proto.workspace = true' 'rand = "0.9"'
|
||||
tree "$tmp/d-loose"; manifest "$tmp/d-loose/crates/loopd" loopd 'bxcore.workspace = true' 'rand = "0.9"'
|
||||
expect fail "crate declares a dependency outside the workspace table" check-dep-docs.sh "$tmp/d-loose"
|
||||
tree "$tmp/d-sect"; printf '\n[dependencies.rand]\nversion = "0.9"\n' >> "$tmp/d-sect/crates/loopd/Cargo.toml"
|
||||
expect fail "table-form dependency without workspace = true" check-dep-docs.sh "$tmp/d-sect"
|
||||
|
||||
Reference in New Issue
Block a user