mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-19 04:06:10 +02:00
CLOSES #1390
This commit is contained in:
@@ -110,6 +110,18 @@ clearPath("yellow/" .. PNG)
|
||||
eq(love.filesystem.read(PNG), "blue-png-bytes",
|
||||
"overlay maps generated reads to blue/ for Blue")
|
||||
|
||||
-- Gold data/generated: fused NX hides gold/maps.lua at the unprefixed path,
|
||||
-- which is the "Gold cache incomplete / maps.lua Does not exist" crash.
|
||||
GameVersion.set("gold")
|
||||
local MAPS = "data/generated/maps.lua"
|
||||
love.filesystem.write("gold/" .. MAPS, "return { NEW_BARK_TOWN = true }")
|
||||
local mapsChunk = love.filesystem.load(MAPS)
|
||||
eq(type(mapsChunk) == "function" and mapsChunk().NEW_BARK_TOWN or nil, true,
|
||||
"wrapped filesystem.load resolves gold/data/generated/maps.lua")
|
||||
eq(love.filesystem.read(MAPS), "return { NEW_BARK_TOWN = true }",
|
||||
"wrapped filesystem.read returns gold maps.lua bytes")
|
||||
clearPath("gold/" .. MAPS)
|
||||
|
||||
-- Red has no prefix: nothing is rewritten
|
||||
GameVersion.set("red")
|
||||
clearPath("blue/" .. PNG)
|
||||
|
||||
@@ -49,5 +49,16 @@ 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")
|
||||
|
||||
-- Gold-only: same overlay contract (the Switch intro/maps.lua hole)
|
||||
love.filesystem._mounts = {}
|
||||
GameVersion.set("gold")
|
||||
love.filesystem.write("gold/data/generated/maps.lua", "return { ok = true }")
|
||||
love.filesystem.write("gold/assets/generated/fonts/font.png", "gold-font")
|
||||
check(CacheFs.mountVersion("gold") == true, "mountVersion(gold) returns true")
|
||||
eq(love.filesystem.read("assets/generated/fonts/font.png"), "gold-font",
|
||||
"Gold mount exposes fonts/font.png at the unprefixed path")
|
||||
eq(love.filesystem.read("data/generated/maps.lua"), "return { ok = true }",
|
||||
"Gold mount exposes maps.lua at the unprefixed path")
|
||||
|
||||
GameVersion.set("red")
|
||||
T.finish()
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
-- Gold on fused NX: gold/data/generated exists, but the overlay mount
|
||||
-- onto data/generated often fails. Game2/World used to love.filesystem.load
|
||||
-- the unprefixed path and crash with "Gold cache incomplete / maps.lua
|
||||
-- Does not exist" after a textless intro. CacheFs.loadActive must read the
|
||||
-- versioned file without any mount.
|
||||
-- Self-contained: luajit tests/engine/cache_fs_gold_nx_load_test.lua
|
||||
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")
|
||||
|
||||
local savedVersion = GameVersion.get()
|
||||
local savedPrefix = CacheFs.prefix
|
||||
|
||||
love.filesystem._mounts = {}
|
||||
GameVersion.set("gold")
|
||||
CacheFs.prefix = GameVersion.cachePrefix()
|
||||
|
||||
love.filesystem.write("gold/data/generated/maps.lua",
|
||||
"return { NEW_BARK_TOWN = { id = 1 } }")
|
||||
love.filesystem.write("gold/data/generated/oak_speech.lua",
|
||||
"return { text = { _OakText1 = 'Hello!' } }")
|
||||
love.filesystem.write("gold/data/generated/font.lua",
|
||||
"return { width = 8 }")
|
||||
|
||||
-- Unprefixed path is a miss: the NX mount hole.
|
||||
eq(love.filesystem.read("data/generated/maps.lua"), nil,
|
||||
"unprefixed maps.lua is missing (mount hole)")
|
||||
eq(love.filesystem.load("data/generated/maps.lua"), nil,
|
||||
"love.filesystem.load misses unprefixed maps.lua")
|
||||
|
||||
local maps, mapsErr = CacheFs.loadActive("data/generated/maps.lua")
|
||||
check(maps ~= nil, "loadActive finds gold/data/generated/maps.lua ("
|
||||
.. tostring(mapsErr) .. ")")
|
||||
eq(maps and maps.NEW_BARK_TOWN and maps.NEW_BARK_TOWN.id, 1,
|
||||
"loadActive returns the Gold maps table")
|
||||
|
||||
local oak = CacheFs.loadActive("data/generated/oak_speech.lua")
|
||||
eq(oak and oak.text and oak.text._OakText1, "Hello!",
|
||||
"loadActive returns oak_speech.lua from gold/")
|
||||
|
||||
local font = CacheFs.loadActive("data/generated/font.lua")
|
||||
eq(font and font.width, 8,
|
||||
"loadActive returns font.lua from gold/")
|
||||
|
||||
love.filesystem.remove("gold/data/generated/maps.lua")
|
||||
love.filesystem.remove("gold/data/generated/oak_speech.lua")
|
||||
love.filesystem.remove("gold/data/generated/font.lua")
|
||||
CacheFs.prefix = savedPrefix
|
||||
GameVersion.set(savedVersion)
|
||||
|
||||
T.finish()
|
||||
@@ -16,5 +16,8 @@ check(CacheFs.read("data/generated/audio.lua") == nil,
|
||||
"read is a nil miss headless, not a crash")
|
||||
check(CacheFs.readActive("data/generated/audio.lua") == nil,
|
||||
"readActive is a nil miss headless, not a crash")
|
||||
local loaded, loadErr = CacheFs.loadActive("data/generated/audio.lua")
|
||||
check(loaded == nil,
|
||||
"loadActive is a nil miss headless, not a crash (" .. tostring(loadErr) .. ")")
|
||||
|
||||
T.finish()
|
||||
|
||||
@@ -89,6 +89,23 @@ check(probe:find("resolve=yellow/assets/generated/fonts/font.png", 1, true) ~= n
|
||||
"probe records versioned font path visibility")
|
||||
check(not probe:find(string.char(0xEA, 0x9B), 1, true),
|
||||
"probe log contains no ROM-like binary")
|
||||
check(probe:find("data/generated/maps.lua", 1, true) ~= nil,
|
||||
"probe records Gold/Gen2 maps.lua visibility")
|
||||
check(probe:find("loadActive=", 1, true) ~= nil,
|
||||
"probe uses loadActive for generated Lua instead of newImage")
|
||||
|
||||
-- Gold maps.lua / gold/ folders: fused NX intro/naming/overworld crash.
|
||||
GameVersion.set("gold")
|
||||
love.filesystem.write("gold/data/generated/maps.lua", "return { NEW_BARK_TOWN = true }")
|
||||
love.filesystem.write("gold/data/generated/oak_speech.lua", "return {}")
|
||||
SwitchDiagnostics.probeAssets("gold")
|
||||
probe = love.filesystem.read("nx-asset-probe.log") or ""
|
||||
check(probe:find("cachePrefix=gold/", 1, true) ~= nil, "probe records gold prefix")
|
||||
check(probe:find("data/generated/maps.lua", 1, true) ~= nil,
|
||||
"probe lists maps.lua (the Gold cache incomplete path)")
|
||||
check(probe:find("list gold", 1, true) ~= nil, "probe lists gold/ folder")
|
||||
check(probe:find("list gold/data/generated", 1, true) ~= nil,
|
||||
"probe lists gold/data/generated/")
|
||||
|
||||
love.system = { getOS = function() return "OS X" end }
|
||||
Platform._resetForTests()
|
||||
@@ -104,5 +121,7 @@ love.filesystem.remove("nx-asset-probe.log")
|
||||
love.filesystem.remove("yellow/assets/generated/fonts/font.png")
|
||||
love.filesystem.remove("yellow/assets/generated/tilesets/reds_house.png")
|
||||
love.filesystem.remove("yellow/assets/generated/sprites/red.png")
|
||||
love.filesystem.remove("gold/data/generated/maps.lua")
|
||||
love.filesystem.remove("gold/data/generated/oak_speech.lua")
|
||||
|
||||
T.finish()
|
||||
|
||||
@@ -26,7 +26,7 @@ end
|
||||
-- Also gates the NX runtime modules and the NX engine suites so an NX
|
||||
-- runtime regression cannot slip past switch-selftest / switch-build.
|
||||
local SWITCH_PATH_REGEX =
|
||||
[[^(scripts/build_switch\.sh$|scripts/switch/|docs/switch-.*\.md$|tests/switch_ci_workflows_test\.lua$|tests/switch_transfer_docs_test\.lua$|\.github/workflows/(ci|release|switch-artifact-comment)\.yml$|src/core/(NxAssetOverlay|Platform|GameVersion)\.lua$|src/import/CacheFs\.lua$|tests/engine/(assets_version_fallback|nx_generated_guard|nx_yellow_boot|switch_diagnostics)_test\.lua$|tests/engine/platform_nx)]]
|
||||
[[^(scripts/build_switch\.sh$|scripts/switch/|docs/switch-.*\.md$|tests/switch_ci_workflows_test\.lua$|tests/switch_transfer_docs_test\.lua$|\.github/workflows/(ci|release|switch-artifact-comment)\.yml$|src/core/(NxAssetOverlay|Platform|GameVersion)\.lua$|src/import/CacheFs\.lua$|tests/engine/(assets_version_fallback|nx_generated_guard|nx_yellow_boot|switch_diagnostics|cache_fs_gold_nx_load)_test\.lua$|tests/engine/platform_nx)]]
|
||||
|
||||
local ci = read(".github/workflows/ci.yml")
|
||||
local release = read(".github/workflows/release.yml")
|
||||
@@ -50,6 +50,7 @@ for _, fragment in ipairs({
|
||||
"nx_generated_guard",
|
||||
"nx_yellow_boot",
|
||||
"switch_diagnostics",
|
||||
"cache_fs_gold_nx_load",
|
||||
"tests/engine/platform_nx",
|
||||
}) do
|
||||
mustContain(ci, fragment, "ci.yml path regex NX fragment")
|
||||
@@ -79,6 +80,7 @@ do
|
||||
mustContain(block, "luajit tests/engine/assets_version_fallback_test.lua", "switch-selftest")
|
||||
mustContain(block, "luajit tests/engine/nx_generated_guard_test.lua", "switch-selftest")
|
||||
mustContain(block, "luajit tests/engine/nx_yellow_boot_test.lua", "switch-selftest")
|
||||
mustContain(block, "luajit tests/engine/cache_fs_gold_nx_load_test.lua", "switch-selftest")
|
||||
mustNotContain(block, "continue-on-error:", "switch-selftest")
|
||||
end
|
||||
|
||||
@@ -185,6 +187,7 @@ mustContain(test_sh, "T0 switch transfer docs gate", "scripts/test.sh")
|
||||
mustContain(test_sh, "tests/engine/assets_version_fallback_test.lua", "scripts/test.sh")
|
||||
mustContain(test_sh, "tests/engine/nx_generated_guard_test.lua", "scripts/test.sh")
|
||||
mustContain(test_sh, "tests/engine/nx_yellow_boot_test.lua", "scripts/test.sh")
|
||||
mustContain(test_sh, "tests/engine/cache_fs_gold_nx_load_test.lua", "scripts/test.sh")
|
||||
mustContain(build_doc, "tests/switch_ci_workflows_test.lua", "switch-build.md path list")
|
||||
mustContain(build_doc, "tests/switch_transfer_docs_test.lua", "switch-build.md path list")
|
||||
|
||||
@@ -197,6 +200,7 @@ for _, path in ipairs({
|
||||
"tests/engine/assets_version_fallback_test.lua",
|
||||
"tests/engine/nx_generated_guard_test.lua",
|
||||
"tests/engine/nx_yellow_boot_test.lua",
|
||||
"tests/engine/cache_fs_gold_nx_load_test.lua",
|
||||
"tests/engine/switch_diagnostics_test.lua",
|
||||
"tests/engine/platform_nx_*",
|
||||
}) do
|
||||
|
||||
Reference in New Issue
Block a user