diff --git a/.gitignore b/.gitignore index 9052f2b..079c59d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ template/*.pdf + +tests/ \ No newline at end of file diff --git a/test-regression.sh b/test-regression.sh new file mode 100755 index 0000000..51f1e15 --- /dev/null +++ b/test-regression.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Clean up previous test results +if [ -d "tests/original-res" ]; then + rm -r tests/original-res +fi +if [ -d "tests/modified-res" ]; then + rm -r tests/modified-res +fi +if [ -d "tests/modified" ]; then + rm -r tests/modified +fi +if [ -d "tests/original/src" ]; then + rm -r tests/original/src +fi + +mkdir -p tests/original-res +mkdir -p tests/modified-res + +# Copy current template +cp -r src/ tests/original/src + +cp -r tests/original tests/modified +# replace the "#import "@local/ktu-paper:0.1.0"" +# with "#import "./src/lib.typ"" in the modified files +find tests/modified -type f -name "*.typ" -exec \ + sed -i 's/#import "@local\/ktu-paper:0.1.0"/#import ".\/src\/lib.typ"/g' {} \; +find tests/modified -type f -name "ataskaita.typ" -exec \ + sed -i 's/setup-page/ktu-paper/g' {} \; + +# Compile the original document +typst compile --root tests/original tests/original/ataskaita.typ "tests/original-res/{0p}.png" +# Compile the modified document +typst compile --root tests/modified tests/modified/ataskaita.typ "tests/modified-res/{0p}.png" +typst compile --root tests/modified tests/modified/ataskaita.typ "tests/modified.pdf" + +# Compare the results +diff -r tests/original-res tests/modified-res +if [ $? -eq 0 ]; then + echo "No differences found between original and modified results." +else + echo "Differences found between original and modified results." +fi