From: Martin Vidner Date: Fri, 10 Jan 2020 11:50:02 +0000 (+0100) Subject: In Travis, build with coverage enabled X-Git-Tag: v0.8.9~1^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d568d0ee1cc3cf6ce6e8bab37147e7dc38f484cb;p=thirdparty%2Fsnapper.git In Travis, build with coverage enabled --- diff --git a/.travis.tumbleweed.sh b/.travis.tumbleweed.sh index 8e3a8605..526ed0fc 100755 --- a/.travis.tumbleweed.sh +++ b/.travis.tumbleweed.sh @@ -13,7 +13,7 @@ make package # 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 @@ -22,10 +22,16 @@ rpm -iv --force --nodeps /usr/src/packages/RPMS/*/*.rpm # 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 diff --git a/Dockerfile.tumbleweed b/Dockerfile.tumbleweed index 49598155..75ec5066 100644 --- a/Dockerfile.tumbleweed +++ b/Dockerfile.tumbleweed @@ -17,6 +17,7 @@ RUN RUBY_VERSION=ruby:`rpm --eval '%{rb_ver}'` && \ e2fsprogs-devel \ gcc-c++ \ grep \ + lcov \ libacl-devel \ libboost_system-devel \ libboost_test-devel \ @@ -29,6 +30,7 @@ RUN RUBY_VERSION=ruby:`rpm --eval '%{rb_ver}'` && \ libxslt \ obs-service-source_validator \ pam-devel \ + perl-JSON \ rpm-build \ "rubygem($RUBY_VERSION:ruby-dbus)" \ which diff --git a/snapper.spec.in b/snapper.spec.in index 226a5b88..49ce5bd8 100644 --- a/snapper.spec.in +++ b/snapper.spec.in @@ -20,6 +20,9 @@ %define _fillupdir /var/adm/fillup-templates %endif +# optionally build with test coverage reporting +%bcond_with coverage + Name: snapper Version: @VERSION@ Release: 0 @@ -76,6 +79,9 @@ BuildRequires: json-c-devel %else BuildRequires: libjson-c-devel %endif +%if %{with coverage} +BuildRequires: lcov +%endif Requires: diffutils Requires: libsnapper@LIBVERSION_MAJOR@ = %version %if 0%{?suse_version} @@ -100,6 +106,9 @@ export CXXFLAGS="%{optflags} -DNDEBUG" autoreconf -fi %configure \ --docdir="%{_defaultdocdir}/snapper" \ +%if %{with coverage} + --enable-coverage \ +%endif %if 0%{?suse_version} <= 1310 --disable-rollback \ %endif