From 66f6e60b6dc60cc08482030b92df223b6a51b15f Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sun, 29 Aug 2021 03:02:07 +0000 Subject: CTAN sync 202108290302 --- macros/latex/contrib/l3build/l3build-check.lua | 76 ++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 6 deletions(-) (limited to 'macros/latex/contrib/l3build/l3build-check.lua') diff --git a/macros/latex/contrib/l3build/l3build-check.lua b/macros/latex/contrib/l3build/l3build-check.lua index 47ab19ced6..f83dee4e44 100644 --- a/macros/latex/contrib/l3build/l3build-check.lua +++ b/macros/latex/contrib/l3build/l3build-check.lua @@ -574,14 +574,16 @@ function runcheck(name, hide) if options["engine"] then checkengines = options["engine"] end + local failedengines = {} -- Used for both .lvt and .pvt tests local test_type = test_types[kind] local function check_and_diff(engine) - runtest(name, engine, hide, test_type.test, test_type, true) + runtest(name, engine, hide, test_type.test, test_type, not forcecheckruns) local errorlevel = base_compare(test_type,name,engine) if errorlevel == 0 then return errorlevel end + failedengines[#failedengines + 1] = engine if options["show-log-on-error"] then showfailedlog(name) end @@ -595,14 +597,20 @@ function runcheck(name, hide) setup_check(name,engine) local errlevel = check_and_diff(engine) if errlevel ~= 0 and options["halt-on-error"] then - return 1 + return 1, failedengines end if errlevel > errorlevel then errorlevel = errlevel end end + for i=1, #failedengines do + if failedengines[i] == stdengine then + failedengines = {stdengine} + break + end + end -- Return everything - return errorlevel + return errorlevel, failedengines end function setup_check(name, engine) @@ -845,11 +853,57 @@ function testexists(test) end end +-- A short auxiliary to print the list of differences for check +local function showsavecommands(failurelist) + local savecmds = {} + local checkcmd = "l3build check --show-saves" + local prefix = "l3build save" + if options.config and options.config[1] ~= 'build' then + local config = " -c " .. options.config[1] + prefix = prefix .. config + checkcmd = checkcmd .. config + end + for name, engines in pairs(failurelist) do + for i = 1, #engines do + local engine = engines[i] + local cmd = savecmds[engine] + if not cmd then + if engine == stdengine then + cmd = prefix + else + cmd = prefix .. " -e " .. engine + end + end + savecmds[engine] = cmd .. " " .. name + if engine == stdengine then + checkcmd = checkcmd .. " " .. name + end + end + end + print(" To regenerate the test files, run\n") + local f = open(testdir .. "/.savecommands", "w") + for _, cmds in pairs(savecmds) do + print(" " .. cmds) + f:write(cmds, "\n") + end + f:write"\n" + if savecmds[stdengine] then + print("\n Afterwards test for engine specific changes using\n") + print(" " .. checkcmd) + f:write(checkcmd) + end + f:close() + print("") +end + function check(names) local errorlevel = 0 if testfiledir ~= "" and direxists(testfiledir) then if not options["rerun"] then - checkinit() + errorlevel = checkinit() + if errorlevel ~= 0 then + return errorlevel + end end local hide = true if names and next(names) then @@ -933,11 +987,13 @@ function check(names) end -- Actually run the tests print("Running checks on") + local failurelist = {} for i, name in ipairs(names) do print(" " .. name .. " (" .. i .. "/" .. #names ..")") - local errlevel = runcheck(name, hide) + local errlevel, failedengines = runcheck(name, hide) -- Return value must be 1 not errlevel if errlevel ~= 0 then + failurelist[name] = failedengines if options["halt-on-error"] then return 1 else @@ -949,6 +1005,9 @@ function check(names) end if errorlevel ~= 0 then checkdiff() + if options["show-saves"] then + showsavecommands(failurelist) + end else print("\n All checks passed\n") end @@ -994,7 +1053,12 @@ function showfaileddiff() end function save(names) - checkinit() + do + local errorlevel = checkinit() + if errorlevel ~= 0 then + return errorlevel + end + end local engines = options["engine"] or {stdengine} if names == nil then print("Arguments are required for the save command") -- cgit v1.2.3