From 03b5718c4f9f0e7beee8e7acc19c2edf0d7aecba Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 22 Jun 2016 21:30:19 +0000 Subject: l3build (22jun16) git-svn-id: svn://tug.org/texlive/trunk@41523 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/l3build/l3build.lua | 171 +++++++++++++-------- .../tex/latex/l3build/regression-test.tex | 13 +- 2 files changed, 118 insertions(+), 66 deletions(-) (limited to 'Master/texmf-dist/tex/latex/l3build') diff --git a/Master/texmf-dist/tex/latex/l3build/l3build.lua b/Master/texmf-dist/tex/latex/l3build/l3build.lua index 4348135b50d..f6a58a0a1c4 100644 --- a/Master/texmf-dist/tex/latex/l3build/l3build.lua +++ b/Master/texmf-dist/tex/latex/l3build/l3build.lua @@ -17,8 +17,8 @@ --]] -- Version information: should be identical to that in l3build.dtx -release_date = "2016/06/14" -release_ver = "6608" +release_date = "2016/06/22" +release_ver = "6641" -- "module" is a deprecated function in Lua 5.2: as we want the name -- for other purposes, and it should eventually be 'free', simply @@ -182,7 +182,7 @@ function argparse() help = "help" , pdf = "pdf" , quiet = "quiet" , - version = "version" + release = "release" } local short_options = { @@ -192,7 +192,7 @@ function argparse() H = "halt" , p = "pdf" , q = "quiet" , - v = "version" + r = "release" } local option_args = { @@ -202,7 +202,7 @@ function argparse() help = false, pdf = false, quiet = false, - version = true + release = true } -- arg[1] is a special case: must be a command or "-h"/"--help" -- Deal with this by assuming help and storing only apparently-valid @@ -312,7 +312,7 @@ opthalt = userargs["halt"] opthelp = userargs["help"] optpdf = userargs["pdf"] optquiet = userargs["quiet"] -optversion = userargs["version"] +optrelease = userargs["release"] -- Convert a file glob into a pattern for use by e.g. string.gub -- Based on https://github.com/davidm/lua-glob-pattern @@ -609,9 +609,9 @@ function allmodules(target) if optengines then engines = " --engine=" .. table.concat(optengines, ",") end - local version = "" - if optversion then - version = " --version=" .. optversion[1] + local release = "" + if optrelease then + release = " --release=" .. release[1] end local errorlevel = run( i, @@ -621,7 +621,7 @@ function allmodules(target) .. engines .. (optpdf and " -p" or "") .. (optquiet and " -q" or "") - .. version + .. release ) if errorlevel ~= 0 then return errorlevel @@ -761,7 +761,7 @@ function formatlog(logfile, newfile, engine) return false end -- Substitutions to remove some non-useful changes - local function normalize(line) + local function normalize(line, lastline) -- Zap line numbers from \show, \showbox, \box_show and the like: -- do this before wrapping lines line = string.gsub(line, "^l%.%d+ ", "l. ...") @@ -769,8 +769,7 @@ function formatlog(logfile, newfile, engine) -- Skip lines that have an explicit marker for truncation if string.len(line) == maxprintline and not string.match(line, "%.%.%.$") then - lastline = (lastline or "") .. line - return "" + return "", (lastline or "") .. line end local line = (lastline or "") .. line lastline = "" @@ -800,7 +799,7 @@ function formatlog(logfile, newfile, engine) -- Merge all of .fd data into one line so will be removed later if string.match(line, "^ *%([%.%/%w]+%.fd[^%)]*$") then lastline = (lastline or "") .. line - return "" + return "", (lastline or "") .. line end -- TeX90/XeTeX knows only the smaller set of dimension units line = string.gsub( @@ -819,6 +818,25 @@ function formatlog(logfile, newfile, engine) end -- Remove 'normal' direction information on boxes with (u)pTeX line = string.gsub(line, ",? yoko direction,?", "") + -- Remove the \special line that in DVI mode keeps PDFs comparable + if string.match(line, "^%.*\\special%{pdf: docinfo << /Creator") then + return "" + end + -- Remove the \special line possibly present in DVI mode for paper size + if string.match(line, "^%.*\\special%{papersize") then + return "" + end + -- Remove ConTeXt stuff + if string.match(line, "^backend >") or + string.match(line, "^close source >") or + string.match(line, "^mkiv lua stats >") or + string.match(line, "^pages >") or + string.match(line, "^system >") or + string.match(line, "^used file >") or + string.match(line, "^used option >") or + string.match(line, "^used structure >") then + return "" + end -- A tidy-up to keep LuaTeX and other engines in sync local utf8_char = unicode.utf8.char line = string.gsub(line, utf8_char(127), "^^?") @@ -829,7 +847,7 @@ function formatlog(logfile, newfile, engine) line = string.gsub(line, utf8_char(i), "^^" .. string.format("%02x", i)) end end - return line + return line, lastline end local lastline = "" local newlog = "" @@ -845,7 +863,7 @@ function formatlog(logfile, newfile, engine) elseif string.match(line, "^%)?TIMO$") then skipping = false elseif not prestart and not skipping then - line = normalize(line) + line, lastline = normalize(line, lastline) if not string.match(line, "^ *$") and not killcheck(line) then newlog = newlog .. line .. os_newline end @@ -1073,11 +1091,11 @@ function runcheck(name, hide) if i == "luajitex" then engine = "luatex" end - setup_check(name, engine) - runtest(name, i, hide, lvtext) - -- Generation of results heavily depends on test type + checkpdf = setup_check(name, engine) + runtest(name, i, hide, lvtext, checkpdf) + -- Generation of results depends on test type local errlevel - if optpdf then + if checkpdf then errlevel = compare_pdf(name, engine) else errlevel = compare_tlg(name, engine) @@ -1095,39 +1113,52 @@ end function setup_check(name, engine) local testname = name .. "." .. engine - local refext = ((optpdf and pdfext) or tlgext) - local reffile = locate( + local pdffile = locate( + {testfiledir, unpackdir}, + {testname .. pdfext, name .. pdfext} + ) + local tlgfile = locate( {testfiledir, unpackdir}, - {testname .. refext, name .. refext} + {testname .. tlgext, name .. tlgext} ) -- Attempt to generate missing reference file from expectation - if not reffile then + if not (pdffile or tlgfile) then if not locate({unpackdir, testfiledir}, {name .. lveext}) then print( - "Error: failed to find " .. refext .. " or " + "Error: failed to find " .. pdfext .. ", " .. tlgext .. " or " .. lveext .. " file for " .. name .. "!" ) os.exit(1) end - runtest(name, engine, hide, lveext) - reffile = testdir .. "/" .. testname .. refext - if not optpdf then + runtest(name, engine, true, lveext, true) + pdffile = testdir .. "/" .. testname .. pdfext + -- If a PDF is generated use it for comparisons + if not fileexists(pdffile) then + pdffile = nil ren(testdir, testname .. logext, testname .. tlgext) end else - cp( - string.match(reffile, ".*/(.*)"), - string.match(reffile, "(.*)/.*"), - testdir - ) + -- Install comparison files found + for _,v in pairs({pdffile, tlgfile}) do + if v then + cp( + string.match(v, ".*/(.*)"), + string.match(v, "(.*)/.*"), + testdir + ) + end + end end - if optpdf then - local reffile = string.match(reffile, ".*/(.*)") + if pdffile then + local pdffile = string.match(pdffile, ".*/(.*)") ren( testdir, - reffile, - string.gsub(reffile, pdfext .. "$", ".ref" .. pdfext) + pdffile, + string.gsub(pdffile, pdfext .. "$", ".ref" .. pdfext) ) + return true + else + return false end end @@ -1139,6 +1170,9 @@ function compare_pdf(name, engine) local refpdffile = locate( {testdir}, {testname .. ".ref" .. pdfext, name .. ".ref" .. pdfext} ) + if not refpdffile then + return + end if os_windows then refpdffile = unix_to_win(refpdffile) end @@ -1157,6 +1191,9 @@ function compare_tlg(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 + end if os_windows then tlgfile = unix_to_win(tlgfile) end @@ -1187,7 +1224,7 @@ end -- Run one of the test files: doesn't check the result so suitable for -- both creating and verifying .tlg files -function runtest(name, engine, hide, ext) +function runtest(name, engine, hide, ext, makepdf) local lvtfile = name .. (ext or lvtext) cp(lvtfile, fileexists(testfiledir .. "/" .. lvtfile) and testfiledir or unpackdir, testdir) @@ -1216,9 +1253,21 @@ function runtest(name, engine, hide, ext) end -- Special casing for XeTeX engine local checkopts = checkopts - if string.match(engine, "xetex") then - if not optpdf then - checkopts = checkopts .. " -no-pdf" + if string.match(engine, "xetex") and not makepdf then + checkopts = checkopts .. " -no-pdf" + end + -- Special casing for ConTeXt + if string.match(checkformat, "^context$") then + format = "" + if engine == "luatex" or engine == "luajittex" then + realengine = "context" + elseif engine == "pdftex" then + realengine = "texexec" + elseif engine == "xetex" then + realengine = "texexec --xetex" + else + print("Engine incompatible with format") + os.exit(1) end end local logfile = testdir .. "/" .. name .. logext @@ -1255,10 +1304,8 @@ function runtest(name, engine, hide, ext) runtest_tasks(stripext(lvtfile)) ) end - if optpdf then - if fileexists(testdir .. "/" .. name .. dviext) then - dvitopdf(name, testdir, engine, hide) - end + if makepdf and fileexists(testdir .. "/" .. name .. dviext) then + dvitopdf(name, testdir, engine, hide) end formatlog(logfile, newfile, engine) -- Store secondary files for this engine @@ -1468,7 +1515,7 @@ function help() print(" --halt-on-error|-H Stops running tests after the first failure") print(" --pdf|-p Check/save PDF files") print(" --quiet|-q Suppresses TeX output when unpacking") - print(" --version|-v Sets the version to insert into sources") + print(" --release|-r Sets the release to insert into sources") print("") print("See l3build.pdf for further details.") end @@ -1782,7 +1829,7 @@ function save(names) local refext = ((optpdf and pdfext) or tlgext) if testexists(name) then print("Creating and copying " .. refext) - runtest(name, engine, false, lvtext) + runtest(name, engine, false, lvtext, optpdf) if optpdf then ren(testdir, pdffile, spdffile) cp(spdffile, testdir, testfiledir) @@ -1814,7 +1861,7 @@ end -- Provide some standard search-and-replace functions if versionform ~= "" and not setversion_update_line then if versionform == "ProvidesPackage" then - function setversion_update_line(line, date, version) + function setversion_update_line(line, date, release) -- No real regex so do it one type at a time for _,i in pairs({"Class", "File", "Package"}) do if string.match( @@ -1824,7 +1871,7 @@ if versionform ~= "" and not setversion_update_line then line = string.gsub(line, "%[%d%d%d%d/%d%d/%d%d", "[" .. string.gsub(date, "%-", "/")) line = string.gsub( - line, "(%[%d%d%d%d/%d%d/%d%d) [^ ]*", "%1 " .. version + line, "(%[%d%d%d%d/%d%d/%d%d) [^ ]*", "%1 " .. release ) break end @@ -1832,7 +1879,7 @@ if versionform ~= "" and not setversion_update_line then return line end elseif versionform == "ProvidesExplPackage" then - function setversion_update_line(line, date, version) + function setversion_update_line(line, date, release) -- No real regex so do it one type at a time for _,i in pairs({"Class", "File", "Package"}) do if string.match( @@ -1842,7 +1889,7 @@ if versionform ~= "" and not setversion_update_line then line = string.gsub( line, "{%d%d%d%d/%d%d/%d%d}( *){[^}]*}", - "{" .. string.gsub(date, "%-", "/") .. "}%1{" .. version .. "}" + "{" .. string.gsub(date, "%-", "/") .. "}%1{" .. release .. "}" ) break end @@ -1850,22 +1897,22 @@ if versionform ~= "" and not setversion_update_line then return line end elseif versionform == "filename" then - function setversion_update_line(line, date, version) + function setversion_update_line(line, date, release) if string.match(line, "^\\def\\filedate{%d%d%d%d/%d%d/%d%d}$") then line = "\\def\\filedate{" .. string.gsub(date, "%-", "/") .. "}" end if string.match(line, "^\\def\\fileversion{[^}]+}$") then - line = "\\def\\fileversion{" .. version .. "}" + line = "\\def\\fileversion{" .. release .. "}" end return line end elseif versionform == "ExplFileName" then - function setversion_update_line(line, date, version) + function setversion_update_line(line, date, release) if string.match(line, "^\\def\\ExplFileDate{%d%d%d%d/%d%d/%d%d}$") then line = "\\def\\ExplFileDate{" .. string.gsub(date, "%-", "/") .. "}" end if string.match(line, "^\\def\\ExplFileVersion{[^}]+}$") then - line = "\\def\\ExplFileVersion{" .. version .. "}" + line = "\\def\\ExplFileVersion{" .. release .. "}" end return line end @@ -1873,7 +1920,7 @@ if versionform ~= "" and not setversion_update_line then end -- Used to actually carry out search-and-replace -setversion_update_line = setversion_update_line or function(line, date, version) +setversion_update_line = setversion_update_line or function(line, date, release) return line end @@ -1910,13 +1957,13 @@ function setversion() if optdate then date = optdate[1] or date end - local version = -1 - if optversion then - version = optversion[1] or version + local release = -1 + if optrelease then + release = optrelease[1] or release end for _,i in pairs(versionfiles) do for _,j in pairs(filelist(".", i)) do - rewrite(j, date, version) + rewrite(j, date, release) end end return 0 @@ -2050,7 +2097,7 @@ function stdmain(target, files) errorlevel = bundlectan() elseif target == "doc" then errorlevel = doc(files) - elseif target == "check" and testfiledir ~= "" then + elseif target == "check" then errorlevel = check(files) elseif target == "clean" then errorlevel = clean() @@ -2060,7 +2107,7 @@ function stdmain(target, files) errorlevel = ctan(true) elseif target == "install" then errorlevel = install() - elseif target == "save" and testfiledir ~= "" then + elseif target == "save" then if next(files) then errorlevel = save(files) else diff --git a/Master/texmf-dist/tex/latex/l3build/regression-test.tex b/Master/texmf-dist/tex/latex/l3build/regression-test.tex index c6ea45f02ac..7e77b55cdda 100644 --- a/Master/texmf-dist/tex/latex/l3build/regression-test.tex +++ b/Master/texmf-dist/tex/latex/l3build/regression-test.tex @@ -47,10 +47,15 @@ %% %% ----------------------------------------------------------------------- %% -\expandafter\edef\csname reset\string @catcodes\endcsname{% - \catcode`\noexpand\@=\the\catcode`\@\relax -} -\catcode`\@=11 % +\ifx\unprotect\undefined + \expandafter\edef\csname reset\string @catcodes\endcsname{% + \catcode`\noexpand\@=\the\catcode`\@\relax + } + \catcode`\@=11 % +\else + \unprotect + \def\reset@catcodes{\protect}% +\fi \scrollmode \errorcontextlines=-1 % \showboxbreadth=\maxdimen -- cgit v1.2.3