From 4f1882007dc25adb049a10b75d300e7097f574bb Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 4 Mar 2025 23:49:34 +0300 Subject: [PATCH 1/5] feat(typst): Add regression testing mechanism for Typst --- Makefile.am | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 3da4d65..2bddf04 100644 --- a/Makefile.am +++ b/Makefile.am @@ -85,6 +85,8 @@ sile/readme_%.sil: sile/README.md $(CODEBLOCK_FILTER) TYPSTASSETS = typst/decasify.wasm typst/readme_1.svg typst/readme_2.svg typst/LICENSE +TYPST_EXPECTATIONS = tests/styled.html + .PHONY: typst-universe typst-universe: $(TYPSTASSETS) @@ -111,6 +113,9 @@ typst/decasify.wasm: typst/src/lib.rs $(TYPST) compile -f svg $< $@ $(SVGO) --multipass --precision 2 --pretty --indent 2 $@ +%.html: %.typ typst-universe + $(TYPST) compile --root $(top_srcdir) --features html --format html $< + SILEASSETS = sile/readme_1.svg sile/readme_2.svg .PHONY: sile-docs @@ -129,9 +134,9 @@ sile-docs: $(SILEASSETS) $(SVGO) --multipass --precision 2 --pretty --indent 2 $@ $(SED) -i -e '/\/defs/a ' $@ -check: busted pytest +check: busted pytest typst-test -PHONY_DEVELOPER_TARGETS = rockspecs srcrocks rocks install-luarock busted pytest release-preview +PHONY_DEVELOPER_TARGETS = rockspecs srcrocks rocks install-luarock busted pytest typst-test release-preview .PHONY: $(PHONY_DEVELOPER_TARGETS) if DEVELOPER_MODE @@ -172,6 +177,9 @@ pytest: $(MATURIN) develop env PYTHONPATH=.venv/lib/python3.12/site-packages/decasify $(PYTEST) +typst-test: $(TYPST_EXPECTATIONS) + $(GIT) diff-files --quiet -- $^ + define rockpec_template = $(SED) -e "s/@""PACKAGE_NAME""@/$(PACKAGE_NAME)/g" \ -e "s/@""SEMVER""@/$(SEMVER)/g" \ From fb4a32f5d0b83e00fd2e96693560d9909c383883 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 4 Mar 2025 23:49:34 +0300 Subject: [PATCH 2/5] test(typst): Add test for preservation of styled output --- tests/styled.html | 37 +++++++++++++++++++++++++++++++++++++ tests/styled.typ | 23 +++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 tests/styled.html create mode 100644 tests/styled.typ diff --git a/tests/styled.html b/tests/styled.html new file mode 100644 index 0000000..3e8aed7 --- /dev/null +++ b/tests/styled.html @@ -0,0 +1,37 @@ + + + + + + + + + + + + +
Sourcethis sample has bold and italic underlined bits.
+

Sentencecase

+ + + + + + + + + +
ActualThis sample has bold and italic underlined bits.
ExpectedThis sample has bold and italic underlined bits.
+

Titlecase

+ + + + + + + + + +
ActualThis Sample Has Bold and Italic Underlined Bits.
ExpectedThis Sample Has Bold and Italic Underlined Bits.
+ + diff --git a/tests/styled.typ b/tests/styled.typ new file mode 100644 index 0000000..1780347 --- /dev/null +++ b/tests/styled.typ @@ -0,0 +1,23 @@ +#import "../typst/decasify.typ": sentencecase, titlecase + +#set text(lang: "en") + +#let sample = [this sample *has bold* and _italic #underline[underlined]_ bits.] + +#table(columns: (2cm, 9cm))[Source][#sample] + += Sentencecase + +#table(columns: (2cm, 9cm))[Actual][ + #sentencecase[#sample] +][Expected][ + This sample *has bold* and _italic #underline[underlined]_ bits. +] + += Titlecase + +#table(columns: (2cm, 9cm))[Actual][ + #titlecase[#sample] +][Expected][ + This Sample *Has Bold* and _Italic #underline[Underlined]_ Bits. +] From 3a825f0ed1e8fc03dbabd832efb4b91d94425bc5 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 5 Mar 2025 00:17:35 +0300 Subject: [PATCH 3/5] feat(sile): Add regression testing mechanism for SILE --- Makefile.am | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2bddf04..b58723e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -118,6 +118,8 @@ typst/decasify.wasm: typst/src/lib.rs SILEASSETS = sile/readme_1.svg sile/readme_2.svg +SILE_EXPECTATIONS = tests/styled.txt + .PHONY: sile-docs sile-docs: $(SILEASSETS) @@ -127,16 +129,22 @@ sile-docs: $(SILEASSETS) %.pdf: %.sil cp $< target/ cd target - $(SILE) $(' $@ -check: busted pytest typst-test +%.txt: %.sil sile-docs + cp $< target/ + cd target + $(SILE) -b debug -o ../$@ $( Date: Wed, 5 Mar 2025 00:12:39 +0300 Subject: [PATCH 4/5] test(sile): Add test for preservation of nested content --- tests/styled.sil | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/styled.sil diff --git a/tests/styled.sil b/tests/styled.sil new file mode 100644 index 0000000..b5c5047 --- /dev/null +++ b/tests/styled.sil @@ -0,0 +1,18 @@ +\begin{document} +\nofolios +\neverindent +\language[main=en] +\use[module=packages.rules] +\use[module=packages.decasify] +\define[command=sample]{this sample \strong{has bold} and \em{italic \underline{underlined}} bits.} +\define[command=group]{\bigskip\font[size=16pt,weight=800]{\process}\par} + +\sample + +\group{Sentencecase} +\decasify[case=sentence]{this sample \strong{has bold} and \em{italic \underline{underlined}} bits.} + +\group{Titlecase} +\decasify[case=title]{this sample \strong{has bold} and \em{italic \underline{underlined}} bits.} + +\end{document} From 1e6627af350b50232e25da6e52611f26fb4abaaf Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 5 Mar 2025 13:38:38 +0300 Subject: [PATCH 5/5] feat(tooling): Setup test drivers for typesetting tests --- Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.am b/Makefile.am index b58723e..ddd401b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -142,6 +142,8 @@ sile-docs: $(SILEASSETS) $(SILE) -b debug -o ../$@ $(