mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-19 12:15:31 +02:00
Merge pull request #858 from johnjohto/fix-modkit-headless-love
Keep CacheFs.read from crashing when modkit runs headless
This commit is contained in:
@@ -294,6 +294,9 @@ function CacheFs.read(rel)
|
|||||||
f:close()
|
f:close()
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
|
-- headless (plain luajit, e.g. the modkit validate/pack driver): there is
|
||||||
|
-- no save directory to read from, so a cache miss is nil, not a crash
|
||||||
|
if not (love and love.filesystem) then return nil end
|
||||||
return love.filesystem.read(rel)
|
return love.filesystem.read(rel)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
-- CacheFs stays headless-safe: plain luajit has no love global, and the
|
||||||
|
-- modkit validate/pack driver reaches CacheFs.read through Data:load when
|
||||||
|
-- an optional generated module (audio) is missing from the checkout
|
||||||
|
-- (issue #850). With no portable root and no love there is no save
|
||||||
|
-- directory to read from, so the read is a nil miss, not a crash.
|
||||||
|
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||||
|
|
||||||
|
local T = require("tests.harness")
|
||||||
|
local check = T.check
|
||||||
|
|
||||||
|
check(_G.love == nil, "suite runs with no love global")
|
||||||
|
|
||||||
|
local CacheFs = require("src.import.CacheFs")
|
||||||
|
|
||||||
|
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")
|
||||||
|
|
||||||
|
T.finish()
|
||||||
Reference in New Issue
Block a user