Skip to content

Commit

Permalink
handle missing expected img for compareImg()
Browse files Browse the repository at this point in the history
  • Loading branch information
ellraiser committed Mar 6, 2024
1 parent 923e695 commit 941c644
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions classes/TestMethod.lua
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,11 @@ TestMethod = {
-- @param {table} imgdata - imgdata to save as a png
-- @return {nil}
compareImg = function(self, imgdata)
local expected = love.image.newImageData(
'tempoutput/expected/love.test.graphics.' .. self.method .. '-' ..
tostring(self.imgs) .. '.png'
)
local expected_path = 'tempoutput/expected/love.test.graphics.' ..
self.method .. '-' .. tostring(self.imgs) .. '.png'
local ok, chunk, _ = pcall(love.image.newImageData, expected_path)
if ok == false then return self:assertEquals(true, false, chunk) end
local expected = chunk
local iw = imgdata:getWidth()-2
local ih = imgdata:getHeight()-2
local rgba_tolerance = self.rgba_tolerance * (1/255)
Expand Down Expand Up @@ -324,7 +325,7 @@ TestMethod = {
self.imgs = self.imgs + 1
end,


-- @method - TestMethod:exportImg()
-- @desc - exports the given imgdata to the 'output/expected/' folder, to use when
-- writing new graphics tests to set the expected image output
Expand Down

0 comments on commit 941c644

Please sign in to comment.