Skip to content

Commit

Permalink
Merge 1e0d1a7 into 9ee9dcd
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Dec 6, 2022
2 parents 9ee9dcd + 1e0d1a7 commit f95b74d
Show file tree
Hide file tree
Showing 18 changed files with 123 additions and 16 deletions.
77 changes: 77 additions & 0 deletions .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 }}
5 changes: 3 additions & 2 deletions Makefile.am
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 $@,:)
Expand Down
13 changes: 12 additions & 1 deletion build-aux/list-dist-files.sh → build-aux/list-dist-files.sh.in
Expand Up @@ -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 ="
Expand All @@ -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'

Expand Down
2 changes: 2 additions & 0 deletions configure.ac
Expand Up @@ -17,6 +17,7 @@ AC_PROG_SED

AX_PROGVAR([cmp])
AX_PROGVAR([git])
AX_PROGVAR([find])

LT_PREREQ([2.2])
LT_INIT([dlopen])
Expand Down Expand Up @@ -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])

Expand Down
5 changes: 5 additions & 0 deletions core/utilities.lua
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion inputters/lua.lua
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion tests/049EPH.xml
@@ -1,4 +1,5 @@
<sile papersize="152mm x 229mm" class="bible" twocolumns="true"> <!-- KNOWNBAD -->
<!-- KNOWNBAD https://github.com/sile-typesetter/sile/issues/326#issuecomment-224873117 -->
<sile papersize="152mm x 229mm" class="bible" twocolumns="true">
<set parameter="linebreak.tolerance" value="5000"/>
<set-counter id="footnote" display="alpha"/>
<font language="en"/>
Expand Down
3 changes: 2 additions & 1 deletion 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]
Expand Down
3 changes: 2 additions & 1 deletion 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.
Expand Down
3 changes: 2 additions & 1 deletion 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)
Expand Down
3 changes: 2 additions & 1 deletion 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]
Expand Down
3 changes: 2 additions & 1 deletion 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
Expand Down
3 changes: 2 additions & 1 deletion 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]
Expand Down
3 changes: 2 additions & 1 deletion 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]
Expand Down
3 changes: 2 additions & 1 deletion 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]
Expand Down
3 changes: 2 additions & 1 deletion 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]
Expand Down
3 changes: 2 additions & 1 deletion 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]

Expand Down
3 changes: 2 additions & 1 deletion 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]
Expand Down

0 comments on commit f95b74d

Please sign in to comment.