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..fe7b36ab37 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,6 +221,7 @@ endif $(LOCALTESTFONTS) $(BUSTED) --cpath="$${packagecpath[*]};;" --lpath="$${packagepath[*]};;" $(BUSTEDFLAGS) . coverage: export SILE_COVERAGE=1 +coverage: BUSTEDFLAGS = -c coverage: regression_previews busted HEADSHA ?= HEAD @@ -253,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 b/build-aux/list-dist-files.sh.in similarity index 68% rename from build-aux/list-dist-files.sh rename to build-aux/list-dist-files.sh.in index bdb0e48188..eaf29ee66b 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 =" @@ -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' 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]) 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 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) 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]