# Moreover it does not work in a Docker container (it fails when trying to mount
# /proc and /sys in the chroot).
cp package/* /usr/src/packages/SOURCES/
-rpmbuild -bb -D "jobs `nproc`" package/*.spec
+rpmbuild -bb --with coverage -D "jobs `nproc`" package/*.spec
# test the %pre/%post scripts by installing/updating/removing the built packages
# ignore the dependencies to make the test easier, as a smoke test it's good enough
# smoke test, make sure snapper at least starts
snapper --version
-# run the integration test
-cd /usr/lib*/snapper/testsuite
+# Run the integration test
+# Running it in the source tree ensures that the coverage report finds it
+pushd /usr/src/packages/BUILD/snapper-*/testsuite-real
./setup-and-run-all
-cd -
+popd
+
+# Coverage report
+pushd /usr/src/packages/BUILD/snapper-*
+make coverage
+popd
rpm -Uv --force --nodeps /usr/src/packages/RPMS/*/*.rpm
# get the plain package names and remove all packages at once
%define _fillupdir /var/adm/fillup-templates
%endif
+# optionally build with test coverage reporting
+%bcond_with coverage
+
Name: snapper
Version: @VERSION@
Release: 0
%else
BuildRequires: libjson-c-devel
%endif
+%if %{with coverage}
+BuildRequires: lcov
+%endif
Requires: diffutils
Requires: libsnapper@LIBVERSION_MAJOR@ = %version
%if 0%{?suse_version}
autoreconf -fi
%configure \
--docdir="%{_defaultdocdir}/snapper" \
+%if %{with coverage}
+ --enable-coverage \
+%endif
%if 0%{?suse_version} <= 1310
--disable-rollback \
%endif