[latex3-commits] [git/LaTeX3-latex3-l3build] master: Revert "Testing an idea .. this might vanish" (511d2f0)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Jul 31 14:44:28 CEST 2018


Repository : https://github.com/latex3/l3build
On branch  : master
Link       : https://github.com/latex3/l3build/commit/511d2f01fec410f700b45be65c3a556c81b06f28

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

commit 511d2f01fec410f700b45be65c3a556c81b06f28
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Jul 31 13:41:46 2018 +0100

    Revert "Testing an idea .. this might vanish"
    
    This reverts commit 3ca0d88f6ed06ecfbd3f3360b6591168d795e7f0.


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

511d2f01fec410f700b45be65c3a556c81b06f28
 CHANGELOG.md            |    2 +-
 l3build-check.lua       |   40 +++++++++++++++++++++++++++++++++++-----
 testfiles/00-test-2.tpf |  Bin 9798 -> 2726 bytes
 3 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 363e5b6..734626c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,7 +13,7 @@ this project uses date-based 'snapshot' version identifiers.
   `main()`
 
 ### Changed
-- PDF-based testing now uses PDF file for comparison,
+- PDF-based testing now uses 'digested' PDF file for comparison,
   working from dedicated .pvt input files
 
 ### Removed
diff --git a/l3build-check.lua b/l3build-check.lua
index 947563c..38ea7dd 100644
--- a/l3build-check.lua
+++ b/l3build-check.lua
@@ -485,6 +485,31 @@ local function formatlualog(logfile, newfile, luatex)
   close(newfile)
 end
 
+local function normalise_pdf(pdffile,npdffile)
+  local file = assert(open(pdffile, "rb"))
+  local contents = gsub(file:read("*all") .. "\n", "\r\n", "\n")
+  close(file)
+  local newcontent = ""
+  local skip = false
+  for line in gmatch(contents, "([^\n]*)\n") do
+    if skip then
+      if match(line,"endstream") then
+        skip = false
+        line = ""
+      end
+    elseif match(line,"currentfile eexec") then
+      skip = true
+    end
+    if not match(line, "^ *$") and not skip then
+      newcontent = newcontent .. line .. os_newline
+    end
+  end 
+  local newfile = open(npdffile, "w")
+  output(newfile)
+  write(newcontent)
+  close(newfile)
+end
+
 -- Run one test which may have multiple engine-dependent comparisons
 -- Should create a difference file for each failed test
 function runcheck(name, hide)
@@ -569,9 +594,10 @@ end
 
 function compare_pdf(name,engine,cleanup)
   local errorlevel
+  local testname = name .. "." .. engine
   local difffile = testdir .. "/" .. name .. os_diffext
-  local pdffile  = testdir .. "/" .. name.. pdfext
-  local tpffile  = testdir .. "/" .. name.. tpfext
+  local pdffile  = testdir .. "/" .. testname .. pdfext
+  local tpffile  = testdir .. "/" .. name .. tpfext
   if not tpffile then
     return 1
   end
@@ -677,6 +703,7 @@ function runtest(name, engine, hide, ext, pdfmode, breakout)
   local logfile = testdir .. "/" .. name .. logext
   local newfile = testdir .. "/" .. name .. "." .. engine .. logext
   local pdffile = testdir .. "/" .. name .. pdfext
+  local npffile = testdir .. "/" .. name .. "." .. engine .. pdfext
   local asciiopt = ""
   for _,i in ipairs(asciiengines) do
     if realengine == i then
@@ -713,6 +740,7 @@ function runtest(name, engine, hide, ext, pdfmode, breakout)
     -- Break the loop if the result is stable
     if breakout and i < checkruns then
       if pdfmode then
+        normalise_pdf(pdffile,npffile)
         if compare_pdf(name,engine,true) == 0 then
           break
         end
@@ -727,7 +755,9 @@ function runtest(name, engine, hide, ext, pdfmode, breakout)
   if pdfmode and fileexists(testdir .. "/" .. name .. dviext) then
     dvitopdf(name, testdir, engine, hide)
   end
-  if not pdfmode then
+  if pdfmode then
+    normalise_pdf(pdffile,npffile)
+  else
     formatlog(logfile, newfile, engine, errlevels)
   end
   -- Store secondary files for this engine
@@ -898,10 +928,10 @@ function save(names)
         else
           -- Create one .tpf file
           print("Creating and copying " .. tpfext)
-          local pdffile  = name .. pdfext
           local tpffile  = name .. tpfext
+          local newfile  = name .. "." .. engine .. pdfext
           runtest(name,engine,false,pvtext,true)
-          ren(testdir,pdffile,tpffile)
+          ren(testdir,newfile,tpffile)
           cp(tpffile,testdir,testfiledir)
         end
         return 0
diff --git a/testfiles/00-test-2.tpf b/testfiles/00-test-2.tpf
index 260cae0..2eecdb4 100644
Binary files a/testfiles/00-test-2.tpf and b/testfiles/00-test-2.tpf differ





More information about the latex3-commits mailing list