From 5552feafca3cd3d39a20074dbd0b85f0220f0140 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 25 Oct 2016 18:49:42 +0200 Subject: CI: API test defaults to failure, unless explicitly succeeded. This fixes problems with the CI build succeeding when the API description has a syntax error in it and the APIDump plugin won't even load. --- Server/Plugins/APIDump/main_APIDump.lua | 43 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'Server') diff --git a/Server/Plugins/APIDump/main_APIDump.lua b/Server/Plugins/APIDump/main_APIDump.lua index c2d70734d..df2d933f8 100644 --- a/Server/Plugins/APIDump/main_APIDump.lua +++ b/Server/Plugins/APIDump/main_APIDump.lua @@ -26,29 +26,25 @@ local function LoadAPIFiles(a_Folder, a_DstTable) local FileName = Folder .. fnam; -- We only want .lua files from the folder: if (cFile:IsFile(FileName) and fnam:match(".*%.lua$")) then - local TablesFn, Err = loadfile(FileName); - if (type(TablesFn) ~= "function") then - LOGWARNING("Cannot load API descriptions from " .. FileName .. ", Lua error '" .. Err .. "'."); - else - local Tables = TablesFn(); - if (type(Tables) ~= "table") then - LOGWARNING("Cannot load API descriptions from " .. FileName .. ", returned object is not a table (" .. type(Tables) .. ")."); - break - end - for k, cls in pairs(Tables) do - if (a_DstTable[k]) then - -- The class is documented in two files, warn and store into a file (so that CIs can mark build as failure): - LOGWARNING(string.format( - "APIDump warning: class %s is documented at two places, the documentation in file %s will overwrite the previously loaded one!", - k, FileName - )) - local f = io.open("DuplicateDocs.txt", "a") - f:write(k, "\t", FileName) - f:close() - end - a_DstTable[k] = cls; + local TablesFn = assert(loadfile(FileName)) + local Tables = TablesFn() + if (type(Tables) ~= "table") then + error("Cannot load API descriptions from " .. FileName .. ", returned object is not a table (" .. type(Tables) .. ").") + break + end + for k, cls in pairs(Tables) do + if (a_DstTable[k]) then + -- The class is documented in two files, warn and store into a file (so that CIs can mark build as failure): + LOGWARNING(string.format( + "APIDump warning: class %s is documented at two places, the documentation in file %s will overwrite the previously loaded one!", + k, FileName + )) + local f = io.open("DuplicateDocs.txt", "a") + f:write(k, "\t", FileName) + f:close() end - end -- if (TablesFn) + a_DstTable[k] = cls + end end -- if (is lua file) end -- for fnam - Folder[] end @@ -2040,6 +2036,9 @@ local function HandleCmdApiCheck(a_Split, a_EntireCmd) return true, "Found new undocumented symbols:\n" .. table.concat(newUndocumented, "\n") end + -- The check completed successfully, remove the "test failed" flag from the filesystem: + cFile:DeleteFile("apiCheckFailed.flag") + return true, "API check completed successfully" end -- cgit v1.2.3