texlive[73021] Master: ppmcheckpdf (2dec24)
commits+karl at tug.org
commits+karl at tug.org
Mon Dec 2 22:00:09 CET 2024
Revision: 73021
https://tug.org/svn/texlive?view=revision&revision=73021
Author: karl
Date: 2024-12-02 22:00:09 +0100 (Mon, 02 Dec 2024)
Log Message:
-----------
ppmcheckpdf (2dec24)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/support/ppmcheckpdf/README.txt
trunk/Master/texmf-dist/doc/support/ppmcheckpdf/ppmcheckpdf.pdf
trunk/Master/texmf-dist/doc/support/ppmcheckpdf/ppmcheckpdf.tex
trunk/Master/texmf-dist/scripts/ppmcheckpdf/ppmcheckpdf.lua
trunk/Master/tlpkg/libexec/ctan2tds
Added Paths:
-----------
trunk/Master/texmf-dist/doc/man/man1/ppmcheckpdf.1
trunk/Master/texmf-dist/doc/man/man1/ppmcheckpdf.man1.pdf
Added: trunk/Master/texmf-dist/doc/man/man1/ppmcheckpdf.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/ppmcheckpdf.1 (rev 0)
+++ trunk/Master/texmf-dist/doc/man/man1/ppmcheckpdf.1 2024-12-02 21:00:09 UTC (rev 73021)
@@ -0,0 +1,25 @@
+.TH ppmcheckpdf 1 "2024-12-02" "2024C"
+.SH NAME
+Ppmcheckpdf \- Image-based regression testing for LaTeX packages
+.SH SYNOPSIS
+ppmcheckpdf <action> [<option>]
+.SH DESCRIPTION
+Ppmcheckpdf makes it easy to run image-based regression testing for
+LaTeX packages, from PDF files generated by l3build or other tools.
+.PP
+The most commonly used ppmcheckpdf actions are:
+.IP "check, \-\-check" 6
+Run tests without saving outputs of failed tests
+.IP "save, \-\-save" 6
+Run tests and save outputs of failed tests
+.IP "help, \-\-help" 6
+Print a help message and exit
+.IP "version, \-\-version" 6
+Print version information and exit
+.SH OPTIONS
+Various options apply
+.IP -c 6
+Set the config used for check or save action
+.SH BUGS
+Please log issues on
+https://github.com/lvjr/ppmcheckpdf/issues
Property changes on: trunk/Master/texmf-dist/doc/man/man1/ppmcheckpdf.1
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/man/man1/ppmcheckpdf.man1.pdf
===================================================================
(Binary files differ)
Index: trunk/Master/texmf-dist/doc/man/man1/ppmcheckpdf.man1.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/ppmcheckpdf.man1.pdf 2024-12-02 20:59:12 UTC (rev 73020)
+++ trunk/Master/texmf-dist/doc/man/man1/ppmcheckpdf.man1.pdf 2024-12-02 21:00:09 UTC (rev 73021)
Property changes on: trunk/Master/texmf-dist/doc/man/man1/ppmcheckpdf.man1.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/support/ppmcheckpdf/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/support/ppmcheckpdf/README.txt 2024-12-02 20:59:12 UTC (rev 73020)
+++ trunk/Master/texmf-dist/doc/support/ppmcheckpdf/README.txt 2024-12-02 21:00:09 UTC (rev 73021)
@@ -1,4 +1,4 @@
-Package: Convert PDF to PNG and compare PNG files after l3build
+Package: Image-based regression testing for LaTeX packages
Author: Jianrui Lyu <tolvjr at 163.com>
Repository: https://github.com/lvjr/ppmcheckpdf
License: The LaTeX Project Public License 1.3c
Modified: trunk/Master/texmf-dist/doc/support/ppmcheckpdf/ppmcheckpdf.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/support/ppmcheckpdf/ppmcheckpdf.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/ppmcheckpdf/ppmcheckpdf.tex 2024-12-02 20:59:12 UTC (rev 73020)
+++ trunk/Master/texmf-dist/doc/support/ppmcheckpdf/ppmcheckpdf.tex 2024-12-02 21:00:09 UTC (rev 73021)
@@ -2,7 +2,7 @@
\documentclass[oneside,12pt]{article}
\usepackage[a4paper,margin=2cm]{geometry}
-\newcommand*{\myversion}{2024B}
+\newcommand*{\myversion}{2024C}
\newcommand*{\mydate}{Version \myversion\ (\the\year-\mylpad\month-\mylpad\day)}
\newcommand*{\mylpad}[1]{\ifnum#1<10 0\the#1\else\the#1\fi}
@@ -10,6 +10,8 @@
\setlength{\parskip}{4pt plus 1pt minus 1pt}
\usepackage{codehigh}
+\usepackage{tabularray}
+\UseTblrLibrary{booktabs}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
@@ -27,7 +29,7 @@
\title{\sffamily
\textcolor{green3}{The \texttt{ppmcheckpdf} tool}\\
- {\large Convert PDF to PNG and compare PNG files after \texttt{l3build}}%
+ {\large Image-based regression testing for LaTeX packages}%
}
\author{%
Jianrui Lyu (tolvjr at 163.com)%
@@ -48,11 +50,29 @@
\section{Installation}
-Normally your TeX distribution will copy \myfile{ppmcheckpdf.lua} file to the correct folder
-when you install this tool. If a manual installation is needed, you could download
-\href{https://ctan.org/pkg/ppmcheckpdf}{\myfile{ppmcheckpdf.lua}}
-from CTAN and install it to \myfile{TEXMF/scripts/ppmcheckpdf/ppmcheckpdf.lua}.
+Normally your TeX distribution will copy \mypkg{ppmcheckpdf} files and
+create a binary file \myfile{ppmcheckpdf} when you install this package.
+If a manual installation is needed, you could copy \mypkg{ppmcheckpdf} files to TEXMF tree as follows:
+
+\noindent\begin{tblr}{X[font=\ttfamily]X[2,font=\ttfamily]}
+\toprule
+ Package file & Where to install it \\
+\midrule
+ ppmcheckpdf.1 & TEXMF/doc/man/man1/ppmcheckpdf.1 \\
+ README.txt & TEXMF/doc/support/ppmcheckpdf/README.txt \\
+ ppmcheckpdf.lua & TEXMF/scripts/ppmcheckpdf/ppmcheckpdf.lua \\
+\bottomrule
+\end{tblr}
+
+Then create a symbolic link from \myfile{/usr/local/bin/ppmcheckpdf} to \myfile{path/to/ppmcheckpdf.lua} on Linux or MacOS,
+or create a batch file \myfile{ppmcheckpdf.bat} in binary folder of the TeX distribution with these lines on Windows:
+
+\begin{codehigh}
+ at echo off
+texlua path\to\ppmcheckpdf.lua %*
+\end{codehigh}
+
The \mypkg{ppmcheckpdf} tool uses \myprg{pdftoppm} program for image converting.
This program is installed by default on MiKTeX. For TeX Live, you can install it by running
\begin{codehigh}
@@ -66,28 +86,24 @@
\section{Usages}
-First create a \myfile{buildend.lua} file with the following lines in the folder of your package
-(next to \myfile{build.lua} file for \mypkg{l3build}):
+You could call \myopt{check} action of \mypkg{ppmcheckpdf} with the folllowing commands
\begin{codehigh}
-kpse.set_program_name("kpsewhich")
-dofile(kpse.lookup("ppmcheckpdf.lua"))
-\end{codehigh}
-Then you could run the folllowing commands
-\begin{codehigh}
l3build check
-texlua buildend.lua
+ppmcheckpdf check
\end{codehigh}
The first run of \mypkg{ppmcheckpdf} will save image and md5 files to \myfile{testfiles} folder,
and the subsequent runs of it will compare new md5 values with existing md5 values.
-You could force \mypkg{ppmcheckpdf} to save new image and md5 files to \myfile{testfiles} folder
-by passing \myopt{save} option to it:
+You could force \mypkg{ppmcheckpdf} to save new image and md5 files of failed tests to
+\myfile{testfiles} folder by calling \myopt{save} option of it:
\begin{codehigh}
l3build check
-texlua buildend.lua save
+ppmcheckpdf save
\end{codehigh}
+Both \myopt{check} and \myopt{save} actions accept \myopt{-c} option, which sets the config to used.
+
\section{Customizations}
The \myprg{pdftoppm} program supports several types of image files.
Modified: trunk/Master/texmf-dist/scripts/ppmcheckpdf/ppmcheckpdf.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/ppmcheckpdf/ppmcheckpdf.lua 2024-12-02 20:59:12 UTC (rev 73020)
+++ trunk/Master/texmf-dist/scripts/ppmcheckpdf/ppmcheckpdf.lua 2024-12-02 21:00:09 UTC (rev 73021)
@@ -1,30 +1,25 @@
#!/usr/bin/env texlua
--- Description: Convert PDF to PNG and compare PNG files after l3build
+-- Description: Image-based regression testing for LaTeX packages
-- Copyright: 2024 (c) Jianrui Lyu <tolvjr at 163.com>
-- Repository: https://github.com/lvjr/ppmcheckpdf
-- License: The LaTeX Project Public License 1.3c
-ppmcheckpdf_version = "2024B"
-ppmcheckpdf_date = "2024-01-21"
+local pcp = pcp or {}
+pcp.version = "2024C"
+pcp.date = "2024-12-02"
+
--------------------------------------------
----- source code from l3build.lua
+--> \section{Some code from l3build.lua}
--------------------------------------------
local lfs = require("lfs")
-local assert = assert
-local ipairs = ipairs
-local insert = table.insert
-local lookup = kpse.lookup
-local match = string.match
-local gsub = string.gsub
-
kpse.set_program_name("kpsewhich")
-build_kpse_path = match(lookup("l3build.lua"),"(.*[/])")
+build_kpse_path = string.match(kpse.lookup("l3build.lua"),"(.*[/])")
local function build_require(s)
- require(lookup("l3build-"..s..".lua", { path = build_kpse_path } ) )
+ require(kpse.lookup("l3build-"..s..".lua", { path = build_kpse_path } ) )
end
-----------------------------------------
@@ -36,8 +31,17 @@
build_require("variables")
-imgext = imgext or ".png"
+------------------------------------------------------------
+--> \section{Some variables and functions}
+------------------------------------------------------------
+local assert = assert
+local ipairs = ipairs
+local insert = table.insert
+local remove = table.remove
+local match = string.match
+local gsub = string.gsub
+
local md5 = require("md5")
local function md5sum(str)
@@ -74,6 +78,12 @@
return files
end
+------------------------------------------------------------
+--> \section{Run check or save actions}
+------------------------------------------------------------
+
+imgext = imgext or ".png"
+
local function getimgopt(imgext)
local imgopt = ""
if imgext == ".png" then
@@ -95,17 +105,19 @@
run(path, cmd)
end
-local function saveimgmd5(imgname, md5file, newmd5)
+local function saveImgMd5(dir, imgname, md5file, newmd5)
print("save md5 and image files for " .. imgname)
- cp(imgname, testdir, testfiledir)
+ cp(imgname, dir, testfiledir)
writefile(md5file, newmd5)
end
-local function ppmcheckpdf(job)
+local issave = false
+
+local function checkOnePdf(dir, job)
local errorlevel
local imgname = job .. imgext
local md5file = testfiledir .. "/" .. job .. ".md5"
- local newmd5 = filesum(testdir .. "/" .. imgname)
+ local newmd5 = filesum(dir .. "/" .. imgname)
if fileexists(md5file) then
local oldmd5 = readfile(md5file)
if newmd5 == oldmd5 then
@@ -117,42 +129,43 @@
local imgdiffexe = os.getenv("imgdiffexe")
if imgdiffexe then
local oldimg = abspath(testfiledir) .. "/" .. imgname
- local newimg = abspath(testdir) .. "/" .. imgname
+ local newimg = abspath(dir) .. "/" .. imgname
local diffname = job .. ".diff.png"
local cmd = imgdiffexe .. " " .. oldimg .. " " .. newimg
.. " -compose src " .. diffname
print("creating image diff file " .. diffname)
- run(testdir, cmd)
- elseif arg[1] == "save" then
- saveimgmd5(imgname, md5file, newmd5)
+ run(dir, cmd)
+ elseif issave == true then
+ saveImgMd5(dir, imgname, md5file, newmd5)
end
end
else
errorlevel = 0
- saveimgmd5(imgname, md5file, newmd5)
+ saveImgMd5(dir, imgname, md5file, newmd5)
end
return errorlevel
end
-local function main()
+local function checkOneFolder(dir)
+ print("checking folder " .. dir)
local errorlevel = 0
local pattern = "%" .. pdfext .. "$"
- local files = getfiles(testdir, pattern)
+ local files = getfiles(dir, pattern)
for _, v in ipairs(files) do
- pdftoimg(testdir, v)
+ pdftoimg(dir, v)
pattern = "^" .. jobname(v):gsub("%-", "%%-") .. "%-%d+%" .. imgext .. "$"
- local imgfiles = getfiles(testdir, pattern)
+ local imgfiles = getfiles(dir, pattern)
if #imgfiles == 1 then
local imgname = jobname(v) .. imgext
- if fileexists(testdir .. "/" .. imgname) then
- rm(testdir, imgname)
+ if fileexists(dir .. "/" .. imgname) then
+ rm(dir, imgname)
end
- ren(testdir, imgfiles[1], imgname)
- local e = ppmcheckpdf(jobname(v)) or 0
+ ren(dir, imgfiles[1], imgname)
+ local e = checkOnePdf(dir, jobname(v)) or 0
errorlevel = errorlevel + e
else
for _, i in ipairs(imgfiles) do
- local e = ppmcheckpdf(jobname(i)) or 0
+ local e = checkOnePdf(dir, jobname(i)) or 0
errorlevel = errorlevel + e
end
end
@@ -160,5 +173,97 @@
return errorlevel
end
+local function cfgToDir(cfg)
+ if cfg == "build" then
+ return testdir
+ else
+ return testdir .. "-" .. cfg
+ end
+end
+
+local function checkAllFolders(arglist)
+ if arglist[1] == "-c" then
+ if arglist[2] then
+ return checkOneFolder(cfgToDir(arglist[2]))
+ else
+ print("missing config name for -c option")
+ return 0
+ end
+ else
+ if #checkconfigs == 0 then
+ return checkOneFolder(testdir)
+ else
+ local errorlevel = 0
+ for _, v in ipairs(checkconfigs) do
+ local dir = cfgToDir(v)
+ local e = checkOneFolder(dir) or 0
+ errorlevel = errorlevel + e
+ end
+ return errorlevel
+ end
+ end
+end
+
+------------------------------------------------------------
+--> \section{Print help or version text}
+------------------------------------------------------------
+
+local helptext = [[
+usage: ppmcheckpdf <action> [<options>]
+
+valid actions are:
+ check Run tests without saving outputs of failed tests
+ save Run tests and save outputs of failed tests
+ help Print this message and exit
+ version Print version information and exit
+
+valid options are:
+ -c Set the config used for check or save action
+
+please report bug at https://github.com/lvjr/ppmcheckpdf
+]]
+
+local function help()
+ print(helptext)
+ return 0
+end
+
+local function version()
+ print("Ppmcheckpdf Version " .. pcp.version .. " (" .. pcp.date .. ")\n")
+ return 0
+end
+
+------------------------------------------------------------
+--> \section{Respond to user input}
+------------------------------------------------------------
+
+local function pcpMain(pcparg)
+ if pcparg[1] == nil then return help() end
+ local action = remove(pcparg, 1)
+ -- remove leading dashes
+ action = match(action, "^%-*(.*)$")
+ if action == "check" then
+ return checkAllFolders(pcparg)
+ elseif action == "save" then
+ issave = true
+ return checkAllFolders(pcparg)
+ elseif action == "help" then
+ return help()
+ elseif action == "version" then
+ return version()
+ else
+ print("unknown action '" .. action .. "'\n")
+ return help()
+ end
+end
+
+local function main()
+ return pcpMain(arg)
+end
+
+-- it equals to total number of failed tests
local errorlevel = main()
+
+--print(errorlevel)
+
if os.type == "windows" then os.exit(errorlevel) end
Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds 2024-12-02 20:59:12 UTC (rev 73020)
+++ trunk/Master/tlpkg/libexec/ctan2tds 2024-12-02 21:00:09 UTC (rev 73021)
@@ -4014,6 +4014,7 @@
'pdfjam' => '\.1$',
'pdfxup' => '\.1$',
'pmx' => '\.1$',
+ 'ppmcheckpdf' => '\.1$',
'purifyeps' => 'purifyeps.1',
'rubik' => '\.1$',
'spix' => '\.1$',
More information about the tex-live-commits
mailing list.