Skip to content

Commit

Permalink
Fix async tests that operate synchronously, store testrunid through r…
Browse files Browse the repository at this point in the history
…efresh
  • Loading branch information
brandonsturgeon committed Oct 7, 2024
1 parent 58a8f6d commit 022e914
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lua/gluatest/runner/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ local LogTestFailureDetails = ResultLogger.LogTestFailureDetails
local PlainLogStart = ResultLogger.PlainLogStart
local noop = function() end

local caseID = 0
GLuaTest_CaseID = GLuaTest_CaseID or 0
local function getCaseID()
caseID = caseID + 1
return "case" .. caseID
GLuaTest_CaseID = GLuaTest_CaseID + 1
return "case" .. GLuaTest_CaseID
end

return function( allTestGroups )
Expand Down Expand Up @@ -255,14 +255,18 @@ return function( allTestGroups )
case.testComplete()
else
-- If the test ran successfully, start the case-specific timeout timer
local timeout = case.timeout or 60

timer.Create( "GLuaTest_AsyncTimeout_" .. case.id, timeout, 1, function()
setTimedOut( case )
callbacks[case.id] = false
if callbacks[case.id] == nil then
-- If the async case actually operated synchronously (i.e. called done() or fail() before we got here) then we don't need to set a timeout
local timeout = case.timeout or 60

case.testComplete()
end )
timer.Create( "GLuaTest_AsyncTimeout_" .. case.id, timeout, 1, function()
setTimedOut( case )
callbacks[case.id] = false

case.testComplete()
end )
end
end
end
end
Expand Down

0 comments on commit 022e914

Please sign in to comment.