diff options
author | Karl Berry <karl@freefriends.org> | 2015-04-30 20:40:06 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-04-30 20:40:06 +0000 |
commit | 0c6cb8273aa12c6f87a00617d574be31f19ea1ae (patch) | |
tree | a638979024f3e0c284adcbfe0af37f04fa1a0a7b /Master/texmf-dist | |
parent | 25e26e9a00325030747f024cb884bd6d58f4469b (diff) |
l3build (30apr15)
git-svn-id: svn://tug.org/texlive/trunk@37132 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/l3build/l3build.pdf | bin | 520833 -> 548486 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/l3build/l3build.dtx | 146 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/l3build/l3build.lua | 494 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/l3build/regression-test.tex | 14 |
4 files changed, 437 insertions, 217 deletions
diff --git a/Master/texmf-dist/doc/latex/l3build/l3build.pdf b/Master/texmf-dist/doc/latex/l3build/l3build.pdf Binary files differindex 3bd005b79d2..0677673e2e4 100644 --- a/Master/texmf-dist/doc/latex/l3build/l3build.pdf +++ b/Master/texmf-dist/doc/latex/l3build/l3build.pdf diff --git a/Master/texmf-dist/source/latex/l3build/l3build.dtx b/Master/texmf-dist/source/latex/l3build/l3build.dtx index 9ac009cddf5..f3fae6b0e79 100644 --- a/Master/texmf-dist/source/latex/l3build/l3build.dtx +++ b/Master/texmf-dist/source/latex/l3build/l3build.dtx @@ -39,8 +39,8 @@ \RequirePackage{expl3} \def\ExplFileName{l3build} \def\ExplFileDescription{L3 Regression test suite} -\def\ExplFileDate{2015/04/02} -\def\ExplFileVersion{5564} +\def\ExplFileDate{2015/04/30} +\def\ExplFileVersion{5602} \documentclass[full]{l3doc} \renewcommand\partname{Part} \usepackage{multicol,needspace} @@ -92,10 +92,10 @@ \luavarset{tdsdir} {distribdir .. "/tds"} {Generated folder where files are organised for a TDS.} \luavarset{tdsroot} {"latex"}{Root directory of the TDS structure for the bundle/module to be installed into.} \luavarseparator -\luavarset{auxfiles} {\{"*.aux", "*.toc"\}} - {Auxiliary typesetting files that should be auto-removed.} +\luavarset{bibfiles} {\{"*.bst"\}}{\BibTeX{} database files.} \luavarset{binaryfiles} {\{"*.pdf", "*.zip"\}} {Files to be added in binary mode to zip files.} +\luavarset{bstfiles} {\{"*.bst"\}}{\BibTeX{} style files.} \luavarset{checkfiles} {\{~\}}{Extra files unpacked purely for tests} \luavarset{checksuppfiles} { }{Files needed for performing regression tests.} \luavarset{cmdchkfiles} {\{~\}}{Files need to perform command checking (\cls{l3doc}-based documentation only).} @@ -141,6 +141,14 @@ \luavarset{glossarystyle}{"gglo.ist"}{MakeIndex style file for glossary/changes creation} \luavarset{indexstyle} {"gind.ist"}{MakeIndex style for index creation} \luavarseparator +\luavarseparator +\luavarset{biberexe} {"biber"} {Biber executable} +\luavarset{biberopts} {""} {Biber options} +\luavarset{bibtexexe} {"bibtex8"} {\BibTeX{} executable} +\luavarset{bibtexopts} {"-W"} {\BibTeX{} options} +\luavarset{makeindexexe} {"makeindex"}{MakeIndex executable} +\luavarset{makeindexopts}{""} {MakeIndex options} +\luavarseparator \luavarset{checkruns} {1} {How many times to run a check file before comparing the log.} \luavarset{packtdszip} {false} {Build a TDS-style zip file for CTAN?} \luavarset{scriptname} {"build.lua"} {Name of script used in dependencies.} @@ -372,15 +380,18 @@ % The `root' of the TDS structure is defined by \var{tdsroot}, which is \luavar{tdsroot} by default. Plain users would redefine this to |"plain"| (or perhaps |"generic"|), for example. % The build process for a |.tds.zip| file currently assumes a `standard' % structure in which all extracted files should be places inside the |tex| -% tree in a single directory, as shown above. +% tree in a single directory, as shown above. If the module includes any +% \BibTeX{} or MakeIndex styles these will be placed in the appropriate +% subtrees. % % \pagebreak[2] % The |doc| tree is constructed from: % \begin{itemize} -% \item all files matched by \var{demofiles}, and +% \item all files matched by \var{demofiles}, % \item all files matched by \var{typesetfiles} with their extension replaced with |.pdf|, -% \item all files matched by \var{textfiles}, and -% \item all files matched by \var{readmefiles}, but when copied their extension is entirely removed (e.g., |README.markdown| is copied as just |README|). +% \item all files matched by \var{textfiles}, +% \item all files matched by \var{readmefiles}, but when copied their extension is entirely removed (e.g., |README.markdown| is copied as just |README|), and +% \item all files matched by \var{bibfiles}. % \end{itemize} % The |source| tree is constructed from all files matched by \var{typesetfiles} and \var{sourcefiles}. % The |tex| tree from all files matched by \var{installfiles}. @@ -389,8 +400,6 @@ % % Binary files should be specified with the \var{binaryfiles} variable (default \luavar{binaryfiles}); these are added to the zip archive without normalising line endings (text files are automatically converted to Unix-style line endings). % -% Any auxiliary files in the working directory may interfere with the automatic typesetting process. Those listed in \var{auxfiles} are automatically removed to prevent this, and are also deleted by the |clean| operation. (This seetting is most useful when typesetting manually and automatically may use different settings, for example enabling/disabling \pkg{hyperref}.) -% % To create the archive, by default the binary \var{zipexe} is used (\luavar{zipexe}) with options \var{zipopts} (|-v -r -X|). The intermediate build directories \var{ctandir} and \var{tdsdir} are used to construct the archive. % \end{buildcmd} % @@ -573,47 +582,53 @@ % To allow test files to be used between different systems (\emph{e.g.}~when % multiple developers are involved in a project), the log files are normalised % before comparison during checking. This removes some system-dependent -% data but also some variations due to different engines and bugs in some -% versions of some engines. This normalisation consists of two parts: removing -% (\enquote{ignoring}) some lines and modifying others to give consistent -% test. Currently, the following types of line are ignored: +% data but also some variations due to different engines. This normalisation +% consists of two parts: removing (\enquote{ignoring}) some lines and modifying +% others to give consistent test. Currently, the following types of line are +% ignored: % \begin{itemize} % \item Lines before the \cs{START}, after the \cs{END} and within % \cs{OMIT}/\cs{TIMO} blocks % \item Entirely blank lines, including those consisting only of spaces. -% \item Lines containing file dates in the -% \texttt{\meta{yyyy}/\meta{mm}/\meta{dd}} format. +% \item Lines containing file dates in format +% \texttt{\meta{yyyy}/\meta{mm}/\meta{dd}}. % \item Lines starting \cs{openin} or \cs{openout}. -% \item \LuaTeX{}-specific lines in box output for the \cs{local\ldots} -% concepts it introduces when these are set to their defaults. -% \item \LuaTeX{}-specific lines in box output which record -% \cs{discretionary}. % \end{itemize} % Modifications made in lines are: % \begin{itemize} % \item Removal of the name of the test file itself. % \item Removal of the |pdftex.map| load information given during % first page shipout. -% \item Removal spaces at the start of lines (deals with some issues -% with \LuaTeX{} using a different amount of indentation to other engines). +% \item Removal spaces at the start of lines. % \item Removal of |./| at start of file names. % \item Standardisation of the list of units known to \TeX{} (\pdfTeX{} % and \LuaTeX{} add a small number of additional units which are not -% known to \XeTeX{}). +% known to \TeX90 or \XeTeX{}). % \item Standardisation of \verb*|\csname\endcsname | to |\csname\endcsname| % (the former is formally correct, but the latter was produced for many % years due to a \TeX{} bug). % \item Conversion of \texttt{on line \meta{number}} to \texttt{on line ...} % to allow flexibility in changes to test files. -% \item Restriction of glue set in boxes to four decimal places (\LuaTeX{} -% may vary in the last digit from the \pdfTeX{} values). -% \item Removal of the \texttt{display} added by \TeX{} versions other than -% \LuaTeX{} to display math boxes. -% \item Removal of the Omega-like \texttt{direction TLT} added by -% \LuaTeX{} to boxes running in the \enquote{normal} way. -% \item Conversion of low chars ($1$ to $31$) to |^^| notation (\LuaTeX{} -% does not do this). -% \item Correction of a \LuaTeX{} error message typo (|I''m going to assume|). +% \item +% \end{itemize} +% +% \LuaTeX{} makes several additional changes to the log file. As normalising +% these may not be desirable in all cases, they are handled separately. +% When creating \LuaTeX{}-specific test files (either with \LuaTeX{} as +% the standard engine or saving a \LuaTeX{}-specific |.tlg| file) no futher +% normalisation is undertaken. On the other hand, for cross-engine comparision +% the following normalisation is applied: +% \begin{itemize} +% \item Removal of additional (unused) |\discretionary| points. +% \item Removal of |U+...| notation for missing characters. +% \item Removal of |display| for display math boxes +% (included by \TeX90/\pdfTeX{}/\XeTeX). +% \item Removal of Omega-like |direction TLT| information. +% \item Removal of additional whatsit containing local paragraph information +% (|\localinterlinepenalty|, \emph{etc.}). +% \item Rounding of glue set to four decimal places (glue set may be +% slightly different in \LuaTeX{} compared to other engines). +% \item Conversion of low chars ($1$ to $31$) to |^^| notation. % \end{itemize} % % \subsection{Generating test files with \pkg{DocStrip}} @@ -819,8 +834,61 @@ % \label{fig:box-log} % \end{figure} % +% \subsection{Typesetting documentation} +% +% As part of the overall build process, \pkg{l3build} will create PDF +% documentation as described earlier. The standard build process for PDFs +% will attempt to run Biber, \BibTeX{} and MakeIndex as appropriate +% (the exact binaries used are defined by \luavar{biberexe}, \luavar{bibtexexe} +% and \luavar{makeindexexe}). However, there is no attempt to create an entire +% PDF creation system in the style of \texttt{latexmk} or similar. +% +% For package authors who have more complex requirements than those covered +% by the standard set up, the Lua script offers the possibility for +% customisation. The Lua function \texttt{typeset} may be defined before +% reading \texttt{l3build.lua} and should take one argument, the name of +% the file to be typeset. Within this function, the auxiliary Lua +% functions \texttt{biber}, \texttt{bibtex}, \texttt{makeindex} and +% \texttt{tex} can be used, along with custom code, to define a PDF +% typesetting pathway. The functions \texttt{biber} and \texttt{bibtex} +% take a single argument: the name of the file to work with \emph{minus} +% any extension. The \texttt{tex} takes as an arugment the full name +% of the file. The most complex function \texttt{makeindex} requires the +% name, input extension, putput extension, log extension and style name. +% For example, Figure~\ref{fig:PDF} shows a simple script which might +% apply to a case where multiple \BibTeX{} runs are needed (perhaps where +% citations can appear within other references). +% +% \begin{figure}[!b] +% \begin{lstlisting}[frame=single,language={[5.2]Lua},gobble = 6] +% #!/usr/bin/env texlua % +% -- Build script with custom PDF route +% +% module = "mymodule" +% +% function typeset (file) +% local name = string.match (file, "^(.*)%.") or name +% local errorlevel = tex (file) +% if errorlevel == 0 then +% -- Return a non-zero errorlevel if anything goes wrong +% errorlevel = ( +% bibtex (name) + +% tex (file) + +% bibtex (name) + +% tex (file) + +% tex (file) +% ) +% end +% return errorlevel +% end % +% kpse.set_program_name("kpsewhich") +% dofile(kpse.lookup("l3build.lua")) +% \end{lstlisting} +% \caption{A customised PDF creation script.} +% \label{fig:PDF} +% \end{figure} % % \end{documentation} % @@ -841,7 +909,7 @@ % Unlike in the \LaTeXe{} regression test suite, reset catcodes: each test should set these % as appropriate. % \begin{macrocode} -\expandafter\edef\csname\detokenize{reset@catcodes}\endcsname{% +\expandafter\edef\csname reset\string @catcodes\endcsname{% \catcode`\noexpand\@=\the\catcode`\@\relax } \catcode`\@=11 % @@ -940,11 +1008,13 @@ \fi \def\END {% - \ifnum\currentgrouplevel>0 % - \LONGTYPEOUT{Bad grouping: \the\currentgrouplevel!}% - \fi - \ifnum\currentiflevel>1 % - \LONGTYPEOUT{Bad conditionals: \the\numexpr\currentiflevel-1!}% + \ifx\currentiflevel\@undefined\else + \ifnum\currentgrouplevel>0 % + \LONGTYPEOUT{Bad grouping: \the\currentgrouplevel!}% + \fi + \ifnum\currentiflevel>2 % + \LONGTYPEOUT{Bad conditionals: \the\numexpr\currentiflevel-2!}% + \fi \fi \LONGTYPEOUT{END-TEST-LOG}\@@@end } diff --git a/Master/texmf-dist/tex/latex/l3build/l3build.lua b/Master/texmf-dist/tex/latex/l3build/l3build.lua index 1edf777cfa1..dd98915e7a7 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 = "2015/04/02" -release_ver = "5564" +release_date = "2015/04/30" +release_ver = "5602" -- "module" is a deprecated function in Lua 5.2: as we want the name -- for other purposes, and it should eventually be 'free', simply @@ -80,22 +80,23 @@ end -- File types for various operations -- Use Unix-style globs -- All of these may be set earlier, so a initialised conditionally -auxfiles = auxfiles or {"*.aux", "*.toc"} +bibfiles = bibfiles or {"*.bib"} binaryfiles = binaryfiles or {"*.pdf", "*.zip"} -checkfiles = checkfiles or { } -- Extra files unpacked purely for tests +bstfiles = bstfiles or {"*.bst"} +checkfiles = checkfiles or { } checksuppfiles = checksuppfiles or { } cmdchkfiles = cmdchkfiles or { } demofiles = demofiles or { } cleanfiles = cleanfiles or {"*.log", "*.pdf", "*.zip"} -excludefiles = excludefiles or {"*~"} -- Any Emacs stuff +excludefiles = excludefiles or {"*~"} installfiles = installfiles or {"*.sty"} makeindexfiles = makeindexfiles or {"*.ist"} readmefiles = readmefiles or {"README.md", "README.markdown", "README.txt"} -sourcefiles = sourcefiles or {"*.dtx", "*.ins"} -- Files to copy for unpacking +sourcefiles = sourcefiles or {"*.dtx", "*.ins"} textfiles = textfiles or { } typesetfiles = typesetfiles or {"*.dtx"} typesetsuppfiles = typesetsuppfiles or { } -unpackfiles = unpackfiles or {"*.ins"} -- Files to actually unpack +unpackfiles = unpackfiles or {"*.ins"} unpacksuppfiles = unpacksuppfiles or { } -- Roots which should be unpacked to support unpacking/testing/typesetting @@ -136,6 +137,14 @@ end glossarystyle = glossarystyle or "gglo.ist" indexstyle = indexstyle or "gind.ist" +-- Supporting binaries and options +biberexe = biberexe or "biber" +biberopts = biberopts or "" +bibtexexe = bibtexexe or "bibtex8" +bibtexopts = bibtexopts or "-W" +makeindexexe = makeindexexe or "makeindex" +makeindexopts = makeindexopts or "" + -- Other required settings checkruns = checkruns or 1 packtdszip = packtdszip or false -- Not actually needed but clearer @@ -233,6 +242,7 @@ if string.sub (package.config, 1, 1) == "\\" then os_concat = "&" os_diffext = ".fc" os_diffexe = "fc /n" + os_grepexe = "findstr /r" os_null = "nul" os_pathsep = ";" os_setenv = "set" @@ -242,6 +252,7 @@ else os_concat = ";" os_diffext = ".diff" os_diffexe = "diff -c --strip-trailing-cr" + os_grepexe = "grep" os_null = "/dev/null" os_pathsep = ":" os_setenv = "export" @@ -284,9 +295,9 @@ function direxists (dir) errorlevel = os.execute ("[ -d " .. dir .. " ]") end if errorlevel ~= 0 then - return (false) + return false end - return (true) + return true end function fileexists (file) @@ -335,6 +346,29 @@ function mkdir (dir) end end +-- Find the relationship between two directories +function relpath (target, source) + -- A shortcut for the case where the two are the same + if target == source then + return "" + end + local resultdir = "" + local trimpattern = "^[^/]*/" + -- Trim off identical leading directories + while + (string.match (target, trimpattern) or "X") == + (string.match (target, trimpattern) or "Y") do + target = string.gsub (target, trimpattern, "") + source = string.gsub (source, trimpattern, "") + end + -- Go up from the source + for i = 0, select(2, string.gsub (target, "/", "")) do + resultdir = resultdir .. "../" + end + -- Return the relative part plus the unique part of the target + return resultdir .. target +end + -- Rename function ren (dir, source, dest) local dir = dir .. "/" @@ -366,7 +400,7 @@ end -- Run a command in a given directory function run (dir, cmd) local errorlevel = os.execute ("cd " .. dir .. os_concat .. cmd) - return (errorlevel) + return errorlevel end -- Deal with the fact that Windows and Unix use different path separators @@ -389,10 +423,10 @@ function allmodules (target) ) errorlevel = run (i, "texlua " .. scriptname .. " " .. target) if errorlevel > 0 then - return (errorlevel) + return errorlevel end end - return (errorlevel) + return errorlevel end -- Set up the check system files: needed for checking one or more tests and @@ -426,7 +460,9 @@ end -- Copy files to the main CTAN release directory function copyctan () -- Do all of the copying in one go - for _,i in ipairs ({demofiles, pdffiles, sourcefiles, textfiles, typesetlist}) do + for _,i in ipairs ( + {bibfiles, demofiles, pdffiles, sourcefiles, textfiles, typesetlist} + ) do for _,j in ipairs (i) do cp (j, ".", ctandir .. "/" .. ctanpkg) end @@ -468,8 +504,9 @@ function copytds () end end end - install (".", "doc", {demofiles, pdffiles, textfiles, typesetlist}) + install (".", "doc", {bibfiles, demofiles, pdffiles, textfiles, typesetlist}) install (unpackdir, "makeindex", {makeindexfiles}, true) + install (unpackdir, "bibtex/bst", {bstfiles}, true) install (".", "source", {sourcelist}) install (unpackdir, "tex", {installfiles}) end @@ -485,46 +522,26 @@ end -- Convert the raw log file into one for comparison/storage: keeps only -- the 'business' part from the tests and removes system-dependent stuff function formatlog (logfile, newfile) - local function killcheck (line, kill) - local killnext = false - local line = line + local function killcheck (line) -- Skip lines containing file dates if string.match (line, "[^<]%d%d%d%d/%d%d/%d%d") then - line = "" + return true elseif -- Skip \openin/\openout lines in web2c 7.x -- As Lua doesn't allow "(in|out)", a slightly complex approach: -- do a substitution to check the line is exactly what is required! string.match ( - string.gsub (line, "^\\openin", "\\openout"), "^\\openout%d = " - ) - then - line = "" - elseif - -- Various things that only LuaTeX adds to boxes: - -- Remove the 'no-op' versions - string.match (line, "^%.*\\whatsit$") or - string.match (line, "^%.*\\localinterlinepenalty=0$") or - string.match (line, "^%.*\\localbrokenpenalty=0$") or - string.match (line, "^%.*\\localleftbox=null$") or - string.match (line, "^%.*\\localrightbox=null$") then - line = "" - -- Pick up LuaTeX's \discretionary line and remove it and the next - -- line - elseif - string.match (line, "%.+\\discretionary") then - line = "" - killnext = true - elseif kill then - line = "" + string.gsub (line, "^\\openin", "\\openout"), "^\\openout%d%d? = " + ) then + return true end - return line, killnext + return false end -- Substitutions to remove some non-useful changes local function normalize (line) local line = line -- Remove test file name from lines - -- This needs ato extract the base name from the log name, + -- This needs to extract the base name from the log name, -- and one to allow for the case that there might be "-" chars -- in the name (other cases are ignored) line = string.gsub ( @@ -544,61 +561,34 @@ function formatlog (logfile, newfile) end -- Zap map loading on first page output line = string.gsub (line, "%[1{[%w/%-]*/pdftex%.map}%]", "[1]") - -- XeTeX knows only the smaller set of dimension units + -- TeX90/XeTeX knows only the smaller set of dimension units line = string.gsub ( line, "cm, mm, dd, cc, bp, or sp", "cm, mm, dd, cc, nd, nc, bp, or sp" ) - -- Normalise a case where a LuaTeX bug misprints \csname\endcsname - -- This comes before the normalisation of the appearance of - -- \csname\endcsname in case we alter that! - line = string.gsub (line, "\\ycsnam\\rendcsnam", "\\csname\\endcsname") -- Normalise a case where fixing a TeX bug changes the message text line = string.gsub (line, "\\csname\\endcsname ", "\\csname\\endcsname") -- Zap "on line <num>" and replace with "on line ..." line = string.gsub (line, "on line %d*", "on line ...") -- Zap line numbers from \show, \showbox, \box_show and the like - line = string.gsub (line, "^l.%d* (\\[^ ]*show)", "l. ... %1") - -- Remove spaces at the start of lines: deals with the fact that LuaTeX - -- uses a different number to the other engines - line = string.gsub (line, "^%s+", "") - -- LuaTeX can give slightly different glue setting to pdfTeX: - -- handle this by restricting to four decimal places - line = string.gsub ( - line, "glue set (%d+.%d%d%d%d)%dfil", "glue set %1fil" - ) - -- Remove 'display' at end of display math boxes: LuaTeX omits this - line = string.gsub (line, "(\\hbox%(.*), display$", "%1") - -- Remove 'normal' direction information on boxes in LuaTeX: - -- any bidi/vertical stuff will still show - line = string.gsub (line, ", direction TLT", "") - -- LuaTeX displays low chars differently: tidy up to ^^ notation + line = string.gsub (line, "^l%.%d+ ", "l. ...") + -- Tidy up to ^^ notation for i = 1, 31, 1 do line = string.gsub (line, string.char (i), "^^" .. string.char (64 + i)) end - -- For normalising UTF-8 to ASCII - local utf8 = unicode.utf8 + -- Remove spaces at the start of lines: deals with the fact that LuaTeX + -- uses a different number to the other engines + line = string.gsub (line, "^%s+", "") -- Unicode engines display chars in the upper half of the 8-bit range: - -- tidy up to match pdfTeX. + -- tidy up to match pdfTeX + local utf8 = unicode.utf8 for i = 128, 255, 1 do line = string.gsub (line, utf8.char (i), "^^" .. string.format ("%02x", i)) end - -- Minor LuaTeX difference: it does not include parentheses in one message - line = string.gsub ( - line, - "%(If you're confused by all this, try typing `I}' now%.%)", - "If you're confused by all this, try typing `I}' now." - ) - -- Minor LuaTeX bug: it prints an extra "'" in one message: add enough - -- context to hopefully hit only the bug - line = string.gsub ( - line, "I''m going to assume", "I'm going to assume" - ) return line end local newlog = "" local prestart = true local skipping = false - local killnext = false for line in io.lines (logfile) do if line == "START-TEST-LOG" then prestart = false @@ -608,9 +598,8 @@ function formatlog (logfile, newfile) skipping = true elseif line == "TIMO" then skipping = false - elseif not prestart and not skipping then + elseif not prestart and not skipping and not killcheck (line) then line = normalize (line) - line, killnext = killcheck (line, killnext) if not string.match (line, "^ *$") then newlog = newlog .. line .. "\n" end @@ -622,13 +611,92 @@ function formatlog (logfile, newfile) io.close (newfile) end +-- Additional normalization for LuaTeX +function formatlualog (logfile, newfile) + local function normalize (line, lastline, dropping) + local line = line + -- Find discretionary lines skip: may get re-added + if string.match (line, "^%.+\\discretionary$") then + return "", line, false + end + -- Find whatsit lines skip: may get re-added + if string.match (line, "^%.+\\whatsit$") then + return "", line, false + end + -- Remove 'display' at end of display math boxes: + -- LuaTeX omits this as it includes direction in all cases + line = string.gsub (line, "(\\hbox%(.*), display$", "%1") + -- Remove 'normal' direction information on boxes: + -- any bidi/vertical stuff will still show + line = string.gsub (line, ", direction TLT", "") + -- Find glue setting and round out the last place + line = string.gsub ( + line, + "glue set (%-? ?)%d+.%d+fil$", + "glue set %1" .. string.format ( + "%.4f", string.match (line, "glue set %-? ?(%d+.%d+)fil$") or 0 + ) + .. "fil" + ) + -- Remove U+ notation in the "Missing character" message + line = string.gsub ( + line, + "Missing character: There is no (%^%^..) %(U%+(....)%)", + "Missing character: There is no %1" + ) + -- Where the last line was a discretionary, looks for the + -- info one level in about what it represents + if string.match (lastline, "^%.+\\discretionary$") then + prefix = string.gsub (string.match (lastline, "^(%.+)"), "%.", "%%.") + if string.match (line, prefix .. "%.") or + string.match (line, prefix .. "%|") then + return "", lastline, true + else + if dropping then + -- End of a \discretionary block + return line, "", false + else + -- A normal (TeX90) discretionary: + -- add with the line break reintroduced + return lastline .. "\n" .. line, "" + end + end + end + -- Much the same idea when the last line was a whatsit, + -- but things are simpler in this case + if string.match (lastline, "^%.+\\whatsit$") then + prefix = string.gsub (string.match (lastline, "^(%.+)"), "%.", "%%.") + if string.match (line, prefix .. "%.") then + return "", lastline, true + else + -- End of a \whatsit block + return line, "", false + end + end + return line, lastline, false + end + local newlog = "" + local lastline = "" + local dropping = false + for line in io.lines (logfile) do + line, lastline, dropping = normalize (line, lastline, dropping) + if not string.match (line, "^ *$") then + newlog = newlog .. line .. "\n" + end + end + local newfile = io.open (newfile, "w") + io.output (newfile) + io.write (newlog) + io.close (newfile) +end + -- Look for files, directory by directory, and return the first existing function locate (dirs, names) for _,i in ipairs (dirs) do for _,j in ipairs (names) do local path = i .. "/" .. j if fileexists (path) then - return (path) + return path end end end @@ -649,7 +717,7 @@ function listmodules () end end end - return (modules) + return modules end -- Runs a single test: needs the name of the test rather than the .lvt file @@ -678,16 +746,34 @@ function runcheck (name, engine, hide) if os_windows then tlgfile = unix_to_win (tlgfile) end - local errlevel = os.execute ( + local errlevel + -- Do additional log formatting if the engine is LuaTeX, there is no + -- LuaTeX-specific .tlg file and the default engine is not LuaTeX + if i == "luatex" + and tlgfile ~= name .. "." .. i .. tlgext + and stdengine ~= "luatex" then + local luatlgfile = testdir .. "/" .. name .. ".luatex" .. tlgext + if os_windows then + luatlgfile = unix_to_win (luatlgfile) + end + formatlualog (tlgfile, luatlgfile) + formatlualog (newfile, newfile) + errlevel = os.execute ( + os_diffexe .. " " .. luatlgfile .. " " .. newfile + .. " > " .. difffile + ) + else + errlevel = os.execute ( os_diffexe .. " " .. tlgfile .. " " .. newfile .. " > " .. difffile ) + end if errlevel == 0 then os.remove (difffile) else errorlevel = errlevel end end - return (errorlevel) + return errorlevel end -- Run one of the test files: doesn't check the result so suitable for @@ -706,9 +792,11 @@ function runtest (name, engine, hide) end local logfile = testdir .. "/" .. name .. logext local newfile = testdir .. "/" .. name .. "." .. engine .. logext - for i = 1, checkruns, 1 do + for i = 1, checkruns do run ( testdir, + -- No use of localdir here as the files get copied to testdir: + -- avoids any paths in the logs os_setenv .. " TEXINPUTS=." .. (checksearch and os_pathsep or "") .. os_concat .. engine .. format .. " " .. checkopts .. " " .. lvtfile @@ -742,6 +830,120 @@ function testexists (test) return (locate ({testfiledir, unpackdir}, {test .. lvtext})) end +-- +-- Auxiliary functions for typesetting: need to be generally available +-- + +-- An auxiliary used to set up the environmental variables +function runtool (envvar, command) + return ( + run ( + typesetdir, + os_setenv .. " " .. envvar .. "=." .. os_pathsep + .. relpath (localdir, typesetdir) + .. (typesetsearch and os_pathsep or "") .. + os_concat .. + command + ) + ) +end + +function biber (name) + if fileexists (typesetdir .. "/" .. name .. ".bcf") then + return ( + runtool ("BIBINPUTS", biberexe .. " " .. biberopts .. " " .. name) + ) + end + return 0 +end + +function bibtex (name) + if fileexists (typesetdir .. "/" .. name .. ".aux") then + -- LaTeX always generates an .aux file, so there is a need to + -- look inside it for a \citation line + local grep + if os_windows then + grep = "\\\\" + else + grep = "\\\\\\\\" + end + if run ( + typesetdir, + os_grepexe .. " \"^" .. grep .. "citation{\" " .. name .. ".aux > " + .. os_null + ) == 0 then + return ( + -- Cheat slightly as we need to set two variables + runtool ( + "BIBINPUTS", + os_setenv .. " BSTINPUTS=." .. os_pathsep + .. relpath (localdir, typesetdir) + .. (typesetsearch and os_pathsep or "") .. + os_concat .. + bibtexexe .. " " .. bibtexopts .. " " .. name + ) + ) + end + end + return 0 +end + +function makeindex (name, inext, outext, logext, style) + if fileexists (typesetdir .. "/" .. name .. inext) then + return ( + runtool ( + "INDEXSTYLE", + makeindexexe .. " " .. makeindexopts .. " " + .. " -s " .. style .. " -o " .. name .. outext + .. " -t " .. name .. logext .. " " .. name .. inext + ) + ) + end + return 0 +end + +function tex (file) + return ( + runtool ( + "TEXINPUTS", + typesetexe .. " " .. typesetopts .. " \"" .. typesetcmds + .. "\\input " .. file .. "\"" + ) + ) +end + +function typesetpdf (file) + local name = stripext (file) + print ("Typesetting " .. name) + local errorlevel = typeset (file) + if errorlevel == 0 then + os.remove (name .. ".pdf") + cp (name .. ".pdf", typesetdir, ".") + else + print (" ! Compilation failed") + end + return errorlevel +end + +typeset = typeset or function (file) + local errorlevel = tex (file) + if errorlevel ~= 0 then + return errorlevel + else + local name = stripext (file) + -- Return a non-zero errorlevel if something goes wrong + -- without having loads of nested tests + return ( + biber (name) + + bibtex (name) + + makeindex (name, ".glo", ".gls", ".glg", glossarystyle) + + makeindex (name, ".idx", ".ind", ".ilg", indexstyle) + + tex (file) + + tex (file) + ) + end +end + -- Standard versions of the main targets for building modules -- Simply print out how to use the build system @@ -777,7 +979,7 @@ function check (name, engine) else errorlevel = checkall () end - return (errorlevel) + return errorlevel end function checkall () @@ -811,7 +1013,7 @@ function checkall () print ("\n All checks passed\n") end end - return (errorlevel) + return errorlevel end function checklvt (name, engine) @@ -858,12 +1060,6 @@ function clean () end end -function auxclean () - for _,i in ipairs (auxfiles) do - rm (".", i) - end -end - function bundleclean () allmodules ("clean") for _,i in ipairs (cleanfiles) do @@ -879,17 +1075,21 @@ function cmdcheck () cleandir (testdir) depinstall (checkdeps) local engine = string.gsub (stdengine, "tex$", "latex") + local localdir = relpath (localdir, testdir) print ("Checking source files") for _,i in ipairs (cmdchkfiles) do for _,j in ipairs (filelist (".", i)) do print (" " .. stripext (j)) - os.execute ( - os_setenv .. " TEXINPUTS=." .. os_pathsep .. localdir .. - (checksearch and os_pathsep or "") .. os_concat .. - engine .. " " .. cmdchkopts .. " -output-directory=" .. testdir .. - " \"\\PassOptionsToClass{check}{l3doc} \\input " .. j .. "\"" - .. " > " .. os_null - ) + cp (j, ".", testdir) + run ( + testdir, + os_setenv .. " TEXINPUTS=." .. os_pathsep .. localdir + .. os_pathsep .. + os_concat .. + engine .. " " .. cmdchkopts .. + " \"\\PassOptionsToClass{check}{l3doc} \\input " .. j .. "\"" + .. " > " .. os_null + ) for line in io.lines (testdir .. "/" .. stripext (j) .. ".cmds") do if string.match (line, "^%!") then print (" - " .. string.match (line, "^%! (.*)")) @@ -946,7 +1146,7 @@ function ctan (standalone) print ("\n====================") print ("Tests failed, zip stage skipped!") print ("====================\n") - return (errorlevel) + return errorlevel end if errorlevel == 0 then for _,i in ipairs (readmefiles) do @@ -970,7 +1170,7 @@ function ctan (standalone) print ("Typesetting failed, zip stage skipped!") print ("====================\n") end - return (errorlevel) + return errorlevel end function bundlectan () @@ -994,7 +1194,7 @@ function bundlectan () end end end - return (includelist) + return includelist end unpack() local errorlevel = doc () @@ -1005,74 +1205,24 @@ function bundlectan () table.insert (pdffiles, (string.gsub (i, "%.%w+$", ".pdf"))) end typesetlist = excludelist (typesetfiles, {sourcefiles}) - sourcelist = excludelist (sourcefiles, {installfiles, makeindexfiles}) + sourcelist = excludelist ( + sourcefiles, {bstfiles, installfiles, makeindexfiles} + ) copyctan () copytds () end - return (errorlevel) + return errorlevel end -- Typeset all required documents --- This function has several sub-parts, but as most are not needed anywhere --- else everything is done locally within the main function +-- Uses a set of dedicated auxiliaries that need to be available to others function doc () - local function typeset (file) - local name = stripext (file) - -- A couple of short functions to deal with the repeated steps in a - -- clear way - local function biber (name) - if fileexists (typesetdir .. "/" .. name .. ".bcf") then - return (run (typesetdir, "biber " .. name)) - end - end - local function makeindex (name, inext, outext, logext, style) - if fileexists (typesetdir .. "/" .. name .. inext) then - return ( - run ( - typesetdir , - "makeindex -s " .. style .. " -o " .. name .. outext - .. " -t " .. name .. logext .. " " .. name .. inext - ) - ) - end - end - local function typeset (file) - return ( - os.execute ( - os_setenv .. " TEXINPUTS=" .. typesetdir .. - os_pathsep .. localdir .. (typesetsearch and os_pathsep or "") .. - os_concat .. - typesetexe .. " " .. typesetopts .. - " -output-directory=" .. typesetdir .. - " \"" .. typesetcmds .. - "\\input " .. typesetdir .. "/" .. file .. "\"" - ) - ) - end - auxclean () - os.remove (name .. ".pdf") - print ("Typesetting " .. name) - local errorlevel = typeset (file) - if errorlevel ~= 0 then - print (" ! Compilation failed") - return (errorlevel) - else - biber (name) - makeindex (name, ".glo", ".gls", ".glg", glossarystyle) - makeindex (name, ".idx", ".ind", ".ilg", indexstyle) - typeset (file) - typeset (file) - cp (name .. ".pdf", typesetdir, ".") - end - return (errorlevel) - end -- Set up cleandir (typesetdir) - for _,i in ipairs (sourcefiles) do - cp (i, ".", typesetdir) - end - for _,i in ipairs (typesetfiles) do - cp (i, ".", typesetdir) + for _,i in ipairs ({bibfiles, sourcefiles, typesetfiles}) do + for _,j in ipairs (i) do + cp (j, ".", typesetdir) + end end for _,i in ipairs (typesetsuppfiles) do cp (i, supportdir, typesetdir) @@ -1082,9 +1232,9 @@ function doc () -- Main loop for doc creation for _,i in ipairs (typesetfiles) do for _,j in ipairs (filelist (".", i)) do - local errorlevel = typeset (j) + local errorlevel = typesetpdf (j) if errorlevel ~= 0 then - return (errorlevel) + return errorlevel end end end @@ -1155,17 +1305,15 @@ bundleunpack = bundleunpack or function () -- on Unix the "yes" command can't be used inside os.execute (it never -- stops, which confuses Lua) os.execute (os_yes .. ">>" .. localdir .. "/yes") - os.execute ( - -- Notice that os.execute is used from 'here' as this ensures that - -- localdir points to the correct place: running 'inside' - -- unpackdir would avoid the need for setting -output-directory - -- but at the cost of needing to correct the relative position - -- of localdir w.r.t. unpackdir - os_setenv .. " TEXINPUTS=" .. unpackdir .. os_pathsep .. localdir .. - (unpacksearch and os_pathsep or "") .. os_concat .. - unpackexe .. " " .. unpackopts .. " -output-directory=" .. unpackdir - .. " " .. unpackdir .. "/" .. j .. " < " .. localdir .. "/yes" - ) + local localdir = relpath (localdir, unpackdir) + run ( + unpackdir, + os_setenv .. " TEXINPUTS=." .. os_pathsep + .. localdir .. (unpacksearch and os_pathsep or "") .. + os_concat .. + unpackexe .. " " .. unpackopts .. " " .. j .. " < " + .. localdir .. "/yes" + ) end end end diff --git a/Master/texmf-dist/tex/latex/l3build/regression-test.tex b/Master/texmf-dist/tex/latex/l3build/regression-test.tex index 792eac0f1e3..6654067138f 100644 --- a/Master/texmf-dist/tex/latex/l3build/regression-test.tex +++ b/Master/texmf-dist/tex/latex/l3build/regression-test.tex @@ -47,7 +47,7 @@ %% %% ----------------------------------------------------------------------- %% -\expandafter\edef\csname\detokenize{reset@catcodes}\endcsname{% +\expandafter\edef\csname reset\string @catcodes\endcsname{% \catcode`\noexpand\@=\the\catcode`\@\relax } \catcode`\@=11 % @@ -106,11 +106,13 @@ \fi \def\END {% - \ifnum\currentgrouplevel>0 % - \LONGTYPEOUT{Bad grouping: \the\currentgrouplevel!}% - \fi - \ifnum\currentiflevel>1 % - \LONGTYPEOUT{Bad conditionals: \the\numexpr\currentiflevel-1!}% + \ifx\currentiflevel\@undefined\else + \ifnum\currentgrouplevel>0 % + \LONGTYPEOUT{Bad grouping: \the\currentgrouplevel!}% + \fi + \ifnum\currentiflevel>2 % + \LONGTYPEOUT{Bad conditionals: \the\numexpr\currentiflevel-2!}% + \fi \fi \LONGTYPEOUT{END-TEST-LOG}\@@@end } |