Skip to content

Commit

Permalink
Run an extra test on headless checking for errors at infolog.txt.
Browse files Browse the repository at this point in the history
  • Loading branch information
saurtron committed Dec 21, 2024
1 parent 2b10905 commit 4b560e6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
34 changes: 34 additions & 0 deletions common/testing/infologtest.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- 'hidden' test checking infolog.txt for errors, used by headless runs.

local maxErrors = 10

local function skipErrors(line)
if string.find(line, 'Could not finalize projectile-texture atlas', nil, true) then
return true
end
end

local function infologTest()
local errors = {}
local infolog = VFS.LoadFile("infolog.txt")
if infolog then
local fileLines = string.lines(infolog)
for i, line in ipairs(fileLines) do
if string.find(line, 'Error:', nil, true) and not skipErrors(line) then
errors[#errors+1] = line
if #errors > maxErrors then
return errors
end
end
end
end
return errors
end


function test()
local errors = infologTest()
if #errors > 0 then
error(table.concat(errors, "\n"), 0)
end
end
6 changes: 6 additions & 0 deletions luaui/Widgets/dbg_test_runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ local config = {
}

local testReporter = nil
local headless = false

-- utils
-- =====
Expand Down Expand Up @@ -71,6 +72,7 @@ local function logEndTests(duration)
testReporter:endTests(duration)

testReporter:report(config.testResultsFilePath)
headless = false
end

local function logTestResult(testResult)
Expand Down Expand Up @@ -142,6 +144,9 @@ local function findAllTestFiles(patterns)
result[#result + 1] = testFileInfo
end
end
if headless then
result[#result+1] = {label="infolog", filename="common/testing/infologtest.lua"}
end
return result
end

Expand Down Expand Up @@ -1258,6 +1263,7 @@ function widget:Initialize()
self,
"runtestsheadless",
function(cmd, optLine, optWords, data, isRepeat, release, actions)
headless = true
config.noColorOutput = true
config.quitWhenDone = true
config.gameStartTestPatterns = Util.splitPhrases(optLine)
Expand Down

0 comments on commit 4b560e6

Please sign in to comment.