A unit test consists of three main files:
- tex file (
test.tex)
, presaved results file (e.g.,test.ss.html
ortest.ss.org
, etc.), andMakefile
Minimal (non-)working example (MWE) test.tex
file.
Would be nice to have metadata:
- author/date of a file
- issue description
- solution description
- bug ID (?)
- etc.
Pre-saved results file, which is compared against build results.
Can be in various formats: html
, xml
, css
, plain text, svg
, binary (png
)
Define rules:
- how to produce results (e.g.,
test.html
file) - how to compare results with pre-saved version (e.g.,
test.html
vstest.ss.html
) - how to make pre-saved version (e.g.,
test.ss.html
)
Common targets:
%.html
- generate results%.diff
- generate diff file%.ss
- presave file
- produce
test.html
; check againsttest.ss.html
.
make check
- pre-save good copy when ready
make save
- remove unnecessary files
make clean
Run in shell:
make test=t-foo new
This will create three files:
./tests/t-foo/Makefile
./tests/t-foo/test.tex
./tests/t-foo/test.ss.html
(empty)
Change directory to ./tests/t-foo/
.
Put your LaTeX/TeX code in test.tex
and amend metadata. Describe your issue.
Put your command line in Makefile
. Default is htlatex $<
.
Run:
make check
It will create test.html
(or other) file(s) and test.diff
file.
When you get correct results, issue command:
make save
which will pre-save your results (e.g., test.ss.html
).
Issue
make clean
to clean up build files.
If you run again:
make check clean
you should get a SUCCESS message.
Leave test.ss.html
file empty, if you are not able to get SUCCESS.
Change directory to a unit test folder ./tests/t-foo/
. Run
make check
To check all tests run
make check
at the top folder.
Your should get a summary report:
(./build/summary.log
)
Summary
*******************
001 SUCCESS (t-172-oolatex-spaces).
002 SUCCESS (t-accents-combined).
003 SUCCESS (t-accents-xelatex).
004 SUCCESS (t-bmatrix).
005 FAILURE (t-hello). See ./build/t-hello/t-hello.diff
006 SUCCESS (t-lettrine).
007 SUCCESS (t-mathml-array).
008 SUCCESS (t-mwbk).
009 SUCCESS (t-scrartcl).
010 SUCCESS (t-scrbook-quoting).
011 SUCCESS (t-suits).
All files from /tests/t-*
are copied to ./build
folder and command make check
is run recursively.
Folders with prefix t-
are active tests.
Folders with prefix xt-
are invalid tests.
There are two template files:
_template.Makefile
_template.tex
Variables: FILE
, TODAY
Dependencies: GNU M4 macro processor.
- GNU make (version 4.1)
- GNU M4 macro processor (version 1.4). Used for Makefile templates
- pandoc (version 2.3.1). For standalone html file generation. see, e.g., t-suits, t-lettrine
- make4ht (version v0.2b)