diff --git a/build.lua b/build.lua index 3d2e0ca93..9daaba0a8 100644 --- a/build.lua +++ b/build.lua @@ -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" diff --git a/config-shell.lua b/config-shell.lua new file mode 100644 index 000000000..f22092edd --- /dev/null +++ b/config-shell.lua @@ -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"} diff --git a/doc/generic/pgf/CHANGELOG.md b/doc/generic/pgf/CHANGELOG.md index 3eabe0278..f32fcb720 100644 --- a/doc/generic/pgf/CHANGELOG.md +++ b/doc/generic/pgf/CHANGELOG.md @@ -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 diff --git a/testfiles/support/pgf-regression-test.tex b/support/pgf-regression-test.tex similarity index 100% rename from testfiles/support/pgf-regression-test.tex rename to support/pgf-regression-test.tex diff --git a/testfiles-shell/gh1397.lvt b/testfiles-shell/gh1397.lvt new file mode 100644 index 000000000..f4b6768bb --- /dev/null +++ b/testfiles-shell/gh1397.lvt @@ -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 diff --git a/testfiles-shell/gh1397.tlg b/testfiles-shell/gh1397.tlg new file mode 100644 index 000000000..11a2b8f7b --- /dev/null +++ b/testfiles-shell/gh1397.tlg @@ -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) ----------- +============================================================ diff --git a/tex/generic/pgf/modules/pgfmoduleplot.code.tex b/tex/generic/pgf/modules/pgfmoduleplot.code.tex index 4dbaa14f0..1b070a89a 100644 --- a/tex/generic/pgf/modules/pgfmoduleplot.code.tex +++ b/tex/generic/pgf/modules/pgfmoduleplot.code.tex @@ -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 @@ -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% diff --git a/tex/generic/pgf/utilities/pgfutil-common.tex b/tex/generic/pgf/utilities/pgfutil-common.tex index 66c6fd015..c12cf5d32 100644 --- a/tex/generic/pgf/utilities/pgfutil-common.tex +++ b/tex/generic/pgf/utilities/pgfutil-common.tex @@ -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 + 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}%