[latex3-commits] [git/LaTeX3-latex3-l3build] new-types: Simplify compare (a02a670)

Marcel Fabian Krüger tex at 2krueger.de
Sat Feb 20 18:59:52 CET 2021


Repository : https://github.com/latex3/l3build
On branch  : new-types
Link       : https://github.com/latex3/l3build/commit/a02a670288c8bd8bd6dc7ae46bb5542f1a23463f

>---------------------------------------------------------------

commit a02a670288c8bd8bd6dc7ae46bb5542f1a23463f
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Wed Oct 21 19:25:57 2020 +0200

    Simplify compare


>---------------------------------------------------------------

a02a670288c8bd8bd6dc7ae46bb5542f1a23463f
 l3build-check.lua     | 28 +++++++++++++---------------
 l3build-variables.lua |  1 -
 2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/l3build-check.lua b/l3build-check.lua
index 5323e7c..ac0e812 100644
--- a/l3build-check.lua
+++ b/l3build-check.lua
@@ -577,7 +577,7 @@ function runcheck(name, hide)
   -- Used for both .lvt and .pvt tests
   local function check_and_diff(test_type, engine)
     runtest(name, engine, hide, test_type.test, test_type, true)
-    local errorlevel = test_type.compare(name,engine)
+    local errorlevel = base_compare(test_type,name,engine)
     if errorlevel == 0 then
       return errorlevel
     end
@@ -657,31 +657,29 @@ function setup_check(name, engine)
   exit(1)
 end
 
-function compare_pdf(name,engine,cleanup)
+function base_compare(test_type,name,engine,cleanup)
   local testname = name .. "." .. engine
-  local difffile = testdir .. "/" .. testname .. pdfext .. os_diffext
-  local pdffile  = testdir .. "/" .. testname .. pdfext
-  local tpffile  = locate({testdir}, {testname .. tpfext, name .. tpfext})
-  if not tpffile then
+  local difffile = testdir .. "/" .. testname .. test_type.generated .. os_diffext
+  local genfile  = testdir .. "/" .. testname .. test_type.generated
+  local reffile  = locate({testdir}, {testname .. test_type.reference, name .. test_type.reference})
+  if not reffile then
     return 1
   end
+  local compare = test_type.compare
+  if compare then
+    return compare(difffile, reffile, genfile, cleanup, name, engine)
+  end
   local errorlevel = execute(os_diffexe .. " "
-    .. normalize_path(tpffile .. " " .. pdffile .. " > " .. difffile))
+    .. normalize_path(reffile .. " " .. genfile .. " > " .. difffile))
   if errorlevel == 0 or cleanup then
     remove(difffile)
   end
   return errorlevel
 end
 
-function compare_tlg(name,engine,cleanup)
+function compare_tlg(difffile, tlgfile, logfile, cleanup, name, engine)
   local errorlevel
   local testname = name .. "." .. engine
-  local difffile = testdir .. "/" .. testname .. os_diffext
-  local logfile  = testdir .. "/" .. testname .. logext
-  local tlgfile  = locate({testdir}, {testname .. tlgext, name .. tlgext})
-  if not tlgfile then
-    return 1
-  end
   -- Do additional log formatting if the engine is LuaTeX, there is no
   -- LuaTeX-specific .tlg file and the default engine is not LuaTeX
   if (match(engine,"^lua") or match(engine,"^harf"))
@@ -803,7 +801,7 @@ function runtest(name, engine, hide, ext, test_type, breakout)
         end
       end
       test_type.rewrite(gen_file,new_file,engine,errlevels)
-      if test_type.compare(name,engine,true) == 0 then
+      if base_compare(test_type,name,engine,true) == 0 then
         break
       end
     end
diff --git a/l3build-variables.lua b/l3build-variables.lua
index 77ace18..090d259 100644
--- a/l3build-variables.lua
+++ b/l3build-variables.lua
@@ -220,7 +220,6 @@ test_types = setmetatable(test_types or {}, { __index = {
       test = pvtext,
       generated = pdfext,
       reference = tpfext,
-      compare = compare_pdf,
       rewrite = rewrite_pdf,
    },
 }})





More information about the latex3-commits mailing list.