Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions common/testing/infologtest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

local maxErrors = 10

function skip()
local function skip()
-- TODO: re-enable. disabled 2025-10-01 in order to get CICD working
return true
end
Expand Down Expand Up @@ -50,9 +50,11 @@ local function infologTest()
end


function test()
local function test()
local errors = infologTest()
if #errors > 0 then
error(table.concat(errors, "\n"), 0)
end
end

return { skip = skip, test = test }
12 changes: 7 additions & 5 deletions luaui/Tests/ai_stai_factory_rect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,33 @@ local function assertRect(expectedX, expectedZ, got)
assert(got.outZ == expectedZ, ("outZ mismatch: expected %d, got %s"):format(expectedZ, tostring(got.outZ)))
end

function test_factory_apron_for_unknown_exit()
local function test_factory_apron_for_unknown_exit()
-- Factories not listed in factoryExitSides get the generous apron.
local got = factoryRect.getOutsets("fac_unknown_exit", unitTable, factoryExitSides)
assertRect(10 * 6, 12 * 9, got)
end

function test_air_factory_uses_default_rect()
local function test_air_factory_uses_default_rect()
-- Air factories (exit side 0) should fall back to default building spacing, not apron/lane.
local got = factoryRect.getOutsets("fac_air_exit", unitTable, factoryExitSides)
assertRect(5 * 4, 7 * 4, got)
end

function test_default_rect_for_non_factory()
local function test_default_rect_for_non_factory()
local got = factoryRect.getOutsets("builder", unitTable, factoryExitSides)
assertRect(3 * 4, 4 * 4, got)
end

function test_nil_when_exit_side_known()
local function test_nil_when_exit_side_known()
local got = factoryRect.getOutsets("fac_known_exit", unitTable, factoryExitSides)
assert(got == nil, "expected nil when exit side is known (lane handled elsewhere)")
end

function test()
local function test()
test_factory_apron_for_unknown_exit()
test_air_factory_uses_default_rect()
test_default_rect_for_non_factory()
test_nil_when_exit_side_known()
end

return { test = test }
10 changes: 6 additions & 4 deletions luaui/Tests/cmd_blueprint/test_cmd_blueprint_filter.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
local widgetName = "Blueprint"

function skip()
local function skip()
-- TODO re-enable and debug. Disabled 2025-09-30 to unblock CICD
-- return Spring.GetGameFrame() <= 0
return true
end

function setup()
local function setup()
assert(widgetHandler.knownWidgets[widgetName] ~= nil)

Test.clearMap()
Expand All @@ -20,14 +20,14 @@ function setup()
})
end

function cleanup()
local function cleanup()
Test.clearMap()

Spring.SetCameraState(initialCameraState)
end

local delay = 5
function test()
local function test()
assert(widget)

mock_saveBlueprintsToFile = Test.mock(widget, "saveBlueprintsToFile")
Expand Down Expand Up @@ -97,3 +97,5 @@ function test()
widget.handleBlueprintDeleteAction()
assert(widget.selectedBlueprintIndex == nil, widget.selectedBlueprintIndex)
end

return { skip = skip, setup = setup, test = test, cleanup = cleanup }
10 changes: 6 additions & 4 deletions luaui/Tests/cmd_blueprint/test_cmd_blueprint_line.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local widgetName = "Blueprint"

function skip()
local function skip()
return not Platform.gl
end

function setup()
local function setup()
assert(widgetHandler.knownWidgets[widgetName] ~= nil)

Test.clearMap()
Expand All @@ -21,14 +21,14 @@ function setup()
})
end

function cleanup()
local function cleanup()
Test.clearMap()

Spring.SetCameraState(initialCameraState)
end

local delay = 5
function test()
local function test()
widget = widgetHandler:FindWidget(widgetName)
assert(widget)

Expand Down Expand Up @@ -128,3 +128,5 @@ function test()
assert(#builderQueue == bpCount, #builderQueue)
assert(builderQueue[1].id == -blueprintUnitDefID)
end

return { skip = skip, setup = setup, test = test, cleanup = cleanup }
6 changes: 3 additions & 3 deletions luaui/Tests/cmd_blueprint/test_cmd_blueprint_single.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local widgetName = "Blueprint"

function setup()
local function setup()
assert(widgetHandler.knownWidgets[widgetName] ~= nil)

Test.clearMap()
Expand All @@ -16,14 +16,14 @@ function setup()
})
end

function cleanup()
local function cleanup()
Test.clearMap()

Spring.SetCameraState(initialCameraState)
end

local delay = 5
function test()
local function test()
widget = widgetHandler:FindWidget(widgetName)
assert(widget)

Expand Down
10 changes: 6 additions & 4 deletions luaui/Tests/cmd_stop_selfd/test_cmd_stop_selfd.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
function skip()
local function skip()
return Spring.GetGameFrame() <= 0
end

function setup()
local function setup()
Test.clearMap()
-- Enable UnitCommand callin for tests
Test.expectCallin("UnitCommand")
end

function cleanup()
local function cleanup()
Test.clearMap()
end

function test()
local function test()
widget = widgetHandler:FindWidget("Stop means Stop")
assert(widget)

Expand Down Expand Up @@ -45,3 +45,5 @@ function test()
assert(Spring.GetUnitSelfDTime(unitID) == 0)
assert(Spring.GetUnitCommandCount(unitID) == 0)
end

return { skip = skip, setup = setup, test = test, cleanup = cleanup }
12 changes: 7 additions & 5 deletions luaui/Tests/critters/test_critters.lua
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
function skip()
local function skip()
-- TODO re-enable and debug. Disabled 2025-12-22 to unblock CICD
return true
end

function setup()
local function setup()
Test.clearMap()
Test.levelHeightMap()

Spring.SendCommands("globallos")
Spring.SendCommands("setspeed 5")
end

function cleanup()
local function cleanup()
Spring.SendCommands("globallos")
Spring.SendCommands("setspeed 1")

Test.clearMap()
end

function runCritterTest()
local function runCritterTest()
local WAIT_FRAMES = 204 -- enough to trigger critter cleanup/restoring by gaia_critters
local unitName = 'armpw'
local critterName = 'critter_crab'
Expand Down Expand Up @@ -176,6 +176,8 @@ function runCritterTest()
assert(countAliveCritters() == 36)
end

function test()
local function test()
runCritterTest()
end

return { skip = skip, setup = setup, test = test, cleanup = cleanup }
10 changes: 6 additions & 4 deletions luaui/Tests/gui_pip/test_gui_pip_autostart_maximize.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
local widgetName = "Picture-in-Picture"
local originalGetSpectatingState = nil

function skip()
local function skip()
return Spring.GetGameFrame() <= 0 or widgetHandler.knownWidgets[widgetName] == nil
end

function setup()
local function setup()
Test.clearMap()
originalGetSpectatingState = Spring.GetSpectatingState
Spring.GetSpectatingState = function()
Expand All @@ -15,15 +15,15 @@ function setup()
assert(widget)
end

function cleanup()
local function cleanup()
if originalGetSpectatingState ~= nil then
Spring.GetSpectatingState = originalGetSpectatingState
originalGetSpectatingState = nil
end
Test.clearMap()
end

function test()
local function test()
local vsx, vsy = Spring.GetViewGeometry()
local uiScale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1)
local widgetScale = (vsy / 2000) * uiScale
Expand All @@ -46,3 +46,5 @@ function test()
assert(expandedWidth >= minExpandedSize, string.format("expandedWidth too small: %.2f < %d", expandedWidth, minExpandedSize))
assert(expandedHeight >= minExpandedSize, string.format("expandedHeight too small: %.2f < %d", expandedHeight, minExpandedSize))
end

return { skip = skip, setup = setup, test = test, cleanup = cleanup }
10 changes: 6 additions & 4 deletions luaui/Tests/gui_selfd_icons/test_gui_selfd_icons_armpw.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
local widgetName = "Self-Destruct Icons"

function skip()
local function skip()
return Spring.GetGameFrame() <= 0
end

function setup()
local function setup()
Test.clearMap()

Test.prepareWidget(widgetName)
end

function cleanup()
local function cleanup()
Test.clearMap()
end

function test()
local function test()
widget = widgetHandler:FindWidget(widgetName)
assert(widget)

Expand Down Expand Up @@ -57,3 +57,5 @@ function test()
assert(table.count(widget.activeSelfD) == 1)
assert(table.count(widget.queuedSelfD) == 0)
end

return { skip = skip, setup = setup, test = test, cleanup = cleanup }
10 changes: 6 additions & 4 deletions luaui/Tests/gui_selfd_icons/test_gui_selfd_icons_armvp.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
local widgetName = "Self-Destruct Icons"

function skip()
local function skip()
return Spring.GetGameFrame() <= 0
end

function setup()
local function setup()
Test.clearMap()

Test.prepareWidget(widgetName)
end

function cleanup()
local function cleanup()
Test.clearMap()
end

function test()
local function test()
widget = widgetHandler:FindWidget(widgetName)
assert(widget)

Expand Down Expand Up @@ -52,3 +52,5 @@ function test()
--assert(table.count(widget.activeSelfD) == 0)
--assert(table.count(widget.queuedSelfD) == 0)
end

return { skip = skip, setup = setup, test = test, cleanup = cleanup }
10 changes: 6 additions & 4 deletions luaui/Tests/mex-building/pregame_mex_queue.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function skip()
local function skip()
return Spring.GetGameFrame() > 0
end

-- Test whether mexes are able to clear queued buildings by shift-clicking
function setup()
local function setup()
Test.clearMap()

local widget_cmd_extractor_snap = widgetHandler:FindWidget("Extractor Snap (mex/geo)")
Expand All @@ -25,7 +25,7 @@ function setup()
Test.waitTime(10)
end

function cleanup()
local function cleanup()
Test.clearMap()

WG['pregame-build'].setBuildQueue({})
Expand All @@ -35,7 +35,7 @@ function cleanup()
end

-- tests both pregame mex snap behavior, as well as basic queue and blueprint handling
function test()
local function test()
local mexUnitDefId = UnitDefNames["armmex"].id
local metalSpots = WG['resource_spot_finder'].metalSpotsList

Expand Down Expand Up @@ -108,3 +108,5 @@ function test()
local buildQueue = WG['pregame-build'].getBuildQueue()
assert(#buildQueue == 0, "Build queue should be empty")
end

return { skip = skip, setup = setup, test = test, cleanup = cleanup }
10 changes: 6 additions & 4 deletions luaui/Tests/mex-building/pregame_mex_snap.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function skip()
local function skip()
return Spring.GetGameFrame() > 0
end

function setup()
local function setup()
Test.clearMap()

widget_cmd_extractor_snap = widgetHandler:FindWidget("Extractor Snap (mex/geo)")
Expand All @@ -24,7 +24,7 @@ function setup()
Test.waitTime(10)
end

function cleanup()
local function cleanup()
Test.clearMap()

WG['pregame-build'].setBuildQueue({})
Expand All @@ -33,7 +33,7 @@ function cleanup()
Spring.SetCameraState(initialCameraState)
end

function test()
local function test()
mexUnitDefId = UnitDefNames["armmex"].id
metalSpots = WG['resource_spot_finder'].metalSpotsList

Expand Down Expand Up @@ -86,3 +86,5 @@ function test()
0
}, 0.1)
end

return { skip = skip, setup = setup, test = test, cleanup = cleanup }
Loading
Loading