[latex3-commits] [git/l3build] master: Fully enable multiple configs (edef5fb)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Dec 12 10:05:33 CET 2017


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

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

commit edef5fbcb62173ece6b3ddb4d0d8e267139dec1a
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Dec 7 09:18:58 2017 +0000

    Fully enable multiple configs
    
    This now allows mixed directories, etc. For example, one might use one
    testfiledir to have searching off for pdfTeX but on for XeTeX/LuaTeX.


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

edef5fbcb62173ece6b3ddb4d0d8e267139dec1a
 build.lua                              |    1 +
 l3build.dtx                            |   44 ++++++++++++++++++++++++++++++++
 l3build.lua                            |   25 ++++++++++++++++++
 plain.lua                              |    2 ++
 testfiles-plain/plain-pdftex.tlg       |    8 +++---
 testfiles-plain/plain-pdftex.xetex.tlg |   17 ++++++++++++
 6 files changed, 93 insertions(+), 4 deletions(-)

diff --git a/build.lua b/build.lua
index 75fa81d..844f24c 100644
--- a/build.lua
+++ b/build.lua
@@ -7,6 +7,7 @@ module = "l3build"
 bundle = ""
 
 -- Non-standard settings
+checkconfigs = {"build", "plain"}
 checkdeps    = { }
 checkengines = {"pdftex", "xetex", "luatex", "ptex", "uptex"}
 cleanfiles   = {"*.pdf", "*.tex", "*.zip"}
diff --git a/l3build.dtx b/l3build.dtx
index a9dc905..5e3add6 100644
--- a/l3build.dtx
+++ b/l3build.dtx
@@ -114,6 +114,9 @@
 \luavarset{stdengine}    {"pdftex"}{Engine to generate \texttt{.tlg} file from}
 \luavarset{checkformat}  {"latex"} {Format to use for tests}
 \luavarseparator
+\luavarset{checkconfigs}{\{\}}{Configurations to use for tests}
+\luavarset{stdconfig}   {\meta{Main script}}{Standard test configuration}
+\luavarseparator
 \luavarset{typesetexe}{"pdflatex"}{Executable for compiling \texttt{doc(s)}}
 \luavarset{unpackexe} {"tex"}     {Executable for running \texttt{unpack}}
 \luavarset{zipexe}    {"zip"}     {Executable for creating archive with \texttt{ctan}}
@@ -306,6 +309,7 @@
 %
 % As well as these commands, the system recognises the options
 % \begin{itemize}
+%   \item \texttt{--config} (\texttt{-c}) Configuration(s) to use for testing
 % \item \texttt{--date} (\texttt{-d}) Date to use when setting version
 %   data
 % \item \texttt{--engine} (\texttt{-e}) Sets the engine to use for
@@ -617,6 +621,46 @@
 %
 % \luavartypeset
 %
+% \subsection{Multiple sets of tests}
+%
+% In most cases, a single set of tests will be appropriate for the module, with
+% a common set of configuration settings applying. However, there are
+% situations where you may need entirely independent sets of tests which have
+% different setting values, for example using different formats or where the
+% entire set will be engine-dependent. To support this, \pkg{l3build} offers
+% the possibility of using multiple configurations for tests. This is supported
+% using the \var{checkconfigs} table. This is used to list the names of each
+% configuration (|.lua| file) which will be used to run tests.
+%
+% For example, for the core \LaTeXe{} tests the main test files are contained 
+% in a directory |testfiles|. To test font loading for \XeTeX{} and \LuaTeX{}
+% there are a second set of tests in |testfiles-TU| which use the short
+% |build-TU.lua| file shown in Figure~\ref{fig:configs}. To run both sets of
+% tests, the main |build.lua| file contains the setting
+% |checkconfigs = {"build", "build-TU"}|. This will cause \pkg{l3build} to run
+% first using no additional settings (\emph{i.e.}~reading the normal
+% |build.lua| file alone), then running \emph{also} loading the settings from
+% |build-TU.lua|.
+% \begin{figure} 
+%   \begin{lstlisting}[frame=single,language={[5.2]Lua},gobble = 6] 
+%     -- Special config for these tests 
+%     checksearch  = true
+%     checkengines = {"xetex","luatex"}
+%     testfiledir  = "testfiles-TU"
+%   \end{lstlisting} 
+% \caption{The build script for the \pkg{xparse} module.} 
+% \label{fig:configs} 
+% \end{figure} 
+%
+% To allow selection of a one or more configurations, and to allow saving of
+% |.tlg| files in non-standard configurations, the |--config| (|-c|) option may
+% be used. This works in the same way as |--engine|: it takes a comma list of
+% configurations to apply, overriding \var{checkconfigs}.
+%
+% Note that the setting \var{stdconfig} is used to determine the \emph{vanilla}
+% configuration: this will typically be the name of the main script (usually
+% |build| for a standard |build.lua| file).
+%
 % \subsection{Dependencies}
 %
 % If you have multiple packages that are developed separately but still interact in some way, it's often desirable to integrate them when performing regression tests.
diff --git a/l3build.lua b/l3build.lua
index b359035..f748f39 100644
--- a/l3build.lua
+++ b/l3build.lua
@@ -139,6 +139,10 @@ checkengines = checkengines or {"pdftex", "xetex", "luatex"}
 checkformat  = checkformat  or "latex"
 stdengine    = stdengine    or "pdftex"
 
+-- Configs for testing
+checkconfigs = checkconfigs or { }
+stdconfig    = stdconfig    or string.gsub(arg[0], "%.lua$", "")
+
 -- Enable access to trees outside of the repo
 -- As these may be set false, a more elaborate test than normal is needed
 if checksearch == nil then
@@ -2528,5 +2532,26 @@ end
 -- Allow main function to be disabled 'higher up'
 main = main or stdmain
 
+-- Deal with multiple configs for tests
+checkconfigs = options["config"] or checkconfigs
+if options["target"] == "check" then
+  if #checkconfigs > 1 then
+    local errorlevel = 0
+    local opts = options
+    for i = 1, #checkconfigs do
+      opts["config"] = {checkconfigs[i]}
+      errorlevel = call({"."}, "check", opts)
+      if errorlevel ~= 0 then exit(1) end
+    end
+    -- Avoid running the 'main' set of tests twice
+    exit(0)
+  end
+end
+if #checkconfigs == 1 and
+   checkconfigs[1] ~= stdconfig and
+   (options["target"] == "check" or options["target"] == "save") then
+   dofile("./" .. checkconfigs[1] .. ".lua")
+end
+
 -- Call the main function
 main(options["target"], options["files"])
diff --git a/plain.lua b/plain.lua
new file mode 100644
index 0000000..b59b2c1
--- /dev/null
+++ b/plain.lua
@@ -0,0 +1,2 @@
+checkformat = "tex"
+testfiledir = "testfiles-plain"
\ No newline at end of file
diff --git a/testfiles-plain/plain-pdftex.tlg b/testfiles-plain/plain-pdftex.tlg
index f09433e..eaffdfd 100644
--- a/testfiles-plain/plain-pdftex.tlg
+++ b/testfiles-plain/plain-pdftex.tlg
@@ -1,4 +1,4 @@
-This is a generated file for the LaTeX (2e + expl3) validation system.
+This is a generated file for the l3build validation system.
 Don't change this file in any respect.
 ============================================================
 CFG FILE IS LOADED
@@ -8,10 +8,10 @@ TEST 1: \afterassignment
 ============================================================
 > hello.
 <argument> ...d}}\foo } \x ={hello} \showthe \foo 
-\show \y 
-l.19 }
+                                                  \show \y 
+l. ...}
 > \y=macro:
 ->world.
 <argument> ... \x ={hello} \showthe \foo \show \y 
-l.19 }
+l. ...}
 ============================================================
diff --git a/testfiles-plain/plain-pdftex.xetex.tlg b/testfiles-plain/plain-pdftex.xetex.tlg
new file mode 100644
index 0000000..eaffdfd
--- /dev/null
+++ b/testfiles-plain/plain-pdftex.xetex.tlg
@@ -0,0 +1,17 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+============================================================
+CFG FILE IS LOADED
+============================================================
+============================================================
+TEST 1: \afterassignment 
+============================================================
+> hello.
+<argument> ...d}}\foo } \x ={hello} \showthe \foo 
+                                                  \show \y 
+l. ...}
+> \y=macro:
+->world.
+<argument> ... \x ={hello} \showthe \foo \show \y 
+l. ...}
+============================================================





More information about the latex3-commits mailing list