ludic.base: bake_maps refuses a first input without {map} (it would test one path for every map: all or none); bake_expand says a {map} row is expanded only with a key from bake_maps
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2161f28766
commit
ef8bf09210
2 changed files with 7 additions and 2 deletions
|
|
@ -3,7 +3,8 @@
|
||||||
# dot-names left out. tools/bake/baked.py `expand` is its checked twin, as baked_hash is the hash's: a
|
# dot-names left out. tools/bake/baked.py `expand` is its checked twin, as baked_hash is the hash's: a
|
||||||
# runner and the check that expand alike agree on stale. A runner's line: bake_inputs_hash(bake_expand(...)).
|
# runner and the check that expand alike agree on stale. A runner's line: bake_inputs_hash(bake_expand(...)).
|
||||||
|
|
||||||
# the inputs with `{map}` as `map` (none when "") and every glob expanded, space-separated
|
# the inputs with `{map}` as `map` and every glob expanded, space-separated. A {map} row is only ever expanded
|
||||||
|
# with a key from bake_maps: with "" its `{map}` stays, hashes as a missing path and reads as a quiet stale
|
||||||
@alloc_ok("a bake's inputs: once a bake or a check")
|
@alloc_ok("a bake's inputs: once a bake or a check")
|
||||||
export function bake_expand(inputs: string, map: string) -> string {
|
export function bake_expand(inputs: string, map: string) -> string {
|
||||||
var ins = inputs
|
var ins = inputs
|
||||||
|
|
@ -22,12 +23,14 @@ export function bake_expand(inputs: string, map: string) -> string {
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
# the maps a `{map}` row covers: each directory under assets/maps holding its first input, sorted
|
# the maps a `{map}` row covers: each directory under assets/maps holding its first input, sorted; none when
|
||||||
|
# the first input has no `{map}` (it would test one path for every map - all or none), and the check says so
|
||||||
export function bake_maps(first_input: string) -> []string { return bake_maps_in("assets/maps", first_input) }
|
export function bake_maps(first_input: string) -> []string { return bake_maps_in("assets/maps", first_input) }
|
||||||
# ... under another directory of maps (a test's)
|
# ... under another directory of maps (a test's)
|
||||||
@alloc_ok("a bake's inputs: once a bake or a check")
|
@alloc_ok("a bake's inputs: once a bake or a check")
|
||||||
export function bake_maps_in(root: string, first_input: string) -> []string {
|
export function bake_maps_in(root: string, first_input: string) -> []string {
|
||||||
let got = new []string
|
let got = new []string
|
||||||
|
if not Text.contains(first_input, "{map}") { return got }
|
||||||
let names = bk_sorted(Fs.list(root))
|
let names = bk_sorted(Fs.list(root))
|
||||||
for i in 0 .. len(names) {
|
for i in 0 .. len(names) {
|
||||||
if len(names[i]) == 0 or names[i][0] == 46 { continue }
|
if len(names[i]) == 0 or names[i][0] == 46 { continue }
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@ program BakedExpandTest {
|
||||||
expect_eq(len(maps), 2)
|
expect_eq(len(maps), 2)
|
||||||
expect_eq(maps[0], "a")
|
expect_eq(maps[0], "a")
|
||||||
expect_eq(maps[1], "b")
|
expect_eq(maps[1], "b")
|
||||||
|
# a first input without {map} tests one path for every map: refused, not all or none
|
||||||
|
expect_eq(len(bake_maps_in(root() + "/maps", root() + "/maps/a/ground_layers.lres")), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
test "a map's inputs: {map} put, the glob's matches sorted byte by byte, dot-names out" {
|
test "a map's inputs: {map} put, the glob's matches sorted byte by byte, dot-names out" {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue