Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate testsuite from pgfmanual #1116

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion doc/generic/pgf/extract.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ local function walk(sourcedir, targetdir)

-- Process all items in the directory
for file in lfs.dir(sourcedir) do

if file == "." or file == ".." then
-- Ignore these two special ones
elseif lfs.attributes(sourcedir .. file, "mode") == "directory" then
Expand All @@ -113,8 +114,12 @@ local function walk(sourcedir, targetdir)
-- extract all code examples
local matches = extractor:match(text) or {}

-- write code examples to separate files
-- storage
local setup_code = ""
local preamble = ""
local document = ""

-- write code examples to separate files
for n, e in ipairs(matches) do
local options = e[1]
local content = e[2]
Expand All @@ -133,6 +138,7 @@ local function walk(sourcedir, targetdir)
-- Skip those that say "code only" or "setup code"
if not options["code only"] and not options["setup code"] then
local newname = name .. "-" .. n .. ".tex"
--[[
local examplefile = io.open(targetdir .. newname, "w")

examplefile:write"\\documentclass{standalone}\n"
Expand All @@ -153,10 +159,47 @@ local function walk(sourcedir, targetdir)
examplefile:write"\\end{document}\n"

examplefile:close()
--]]
preamble = preamble .. (options["preamble"] and (options["preamble"] .. "\n") or "")
document = document .. "\\BEGINBOXTEST{" .. name .. "-" .. n .. "}\n"
local pre = options["pre"]
if pre then
pre = pre:gsub("##", "#")
document = document .. pre .. "\n"
end
if options["render instead"] then
document = document .. options["render instead"] .. "\n"
else
document = document .. strip(content) .. "\n"
end
document = document .. (options["post"] and (options["post"] .. "\n") or "")
document = document .. "\\ENDBOXTEST\n\n"
end

::continue::
end

document = strip(document)
if document ~= "" then
local examplefile = io.open(targetdir .. name .. ".lvt", "w")
examplefile:write"\\documentclass{minimal}\n"
examplefile:write"\\input{pgf-regression-test}\n"
examplefile:write"\\RequirePackage{fp,pgf,tikz,xcolor}\n"
if preamble ~= "" then
examplefile:write"\n"
examplefile:write(preamble)
examplefile:write"\n"
end
examplefile:write"\\begin{document}\n\n"
if setup_code ~= "" then
examplefile:write(setup_code)
examplefile:write"\n"
end
examplefile:write(document)
examplefile:write"\n"
examplefile:write"\\END\n"
examplefile:close()
end
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions testfiles/pgf001.latexdvips.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ TEST 1: pgf: \pgfpathmoveto
...\special{ps::[end]}
...\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDPGFTEST ...th =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDPGFTEST
============================================================
Expand Down Expand Up @@ -54,7 +54,7 @@ TEST 2: pgf: \pgfpathlineto
...\special{ps::[end]}
...\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDPGFTEST ...th =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDPGFTEST
============================================================
4 changes: 2 additions & 2 deletions testfiles/pgf001.latexdvisvgm.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TEST 1: pgf: \pgfpathmoveto
....\special{color pop}
....\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDPGFTEST ...th =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDPGFTEST
============================================================
Expand Down Expand Up @@ -56,7 +56,7 @@ TEST 2: pgf: \pgfpathlineto
....\special{color pop}
....\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDPGFTEST ...th =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDPGFTEST
============================================================
4 changes: 2 additions & 2 deletions testfiles/pgf001.luatex.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TEST 1: pgf: \pgfpathmoveto
...\pdfliteral origin{Q }
...\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDPGFTEST ...th =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDPGFTEST
============================================================
Expand All @@ -46,7 +46,7 @@ TEST 2: pgf: \pgfpathlineto
...\pdfliteral origin{Q }
...\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDPGFTEST ...th =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDPGFTEST
============================================================
4 changes: 2 additions & 2 deletions testfiles/pgf001.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TEST 1: pgf: \pgfpathmoveto
...\pdfliteral{Q }
...\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDPGFTEST ...th =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDPGFTEST
============================================================
Expand All @@ -46,7 +46,7 @@ TEST 2: pgf: \pgfpathlineto
...\pdfliteral{Q }
...\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDPGFTEST ...th =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDPGFTEST
============================================================
4 changes: 2 additions & 2 deletions testfiles/pgf001.xetex.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TEST 1: pgf: \pgfpathmoveto
...\special{pdf:econtent}
...\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDPGFTEST ...th =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDPGFTEST
============================================================
Expand All @@ -50,7 +50,7 @@ TEST 2: pgf: \pgfpathlineto
...\special{pdf:econtent}
...\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDPGFTEST ...th =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDPGFTEST
============================================================
2 changes: 1 addition & 1 deletion testfiles/pgf002.latexdvips.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ TEST 1: tikz: matrix
...\special{ps::[end]}
...\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDTIKZTEST ...h =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDTIKZTEST
============================================================
2 changes: 1 addition & 1 deletion testfiles/pgf002.latexdvisvgm.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ TEST 1: tikz: matrix
....\special{color pop}
....\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDTIKZTEST ...h =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDTIKZTEST
============================================================
2 changes: 1 addition & 1 deletion testfiles/pgf002.luatex.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ TEST 1: tikz: matrix
...\pdfliteral origin{Q }
...\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDTIKZTEST ...h =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDTIKZTEST
============================================================
2 changes: 1 addition & 1 deletion testfiles/pgf002.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ TEST 1: tikz: matrix
...\pdfliteral{Q }
...\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDTIKZTEST ...h =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDTIKZTEST
============================================================
2 changes: 1 addition & 1 deletion testfiles/pgf002.xetex.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ TEST 1: tikz: matrix
...\special{pdf:econtent}
...\glue 0.0 plus 1.0fil minus 1.0fil
! OK.
\ENDTIKZTEST ...h =\maxdimen \showbox \PGFTESTBOX
\ENDBOXTEST ...th =\maxdimen \showbox \PGFTESTBOX
\endgroup \ENDTEST
l. ...\ENDTIKZTEST
============================================================
179 changes: 179 additions & 0 deletions testfiles/pgfmanual-en-base-actions.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
\documentclass{minimal}
\input{pgf-regression-test}
\RequirePackage{fp,pgf,tikz,xcolor}

\usepgflibrary{arrows.meta}
\usepgflibrary{arrows.meta}
\usepgflibrary{arrows.meta}
\usepgflibrary{arrows.meta}

\begin{document}

\BEGINBOXTEST{pgfmanual-en-base-actions-1}
\begin{pgfpicture}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{1cm}{1cm}}
\pgfpathlineto{\pgfpoint{1cm}{0cm}}
\pgfusepath{fill}
\end{pgfpicture}
\ENDBOXTEST

\BEGINBOXTEST{pgfmanual-en-base-actions-2}
\begin{pgfpicture}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{1cm}{1cm}}
\pgfpathlineto{\pgfpoint{1cm}{0cm}}
\pgfusepath{stroke}
\end{pgfpicture}
\ENDBOXTEST

\BEGINBOXTEST{pgfmanual-en-base-actions-3}
\begin{pgfpicture}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{1cm}{1cm}}
\pgfpathlineto{\pgfpoint{1cm}{0cm}}
\pgfusepath{stroke,clip}
\pgfpathcircle{\pgfpoint{1cm}{1cm}}{0.5cm}
\pgfusepath{fill}
\end{pgfpicture}
\ENDBOXTEST

\BEGINBOXTEST{pgfmanual-en-base-actions-4}
\begin{pgfpicture}
\pgfsetlinewidth{1mm}
\pgfpathmoveto{\pgfpoint{0mm}{0mm}}
\pgfpathlineto{\pgfpoint{2cm}{0mm}}
\pgfusepath{stroke}
\pgfsetlinewidth{2\pgflinewidth} % double in size
\pgfpathmoveto{\pgfpoint{0mm}{5mm}}
\pgfpathlineto{\pgfpoint{2cm}{5mm}}
\pgfusepath{stroke}
\end{pgfpicture}
\ENDBOXTEST

\BEGINBOXTEST{pgfmanual-en-base-actions-5}
\begin{pgfpicture}
\pgfsetdash{{0.5cm}{0.5cm}{0.1cm}{0.2cm}}{0cm}
\pgfpathmoveto{\pgfpoint{0mm}{0mm}}
\pgfpathlineto{\pgfpoint{2cm}{0mm}}
\pgfusepath{stroke}
\pgfsetdash{{0.5cm}{0.5cm}{0.1cm}{0.2cm}}{0.1cm}
\pgfpathmoveto{\pgfpoint{0mm}{1mm}}
\pgfpathlineto{\pgfpoint{2cm}{1mm}}
\pgfusepath{stroke}
\pgfsetdash{{0.5cm}{0.5cm}{0.1cm}{0.2cm}}{0.2cm}
\pgfpathmoveto{\pgfpoint{0mm}{2mm}}
\pgfpathlineto{\pgfpoint{2cm}{2mm}}
\pgfusepath{stroke}
\end{pgfpicture}
\ENDBOXTEST

\BEGINBOXTEST{pgfmanual-en-base-actions-6}
\begin{pgfpicture}
\pgfsetlinewidth{1pt}
\color{red}
\pgfpathcircle{\pgfpoint{0cm}{0cm}}{3mm} \pgfusepath{fill,stroke}
\pgfsetstrokecolor{black}
\pgfpathcircle{\pgfpoint{1cm}{0cm}}{3mm} \pgfusepath{fill,stroke}
\color{red}
\pgfpathcircle{\pgfpoint{2cm}{0cm}}{3mm} \pgfusepath{fill,stroke}
\end{pgfpicture}
\ENDBOXTEST

\BEGINBOXTEST{pgfmanual-en-base-actions-7}
\begin{pgfpicture}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{1cm}{1cm}}
\pgfpathlineto{\pgfpoint{1cm}{0cm}}
\pgfsetlinewidth{2pt}
\pgfsetinnerlinewidth{1pt}
\pgfusepath{stroke}
\end{pgfpicture}
\ENDBOXTEST

\BEGINBOXTEST{pgfmanual-en-base-actions-8}
\begin{pgfpicture}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{1cm}{1cm}}
\pgfpathlineto{\pgfpoint{1cm}{0cm}}
\pgfsetlinewidth{2pt}
\pgfsetinnerlinewidth{1pt}
\pgfsetinnerstrokecolor{red!50}
\pgfusepath{stroke}
\end{pgfpicture}
\ENDBOXTEST

\BEGINBOXTEST{pgfmanual-en-base-actions-9}
\begin{pgfpicture}
\pgfsetarrowsstart{Latex[length=10pt]}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{1cm}{0cm}}
\pgfusepath{stroke}
\pgfsetarrowsstart{Computer Modern Rightarrow}
\pgfpathmoveto{\pgfpoint{0cm}{2mm}}
\pgfpathlineto{\pgfpoint{1cm}{2mm}}
\pgfusepath{stroke}
\end{pgfpicture}
\ENDBOXTEST

\BEGINBOXTEST{pgfmanual-en-base-actions-10}
\begin{pgfpicture}
\pgfsetarrowsstart{Latex[length=10pt]}
\pgfsetarrowsend{Computer Modern Rightarrow}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{1cm}{0cm}}
\pgfusepath{stroke}
\end{pgfpicture}
\ENDBOXTEST

\BEGINBOXTEST{pgfmanual-en-base-actions-11}
\begin{pgfpicture}
\pgfsetarrows{Latex[length=10pt]->>}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{1cm}{0cm}}
\pgfusepath{stroke}
\end{pgfpicture}
\ENDBOXTEST

\BEGINBOXTEST{pgfmanual-en-base-actions-12}
\begin{pgfpicture}
\pgfpathcircle{\pgfpointorigin}{5mm}
\pgfusepath{stroke}
\pgfsetarrows{Latex-}
\pgfsetshortenstart{4pt}
\pgfpathmoveto{\pgfpoint{5mm}{0cm}} % would be on the circle
\pgfpathlineto{\pgfpoint{2cm}{0cm}}
\pgfusepath{stroke}
\end{pgfpicture}
\ENDBOXTEST

\BEGINBOXTEST{pgfmanual-en-base-actions-13}
\begin{pgfpicture}
\pgfseteorule
\pgfpathcircle{\pgfpoint{0mm}{0cm}}{7mm}
\pgfpathcircle{\pgfpoint{5mm}{0cm}}{7mm}
\pgfusepath{fill}
\end{pgfpicture}
\ENDBOXTEST

\BEGINBOXTEST{pgfmanual-en-base-actions-14}
\begin{pgfpicture}
\pgfsetnonzerorule
\pgfpathcircle{\pgfpoint{0mm}{0cm}}{7mm}
\pgfpathcircle{\pgfpoint{5mm}{0cm}}{7mm}
\pgfusepath{fill}
\end{pgfpicture}
\ENDBOXTEST

\BEGINBOXTEST{pgfmanual-en-base-actions-15}
Left
\begin{pgfpicture}
\pgfpathrectangle{\pgfpointorigin}{\pgfpoint{2ex}{1ex}}
\pgfusepath{use as bounding box} % draws nothing

\pgfpathcircle{\pgfpointorigin}{2ex}
\pgfusepath{stroke}
\end{pgfpicture}
right.
\ENDBOXTEST
\END
Loading