mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-12 16:31:05 +02:00
4f54255518
Probe generated canaries after mountVersion and always readActive for prefixed caches so sprites are not blanked by empty PhysFS stubs. Co-authored-by: Cursor <cursoragent@cursor.com>
54 lines
2.2 KiB
Lua
54 lines
2.2 KiB
Lua
-- Blue/Yellow mountVersion must overlay save-dir caches without FFI (NX).
|
|
package.path = "./?.lua;./?/init.lua;" .. package.path
|
|
if not _G.love then _G.love = require("tests.love_stub") end
|
|
|
|
local T = require("tests.harness")
|
|
local check = T.check
|
|
local eq = T.eq
|
|
|
|
local CacheFs = require("src.import.CacheFs")
|
|
local GameVersion = require("src.core.GameVersion")
|
|
|
|
love.filesystem._mounts = {}
|
|
-- Imply blue/data/generated and blue/assets/generated directories via file keys.
|
|
love.filesystem.write("blue/data/generated/maps.lua", "return {}")
|
|
love.filesystem.write("blue/data/generated/constants.lua", "return {}")
|
|
love.filesystem.write("blue/assets/generated/fonts/font.png", "font-bytes")
|
|
|
|
check(CacheFs.mountVersion("blue") == true, "mountVersion(blue) returns true")
|
|
|
|
local sawBlueRoot, sawDataGen, sawAssetsGen = false, false, false
|
|
for _, m in ipairs(love.filesystem._mounts) do
|
|
if m.archive == "blue" and m.mountpoint == "" and m.append == false then
|
|
sawBlueRoot = true
|
|
end
|
|
if m.archive == "blue/data/generated" and m.mountpoint == "data/generated"
|
|
and m.append == false then
|
|
sawDataGen = true
|
|
end
|
|
if m.archive == "blue/assets/generated" and m.mountpoint == "assets/generated"
|
|
and m.append == false then
|
|
sawAssetsGen = true
|
|
end
|
|
end
|
|
check(sawBlueRoot, "prepend-mounts save-dir relative blue/")
|
|
check(sawDataGen, "prepend-mounts blue/data/generated -> data/generated")
|
|
check(sawAssetsGen, "prepend-mounts blue/assets/generated -> assets/generated")
|
|
|
|
eq(love.filesystem.read("assets/generated/fonts/font.png"), "font-bytes",
|
|
"post-mount probe can read unprefixed assets/generated canary")
|
|
eq(love.filesystem.read("data/generated/constants.lua"), "return {}",
|
|
"post-mount probe can read unprefixed data/generated canary")
|
|
|
|
-- Yellow-only: same overlay contract
|
|
love.filesystem._mounts = {}
|
|
GameVersion.set("yellow")
|
|
love.filesystem.write("yellow/data/generated/constants.lua", "return {y=1}")
|
|
love.filesystem.write("yellow/assets/generated/fonts/font.png", "yellow-font")
|
|
check(CacheFs.mountVersion("yellow") == true, "mountVersion(yellow) returns true")
|
|
eq(love.filesystem.read("assets/generated/fonts/font.png"), "yellow-font",
|
|
"Yellow mount exposes fonts/font.png at the unprefixed path")
|
|
|
|
GameVersion.set("red")
|
|
T.finish()
|