---@class DBMCoreNamespace local private = select(2, ...) ---@class DBM local DBM = private:GetPrototype("DBM") local CL = DBM_COMMON_L ---@class DBMTest local test = private:GetPrototype("DBMTest") DBM.Test = test -- Indicates whether a test is currently running. test.testRunning = false -- Overriden by DBM-Test once loaded. -- This field is intentionally set in an odd way to prevent LuaLS from suggesting this function. local traceField = "Trace" test[traceField] = function() end local LoadAddOn = _G.C_AddOns.LoadAddOn or LoadAddOn ---@diagnostic disable-line:deprecated function test:Load() local loaded, err = LoadAddOn("DBM-Test") if not loaded then DBM:AddMsg("Failed to load DBM-Test: " .. (_G["ADDON_" .. err] or CL.UNKNOWN)) return loaded, err end return true end function test:LoadAllTests() local numTestAddOnsFound = 0 if not self:Load() then return nil end for i = 1, C_AddOns.GetNumAddOns() do if C_AddOns.GetAddOnMetadata(i, "X-DBM-Test") then numTestAddOnsFound = numTestAddOnsFound + 1 C_AddOns.LoadAddOn(i) end end return numTestAddOnsFound end function test:TestsLoaded() return self.Registry ~= nil and #self.Registry.sortedTests > 0 end function test:HandleCommand(testName, timeWarp) timeWarp = timeWarp and tonumber(timeWarp:match("(%d+)")) local numTestAddOnsFound = self:LoadAllTests() if not numTestAddOnsFound then return end if numTestAddOnsFound == 0 then DBM:AddMsg("No test AddOns installed, install an alpha or dev version of DBM to get DBM-Test-* mods.") end if testName:lower() == "list" or testName:lower() == "help" then DBM:AddMsg("Available tests:") for _, v in ipairs(self.Registry.sortedTests) do DBM:AddMsg(" " .. v) end if #self.Registry.sortedTests == 0 then DBM:AddMsg(" (none)") end DBM:AddMsg("/dbm test