Skip to content
Merged
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
10 changes: 9 additions & 1 deletion build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ specialformats["latex"] = specialformats["latex"] or
checkengines = {"pdftex", "latexdvips", "latexdvisvgm", "luatex", "xetex"}

-- Use multiple sets of tests
checkconfigs = { "build", "config-gd", "config-manual" }
checkconfigs = {
"build",
"config-gd",
"config-manual",
"config-shell",
}

-- common testing support files
checksuppfiles = {"pgf-regression-test.tex"}

-- For release
ctanzip = "pgf.ctan.flatdir"
Expand Down
7 changes: 7 additions & 0 deletions config-shell.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Tests which require shell escape enabled

testfiledir = "testfiles-shell"
checkopts = "-interaction=nonstopmode -shell-escape"

-- files removed between different engine tests
dynamicfiles = {"*.gnuplot", "*.table"}
5 changes: 5 additions & 0 deletions doc/generic/pgf/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed

- Fix formatting of `default XXX, initially XXX` in key docs #1278
- Correct the fix to trim spaces from `gnuplot` functions #1397 #1399

### Added

- Emulated `runsystem(...)` logging for LuaTeX

## [3.1.11] - 2025-08-14 Henri Menke

Expand Down
51 changes: 51 additions & 0 deletions testfiles-shell/gh1397.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
\documentclass{article}
\input{pgf-regression-test}

\usepackage{tikz}

\begin{document}

\START

\BEGINTEST{no .gnuplot}
\begin{tikzpicture}
\draw[id=normal] plot[domain=-2:2] function {x**2};
\end{tikzpicture}

\SHOWFILE{\jobname.normal.gnuplot}
\ENDTEST

\BEGINTEST{no .gnuplot, leading space in function}
\begin{tikzpicture}
\draw[id=leading-space] plot[domain=-2:2] function { x**2};
\end{tikzpicture}

\SHOWFILE{\jobname.leading-space.gnuplot}
\ENDTEST

\BEGINTEST{no .gnuplot, trailing space in function}
\begin{tikzpicture}
\draw[id=trailing-space] plot[domain=-2:2] function {x**2 };
\end{tikzpicture}

\SHOWFILE{\jobname.trailing-space.gnuplot}
\ENDTEST

\BEGINTEST{.gnuplot existing and matched}
\begin{tikzpicture}
\draw[id=normal] plot[domain=-2:2] function {x**2};
\draw[id=leading-space] plot[domain=-2:2] function { x**2};
\draw[id=trailing-space] plot[domain=-2:2] function {x**2 };
\end{tikzpicture}
\ENDTEST

\BEGINTEST{.gnuplot existing but outdated}
\begin{tikzpicture}
% use the existing id but a different domain
\draw[id=normal] plot[domain=-4:4] function {x**2};
\end{tikzpicture}

\SHOWFILE{\jobname.normal.gnuplot}
\ENDTEST

\END
42 changes: 42 additions & 0 deletions testfiles-shell/gh1397.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
============================================================
TEST 1: no .gnuplot
============================================================
runsystem(gnuplot gh1397.normal.gnuplot)...executed.
-------- gh1397.normal.gnuplot (start) ---------
(gh1397.normal.gnuplot) set table "gh1397.normal.table"; set format "%.5f"[nl]
set samples 25; plot [x=-2:2] x**2[nl]
-------- gh1397.normal.gnuplot (end) -----------
============================================================
============================================================
TEST 2: no .gnuplot, leading space in function
============================================================
runsystem(gnuplot gh1397.leading-space.gnuplot)...executed.
-------- gh1397.leading-space.gnuplot (start) ---------
(gh1397.leading-space.gnuplot) set table "gh1397.leading-space.table"; set format "%.5f"[nl]
set samples 25; plot [x=-2:2] x**2[nl]
-------- gh1397.leading-space.gnuplot (end) -----------
============================================================
============================================================
TEST 3: no .gnuplot, trailing space in function
============================================================
runsystem(gnuplot gh1397.trailing-space.gnuplot)...executed.
-------- gh1397.trailing-space.gnuplot (start) ---------
(gh1397.trailing-space.gnuplot) set table "gh1397.trailing-space.table"; set format "%.5f"[nl]
set samples 25; plot [x=-2:2] x**2[nl]
-------- gh1397.trailing-space.gnuplot (end) -----------
============================================================
============================================================
TEST 4: .gnuplot existing and matched
============================================================
============================================================
============================================================
TEST 5: .gnuplot existing but outdated
============================================================
runsystem(gnuplot gh1397.normal.gnuplot)...executed.
-------- gh1397.normal.gnuplot (start) ---------
(gh1397.normal.gnuplot) set table "gh1397.normal.table"; set format "%.5f"[nl]
set samples 25; plot [x=-4:4] x**2[nl]
-------- gh1397.normal.gnuplot (end) -----------
============================================================
2 changes: 1 addition & 1 deletion tex/generic/pgf/modules/pgfmoduleplot.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@
\pgfutilpreparefilename{#1.table}%
\let\pgf@plottablefile=\pgfretval
\let\pgf@plottablefile@quoted=\pgfretvalquoted
\edef\pgf@plot@code{\pgfutil@trimspaces@e{#2}}%
\begingroup
\endlinechar=-1 % suppress white space at end
% Check, whether it is up-to-date
Expand All @@ -490,7 +491,6 @@
\pgfutil@read\pgfutil@inputcheck to\pgf@temp% ignored
\pgfutil@read\pgfutil@inputcheck to\pgf@plot@line%
\closein\pgfutil@inputcheck
\edef\pgf@plot@code{\pgfutil@trimspaces@e{#2}}%
\ifx\pgf@plot@code\pgf@plot@line%
\openin\pgfutil@inputcheck=\pgfretval\relax
\ifeof\pgfutil@inputcheck%
Expand Down
17 changes: 15 additions & 2 deletions tex/generic/pgf/utilities/pgfutil-common.tex
Original file line number Diff line number Diff line change
Expand Up @@ -883,9 +883,22 @@
\def\pgfutil@luaescapestring#1{}
\fi


% Emulate the "runsystem(...)" logging for LuaTeX
% based on the emulation in l3kernel (l3sys.dtx, @@_shell_now:e), and the
% ending periods are added following https://github.com/latex3/latex2e/commit/90d53de44fe4a09baa4a17506abe6ce9e120a7c3.
\def\pgfutil@shellescape@lua@eightseven#1{%
\pgfutil@directlua{os.execute("\pgfutil@luaescapestring{#1}")}%
\pgfutil@directlua{%
local write_nl = texio.write_nl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will only ever call texio.write_nl once, so we don't gain anything from the local binding, but you can leave it. Just wanted to point that out.

local cmd = "\pgfutil@luaescapestring{#1}"
local status, msg = os.execute(cmd)
if status == nil then
write_nl("log", "runsystem(" .. cmd .. ")...(" .. msg .. ").\string\n")
elseif status == 0 then
write_nl("log", "runsystem(" .. cmd .. ")...executed.\string\n")
else
write_nl("log", "runsystem(" .. cmd .. ")...failed. " .. (msg or "") .. "\string\n")
end
}%
}%
\def\pgfutil@shellescape#1{%
\immediate\write18{#1}%
Expand Down
Loading