From 7811a2cc0cf5dd6850d2da5c5a3ea2f3b5f240a5 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 2 Dec 2022 23:37:32 +0300 Subject: [PATCH 1/7] ci(actions): Add special workflow to get coverage --- .github/workflows/coverage.yml | 77 ++++++++++++++++++++++++++++++++++ Makefile.am | 5 ++- 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000000..4dbce0403d --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,77 @@ +name: Coverage + +on: [ push, pull_request ] + +# Coverage slows down tests *a lot*. +# Also most of our regression tests use a dummy back end. +# Here we use LuaJIT for speed and use the real backend. + +jobs: + + coverage: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Cache test fonts + uses: actions/cache@v3 + with: + path: | + .fonts + .sources + key: fonts-${{ hashFiles('Makefile-fonts') }} + - name: Cache lua_modules + uses: actions/cache@v3 + with: + path: | + lua_modules + key: luarocks-luajit-${{ hashFiles('Makefile-luarocks', 'sile-dev-1.rockspec') }} + - name: Fetch tags + run: | + git fetch --prune --tags ||: + - name: Setup ‘lua’ + uses: leafo/gh-actions-lua@v9 + with: + luaVersion: luajit + luaCompileFlags: XCFLAGS=-fPIC + - name: Setup ‘luarocks’ + uses: leafo/gh-actions-luarocks@v4 + - name: Prep system Lua for use + run: | + luarocks install busted + luarocks install luacov-coveralls + function deepest () { find $1 -type d | awk 'length>m{m=length;r=$0}END{print r}'; } + cat << EOF >> $GITHUB_ENV + LD_LIBRARY_PATH=$PWD/.lua/lib:$LD_LIBRARY_PATH + LIBRARY_PATH=$PWD/.lua/lib:$LIBRARY_PATH + LD_RUN_PATH=$PWD/.lua/lib:$LD_RUN_PATH + PKG_CONFIG_PATH=$PWD/.lua/lib/pkgconfig:$PKG_CONFIG_PATH + LUA_INCLUDE=-I$(deepest $PWD/.lua/include) + MAKEFLAGS=-j$(nproc) -Otarget + EOF + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install fonts-sil-gentiumplus libarchive-tools libfontconfig1-dev libharfbuzz-dev libicu-dev libpng-dev poppler-utils + - name: Configure + run: | + ./bootstrap.sh + ./configure \ + --enable-developer LUACHECK=false \ + --without-system-luarocks \ + --with-luajit \ + --without-manual + - name: Make + run: | + make + - name: Run all testing with coverage + run: | + make coverage + - name: Report test coverage + if: success() + continue-on-error: true + run: luacov-coveralls -i sile -e .luarocks + env: + COVERALLS_REPO_TOKEN: ${{ github.token }} diff --git a/Makefile.am b/Makefile.am index d030d865d4..8ddc7dd19f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -127,7 +127,7 @@ DEPDIR := .deps REGRESSIONSCRIPT := ./tests/regressions.pl LOCALTESTFONTS := FONTCONFIG_FILE=$(PWD)/fontconfig.conf SILEFLAGS ?= -m $(DEPDIR)/$(basename $@).d -d versions -f fontconfig -BUSTEDFLAGS ?= +BUSTEDFLAGS ?= $(and $(SILE_COVERAGE),-c) TESTPDFS = $(addsuffix .pdf,$(basename $(TESTSRCS))) EXPECTEDS ?= $(filter $(addsuffix .expected,$(basename $(TESTSRCS))),$(TESTEXPECTS)) @@ -221,7 +221,8 @@ endif $(LOCALTESTFONTS) $(BUSTED) --cpath="$${packagecpath[*]};;" --lpath="$${packagepath[*]};;" $(BUSTEDFLAGS) . coverage: export SILE_COVERAGE=1 -coverage: regression_previews busted +coverage: BUSTEDFLAGS = -c +coverage: regression_previews busted docs HEADSHA ?= HEAD _HEADSHA ?= $(shell test -e .git && $(GIT) rev-parse --short=7 $(HEADSHA)) From c3aad018b6a41bbfee9b3378f5a20671eb5bb71a Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 3 Dec 2022 16:32:23 +0300 Subject: [PATCH 2/7] chore(tooling): Exclude manual from coverage tests Building the manual as a test is great, but it isn't the same as running specific unit, regression, or integration tests. Lets not count hits only from the manual build as part of the test coverage. We *should* eventually have unit tests that cover everything. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 8ddc7dd19f..e3cedc7b46 100644 --- a/Makefile.am +++ b/Makefile.am @@ -222,7 +222,7 @@ endif coverage: export SILE_COVERAGE=1 coverage: BUSTEDFLAGS = -c -coverage: regression_previews busted docs +coverage: regression_previews busted HEADSHA ?= HEAD _HEADSHA ?= $(shell test -e .git && $(GIT) rev-parse --short=7 $(HEADSHA)) From 5d31fd47be3128f5fedb61adbd8107dccd9635bf Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 6 Dec 2022 21:05:26 +0300 Subject: [PATCH 3/7] test(inputters): Make use of more flexible parser and link bugs --- tests/049EPH.xml | 3 ++- tests/balanced.sil | 3 ++- tests/bug-214.sil | 3 ++- tests/bug-248.sil | 3 ++- tests/bug-307.sil | 3 ++- tests/bug-342.sil | 3 ++- tests/color-fonts.sil | 3 ++- tests/footnotes-twocols.sil | 3 ++- tests/frametricks.sil | 3 ++- tests/process-commands.sil | 3 ++- tests/space-after-command.sil | 3 ++- tests/sura-2.sil | 3 ++- 12 files changed, 24 insertions(+), 12 deletions(-) diff --git a/tests/049EPH.xml b/tests/049EPH.xml index 20ee148805..54d6bce165 100644 --- a/tests/049EPH.xml +++ b/tests/049EPH.xml @@ -1,4 +1,5 @@ - + + diff --git a/tests/balanced.sil b/tests/balanced.sil index e98732ff2e..88bc7e9fa7 100644 --- a/tests/balanced.sil +++ b/tests/balanced.sil @@ -1,4 +1,5 @@ -\begin[papersize=a5]{document}% KNOWNBAD +% KNOWNBAD +\begin[papersize=a5]{document} \nofolios \use[module=packages.lorem] \use[module=packages.grid] diff --git a/tests/bug-214.sil b/tests/bug-214.sil index 347a82a21d..4e193aaed2 100644 --- a/tests/bug-214.sil +++ b/tests/bug-214.sil @@ -1,4 +1,5 @@ -\begin[papersize=a7,class=book]{document} % KNOWNBAD +% KNOWNBAD https://github.com/sile-typesetter/sile/issues/214 +\begin[papersize=a7,class=book]{document} \nofolios % We are testing that the footnote's top skip (separator) gets retained % and that the main content doesn't overflow its frame. diff --git a/tests/bug-248.sil b/tests/bug-248.sil index f3906e52bf..593e2fe23d 100644 --- a/tests/bug-248.sil +++ b/tests/bug-248.sil @@ -1,4 +1,5 @@ -\begin[papersize=a6]{document}% KNOWNBAD +% KNOWNBAD https://github.com/sile-typesetter/sile/issues/248 +\begin[papersize=a6]{document} % The breakage here is so bad that it it produces an infinite loop when % using the libtexpdf backend (i.e. `make regression_previews`) and hence when % trying to get code coverage reports. It works (although not as expected) diff --git a/tests/bug-307.sil b/tests/bug-307.sil index 11a6230f68..3cac0f61ad 100644 --- a/tests/bug-307.sil +++ b/tests/bug-307.sil @@ -1,4 +1,5 @@ -\begin[papersize=a5]{document}% KNOWNBAD +% KNOWNBAD https://github.com/sile-typesetter/sile/issues/307 +\begin[papersize=a5]{document} \nofolios \set[parameter=document.parindent,value=0] \set[parameter=document.parskip,value=1ex] diff --git a/tests/bug-342.sil b/tests/bug-342.sil index ffae2d8ca5..0d1d2b74e7 100644 --- a/tests/bug-342.sil +++ b/tests/bug-342.sil @@ -1,4 +1,5 @@ -\begin[papersize=a5,class=book]{document}% KNOWNBAD +% KNOWNBAD https://github.com/sile-typesetter/sile/issues/342 +\begin[papersize=a5,class=book]{document} \use[module=packages.ifattop] \use[module=packages.lorem] \nofolios diff --git a/tests/color-fonts.sil b/tests/color-fonts.sil index 9ad86f6400..d5726604c9 100644 --- a/tests/color-fonts.sil +++ b/tests/color-fonts.sil @@ -1,4 +1,5 @@ -\begin[class=book,papersize=129mm x 198mm]{document}% KNOWNBAD +% KNOWNBAD https://github.com/sile-typesetter/sile/issues/1261 +\begin[class=book,papersize=129mm x 198mm]{document} \use[module=packages.color-fonts] \bidi-on \font[filename=tests/TestCLR-Regular.ttf] diff --git a/tests/footnotes-twocols.sil b/tests/footnotes-twocols.sil index e877e52b34..f2011ac227 100644 --- a/tests/footnotes-twocols.sil +++ b/tests/footnotes-twocols.sil @@ -1,4 +1,5 @@ -\begin[papersize=a5,class=testtwocol]{document}% KNOWNBAD +% KNOWNBAD +\begin[papersize=a5,class=testtwocol]{document} \use[module=packages.lorem] \set[parameter=document.baselineskip,value=15pt plus 2pt] \font[size=13pt] diff --git a/tests/frametricks.sil b/tests/frametricks.sil index 969f193e36..9415b10eb1 100644 --- a/tests/frametricks.sil +++ b/tests/frametricks.sil @@ -1,4 +1,5 @@ -\begin[papersize=129mm x 198mm]{document}% KNOWNBAD https://github.com/sile-typesetter/sile/issues/740 +% KNOWNBAD https://github.com/sile-typesetter/sile/issues/740 +\begin[papersize=129mm x 198mm]{document} \use[module=packages.frametricks] \makecolumns[columns=2] \font[size=15pt] diff --git a/tests/process-commands.sil b/tests/process-commands.sil index f2824d6b07..eb129ab545 100644 --- a/tests/process-commands.sil +++ b/tests/process-commands.sil @@ -1,4 +1,5 @@ -\begin[papersize=a5]{document}% KNOWNBAD +% KNOWNBAD https://github.com/sile-typesetter/sile/issues/105 +\begin[papersize=a5]{document} \use[module=packages.lorem] \pagetemplate[first-content-frame=a]{ \frame[id=a,top=5%ph,bottom=95%ph,next=b,left=5%pw,right=50%pw] diff --git a/tests/space-after-command.sil b/tests/space-after-command.sil index b08604748c..142a998786 100644 --- a/tests/space-after-command.sil +++ b/tests/space-after-command.sil @@ -1,4 +1,5 @@ -\begin[papersize=a5]{document}% KNOWNBAD +% KNOWNBAD https://github.com/sile-typesetter/sile/issues/105 +\begin[papersize=a5]{document} % Test leading comment and package lines \use[module=packages.color] diff --git a/tests/sura-2.sil b/tests/sura-2.sil index 100d411a73..610a27aac8 100644 --- a/tests/sura-2.sil +++ b/tests/sura-2.sil @@ -1,4 +1,5 @@ -\begin[papersize=a6,direction=RTL]{document}% KNOWNBAD +% KNOWNBAD https://github.com/sile-typesetter/sile/issues/192 +\begin[papersize=a6,direction=RTL]{document} \nofolios \font[family=Amiri Quran,size=20pt] \use[module=packages.linespacing] From 93c424adff91e6d35dc7500817bcdfd96a324506 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 6 Dec 2022 21:39:50 +0300 Subject: [PATCH 4/7] chore(tooling): Make sure build-time tooling (find) is configurable --- build-aux/{list-dist-files.sh => list-dist-files.sh.in} | 2 +- configure.ac | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) rename build-aux/{list-dist-files.sh => list-dist-files.sh.in} (92%) diff --git a/build-aux/list-dist-files.sh b/build-aux/list-dist-files.sh.in similarity index 92% rename from build-aux/list-dist-files.sh rename to build-aux/list-dist-files.sh.in index bdb0e48188..6cbdc47307 100755 --- a/build-aux/list-dist-files.sh +++ b/build-aux/list-dist-files.sh.in @@ -3,7 +3,7 @@ set -e finder () { test -d "$1" || return 0 - find "$@" -type f | sort -bdi | xargs printf ' %s' + @FIND@ "$@" -type f | sort -bdi | xargs printf ' %s' } printf '%s' "SILEDATA =" diff --git a/configure.ac b/configure.ac index 1a0955d58b..bb229e8bad 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,7 @@ AC_PROG_SED AX_PROGVAR([cmp]) AX_PROGVAR([git]) +AX_PROGVAR([find]) LT_PREREQ([2.2]) LT_INIT([dlopen]) @@ -213,6 +214,7 @@ AC_SUBST([SILE_LIB_PATH]) AX_SUBST_MAN_DATE +AC_CONFIG_FILES([build-aux/list-dist-files.sh], [chmod +x build-aux/list-dist-files.sh]) AC_CONFIG_FILES([Makefile src/Makefile sile.1 core/version.lua]) AC_CONFIG_FILES([sile tests/regressions.pl], [chmod +x sile tests/regressions.pl]) From 8d96e642480dde9409b67d12902583b5b4dffe3d Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 3 Dec 2022 16:36:55 +0300 Subject: [PATCH 5/7] chore(tooling): Limit test previews to known-good tests --- Makefile.am | 2 +- build-aux/list-dist-files.sh.in | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index e3cedc7b46..fe7b36ab37 100644 --- a/Makefile.am +++ b/Makefile.am @@ -254,7 +254,7 @@ tests/%.expected: tests/%.xml $$(patterndeps) tests/%.expected: tests/%.nil $$(patterndeps) $(LOCALTESTFONTS) ./$(SILE) $(SILEFLAGS) -b debug $< -o $@ -regression_previews: $(TESTPDFS) +regression_previews: $(TESTPREVIEWS) tests/%.actual: tests/%.sil $$(patterndeps) -$(if $(CLEAN),rm -f $@,:) diff --git a/build-aux/list-dist-files.sh.in b/build-aux/list-dist-files.sh.in index 6cbdc47307..eaf29ee66b 100755 --- a/build-aux/list-dist-files.sh.in +++ b/build-aux/list-dist-files.sh.in @@ -22,6 +22,17 @@ finder tests -maxdepth 1 -name '*.xml' finder tests -maxdepth 1 -name '*.lua' finder tests -maxdepth 1 -name '*.nil' +printf '\n%s' "TESTPREVIEWS ?=" +{ +finder tests -maxdepth 1 -name '*.sil' +finder tests -maxdepth 1 -name '*.xml' +finder tests -maxdepth 1 -name '*.lua' +finder tests -maxdepth 1 -name '*.nil' +} | + xargs @GREP@ -L KNOWNBAD | + @SED@ 's/\....$/.pdf/' | + xargs printf ' %s' + printf '\n%s' "BUSTEDSPECS ?=" finder . -maxdepth 1 -name '*_spec.lua' From 354a3ff98a902139a7dff82c7c30a48760a561ff Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 6 Dec 2022 22:39:41 +0300 Subject: [PATCH 6/7] fix(inputters): Correct Lua inputter AST expectations to match others --- inputters/lua.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/inputters/lua.lua b/inputters/lua.lua index 5e88f0440b..0c5d49dd26 100644 --- a/inputters/lua.lua +++ b/inputters/lua.lua @@ -32,7 +32,6 @@ function inputter:process (doc) SILE.process(tree) elseif type(tree) == "table" then if not tree.type then - tree = { tree } -- hoping tree is an AST self:requireClass(tree) return SILE.process(tree) From 1e0d1a7071caf286ab1e8e0f645c609fb6d9625d Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 6 Dec 2022 23:55:24 +0300 Subject: [PATCH 7/7] fix(inputters): Work around SIL parser returning tags as part of content --- core/utilities.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/utilities.lua b/core/utilities.lua index cf7076e66a..8ddf47e978 100644 --- a/core/utilities.lua +++ b/core/utilities.lua @@ -328,6 +328,11 @@ utilities.contentToString = function (content) if type(content[i]) == "table" and type(content[i][1]) == "string" then string = string .. content[i][1] elseif type(content[i]) == "string" then + -- Work around PEG parser returning env tags as content + -- TODO: refactor capture groups in PEG parser + if content.command == content[i] and content[i] == content[i+1] then + break + end string = string .. content[i] end end