mirror of
https://github.com/DramaticShape/DramaticShapeVoxelMod.git
synced 2026-08-12 08:31:06 +02:00
find the colour table relative to the mod, not the cwd
ShinyPalette loaded data/shiny_colors.lua by guessing cwd-relative paths when V.data was absent, which is the headless case. Run from the project root, none of the guesses hit -- so the extraction built all 151 species, recoloured none of them, and reported PASS. The packs were correct; there simply were no shiny variants in them, and nothing in the output said so. Two fixes, because either alone leaves the trap open: V.path is now consulted first, so the file is found relative to the MOD the way every other resource is. The extract test's stub sets it to whatever --mod it was given. A count of zero recoloured is now a failure. That is precisely what a missing colour table looks like from the outside, and a test that passes on it is not testing the feature. It was caught by noticing the number change between two runs that differed only in where they were started from -- which is too thin a thread to hang it on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+17
-2
@@ -168,8 +168,16 @@ local function loadColors()
|
||||
local ok, t = pcall(V.data, "shiny_colors")
|
||||
if ok and type(t) == "table" then colors = t; return colors end
|
||||
end
|
||||
local tries = { "data/shiny_colors.lua",
|
||||
"mods/DramaticShapeVoxelMod/data/shiny_colors.lua" }
|
||||
-- Off disk, RELATIVE TO THE MOD rather than to the working directory.
|
||||
-- V.path is the mod's own directory (main.lua sets it; the headless
|
||||
-- harnesses set it to whatever --mod they were given). Guessing from the
|
||||
-- cwd instead is what made this silently find nothing when the extraction
|
||||
-- test was run from the project root rather than from the mod: every
|
||||
-- species built, none recoloured, and a PASS at the end of it.
|
||||
local tries = {}
|
||||
if V and V.path then tries[#tries + 1] = V.path .. "/data/shiny_colors.lua" end
|
||||
tries[#tries + 1] = "data/shiny_colors.lua"
|
||||
tries[#tries + 1] = "mods/DramaticShapeVoxelMod/data/shiny_colors.lua"
|
||||
for _, p in ipairs(tries) do
|
||||
local chunk = loadfile(p)
|
||||
if chunk then
|
||||
@@ -181,6 +189,13 @@ local function loadColors()
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Whether the colour table was found at all. The extraction asks so it can
|
||||
-- say "no colours" once and loudly, rather than reporting 151 successful
|
||||
-- builds with no shiny variant among them.
|
||||
function ShinyPalette.haveColors()
|
||||
return loadColors() ~= nil
|
||||
end
|
||||
|
||||
-- The spec for one dex number, or nil if we have nothing for it.
|
||||
function ShinyPalette.forDex(dex)
|
||||
local all = loadColors()
|
||||
|
||||
@@ -51,6 +51,9 @@ function V.require(name)
|
||||
return loaded[name]
|
||||
end
|
||||
V.mod = { log = { warn = function() end, info = function() end } }
|
||||
-- the mod's own directory, so a module that loads a data file finds it
|
||||
-- relative to the MOD rather than to wherever this was run from
|
||||
V.path = MOD
|
||||
|
||||
local StadiumRom = V.require("StadiumRom")
|
||||
local StadiumBuild = V.require("StadiumBuild")
|
||||
@@ -150,6 +153,16 @@ io.write(("\n%d checked, %d identical, %d differ, %d oracle files missing, "
|
||||
io.write(("shiny: %d recoloured, %d without a variant, %d malformed\n")
|
||||
:format(shinyOk, shinyMissing, shinyBad))
|
||||
|
||||
-- NONE recoloured is a failure, not a quiet zero. It is what a missing or
|
||||
-- unfindable data/shiny_colors.lua looks like, and the first version of this
|
||||
-- test reported PASS through exactly that: 151 species built, every one of
|
||||
-- them without a shiny variant, and nothing in the output that read as
|
||||
-- wrong. A count of zero is now as loud as a malformed pack.
|
||||
if checked > 0 and shinyOk == 0 then
|
||||
io.write("NO SPECIES RECOLOURED -- data/shiny_colors.lua was not found\n")
|
||||
shinyBad = shinyBad + 1
|
||||
end
|
||||
|
||||
-- The oracle diff is the load-bearing assertion and is unchanged: the shiny
|
||||
-- pass must not have moved a single byte of the normal packs. The shiny
|
||||
-- counters are additional, and a malformed variant fails the run -- a pack
|
||||
|
||||
Reference in New Issue
Block a user