diff --git a/lib/ShinyPalette.lua b/lib/ShinyPalette.lua index 823aff9..ba49c73 100644 --- a/lib/ShinyPalette.lua +++ b/lib/ShinyPalette.lua @@ -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() diff --git a/tests/stadium_extract_test.lua b/tests/stadium_extract_test.lua index c4415df..2bb2142 100644 --- a/tests/stadium_extract_test.lua +++ b/tests/stadium_extract_test.lua @@ -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