Skip to content

Commit

Permalink
Test support for -output-directory option of TeX engines in test.py
Browse files Browse the repository at this point in the history
The onlz exception is ConTeXt MkIV, which only supports the `--result`
option, which behaves differently.
  • Loading branch information
Witiko committed Jul 13, 2024
1 parent cfa795e commit 430884a
Show file tree
Hide file tree
Showing 177 changed files with 411 additions and 370 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ARG DEPENDENCIES="\
poppler-utils \
python3-pygments \
python3-venv \
rename \
retry \
unzip \
wget \
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ EXAMPLES=examples/context-mkiv.pdf \
examples/latex-tex4ht.html examples/latex-tex4ht.css \
examples/optex.pdf
TESTS=tests/test.sh tests/test.py tests/requirements.txt tests/support/*.tex \
tests/templates/*/*/head.tex tests/templates/*/*/body.tex.m4 \
tests/templates/*/*/foot.tex tests/templates/*/COMMANDS.m4 tests/testfiles/*/*/*.test
tests/templates/*/*/head.tex.m4 tests/templates/*/*/body.tex.m4 \
tests/templates/*/*/foot.tex.m4 tests/templates/*/COMMANDS.m4 tests/testfiles/*/*/*.test
MAKES=Makefile $(addsuffix /Makefile, $(SUBDIRECTORIES)) latexmkrc
ROOT_README=README.md markdown.png
READMES=$(ROOT_README) LICENSE examples/README.md tests/README.md \
Expand Down
10 changes: 5 additions & 5 deletions tests/support/keyval-setup.tex
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@
lineBlock(Begin|End) = {%
\TYPE{#0}},
inputVerbatim = {%
\TYPE{#0: #1}},
\TYPE{#0: \NORMALIZEPATH{#1}}},
inputFencedCode = {%
\TYPE{BEGIN fencedCode}%
\TYPE{- src: #1}%
\TYPE{- src: \NORMALIZEPATH{#1}}%
\TYPE{- infostring: #3}%
\TYPE{END fencedCode}},
heading* = {%
Expand All @@ -144,7 +144,7 @@
inlineHtml(Comment|Tag) = {%
\TYPE{#0: #1}},
inputBlockHtmlElement = {%
\TYPE{#0: #1}},
\TYPE{#0: \NORMALIZEPATH{#1}}},
(ticked|halfTicked|unticked)Box = {%
\TYPE{#0}},
jekyllData(Boolean|Number|String) = {%
Expand Down Expand Up @@ -173,12 +173,12 @@
\TYPE{#0: #1}},
inputRawInline = {%
\TYPE{BEGIN rawInline}%
\TYPE{- src: #1}%
\TYPE{- src: \NORMALIZEPATH{#1}}%
\TYPE{- raw attribute: #2}%
\TYPE{END rawInline}},
inputRawBlock = {%
\TYPE{BEGIN rawBlock}%
\TYPE{- src: #1}%
\TYPE{- src: \NORMALIZEPATH{#1}}%
\TYPE{- raw attribute: #2}%
\TYPE{END rawBlock}},
replacementCharacter = {%
Expand Down
20 changes: 20 additions & 0 deletions tests/support/setup.tex
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,23 @@
\CITATIONSCOUNTER=1%
\def\CITATIONSTOTAL{#2}%
\DOCITATIONS{#1}}%

% Normalize pathnames by stripping all but the last fragment.
\ExplSyntaxOn
\cs_new:Npn
\NORMALIZEPATH
#1
{
\DONORMALIZEPATH
#1 / /
}
\cs_new:Npn
\DONORMALIZEPATH
#1 / #2 /
{
\tl_if_empty:nTF
{ #2 }
{ #1 }
{ \DONORMALIZEPATH #2 / }
}
\ExplSyntaxOff
16 changes: 9 additions & 7 deletions tests/templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ This directory contains subdirectories, which correspond to individual TeX
formats. These subdirectories contain subdirectories with TeX source code
templates and a file named `COMMANDS.m4`.

The TeX source code templates contain three documents: `head.tex`,
`body.tex.m4`, and `foot.m4`. First, the file `body.tex.m4` is preprocessed by
The TeX source code templates contain three documents: `head.tex.m4`,
`body.tex.m4`, and `foot.tex.m4`. First, these files are preprocessed by
the m4 macro preprocessor with the following macro definitions:

1. `TEST_SETUP_FILENAME` corresponds to the name of the file containing the
test setup TeX source code.
2. `TEST_INPUT_FILENAME` corresponds to the name of the file containing the
test markdown source code.
1. `OUTPUT_DIRECTORY` corresponds to the name of the TeX output directory.
2. `TEST_SETUP_FILENAME` corresponds to the name of the file containing the
test setup TeX source code. This macro is only available in `body.tex.m4`.
3. `TEST_INPUT_FILENAME` corresponds to the name of the file containing the
test markdown source code. This macro is only available in `body.tex.m4`.

Then, the file `head.tex`, the preprocessing results of `body.tex.m4`, and the
file `foot.tex` are concatenated. Finally, the concatenation result is typeset.
Expand All @@ -18,5 +19,6 @@ The `COMMANDS.m4` file contains a newline-separated list of commands that will
be used to typeset the pre-processed TeX source code templates. Before use,
the commands will preprocessed with the following macro definitions:

1. `TEST_FILENAME` corresponds to the name of the pre-processed TeX source
1. `OUTPUT_DIRECTORY` corresponds to the name of the TeX output directory.
2. `TEST_FILENAME` corresponds to the name of the pre-processed TeX source
code template that is being typeset.
2 changes: 1 addition & 1 deletion tests/templates/context-mkiv/COMMANDS.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
context --once --luatex --nonstopmode TEST_FILENAME
context --result=OUTPUT_DIRECTORY`___'TEST_BASENAME --once --luatex --nonstopmode TEST_FILENAME && rename 's/___/\//' OUTPUT_DIRECTORY`___'TEST_BASENAME*
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/templates/latex/COMMANDS.m4
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pdflatex --shell-escape --interaction=nonstopmode TEST_FILENAME
lualatex --interaction=nonstopmode TEST_FILENAME
pdflatex -shell-escape -output-directory OUTPUT_DIRECTORY -interaction=nonstopmode TEST_FILENAME
lualatex -output-directory OUTPUT_DIRECTORY -interaction=nonstopmode TEST_FILENAME
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

% Load the support files.
\markdownSetup{
outputDir = OUTPUT_DIRECTORY,
import = {
witiko/markdown/test = snippet as testSnippet,
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

% Load the support files.
\markdownSetup{
outputDir = OUTPUT_DIRECTORY,
import = {
witiko/markdown/test = snippet as testSnippet,
}
Expand Down
4 changes: 2 additions & 2 deletions tests/templates/plain/COMMANDS.m4
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pdftex --shell-escape --interaction=nonstopmode TEST_FILENAME
luatex --interaction=nonstopmode TEST_FILENAME
pdftex -shell-escape -output-directory OUTPUT_DIRECTORY -interaction=nonstopmode TEST_FILENAME
luatex -output-directory OUTPUT_DIRECTORY -interaction=nonstopmode TEST_FILENAME
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

% Load the support files.
\markdownSetup{
outputDir = OUTPUT_DIRECTORY,
import = {
witiko/markdown/test = snippet as testSnippet,
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

% Load the support files.
\markdownSetup{
outputDir = OUTPUT_DIRECTORY,
import = {
witiko/markdown/test = snippet as testSnippet,
}
Expand Down
Loading

0 comments on commit 430884a

Please sign in to comment.