Commit 46686ba2 authored by Philip Chimento's avatar Philip Chimento 🚮

build: Use AX_CODE_COVERAGE macro

Instead of the homebrew stuff, use AX_CODE_COVERAGE from the Autoconf
Archive. We do require a few extra options in order to include the
coverage data for the JS files.

See: https://wiki.gnome.org/Initiatives/GnomeGoals/ModernAutotools

https://bugzilla.gnome.org/show_bug.cgi?id=772027
parent 538a7c38
......@@ -126,35 +126,16 @@ TESTS_ENVIRONMENT = \
G_FILENAME_ENCODING=latin1 # ensure filenames are not utf8 \
DBUS_UUIDGEN="$(DBUS_UUIDGEN)"
if ENABLE_COVERAGE
if CODE_COVERAGE_ENABLED
TESTS_ENVIRONMENT += \
GJS_UNIT_COVERAGE_OUTPUT=lcov \
GJS_UNIT_COVERAGE_PREFIX=resource:///org/gnome/gjs/
endif
########################################################################
if ENABLE_COVERAGE
lcov:
test -d lcov || mkdir lcov
$(LCOV) --compat-libtool --directory . --capture -o lcov/lcov_tmp.info
$(LCOV) --extract lcov/lcov_tmp.info "$(PWD)/*" -o lcov/lcov.info
rm -f lcov/lcov_tmp.info
$(GENHTML) --legend -o lcov lcov/lcov.info lcov/coverage.lcov
lcov-clean:
find . -name '*.gcda' -delete
rm -rf lcov
lcov-realclean: lcov-clean
find . -name '*.gcno' -delete
clean-local: lcov-realclean
.PHONY: lcov lcov-clean lcov-realclean
else
lcov:
@echo >&1 "*** ERROR: 'configure --enable-coverage' required"
@exit 1
.PHONY: lcov
endif
CODE_COVERAGE_IGNORE_PATTERN = */include/*
CODE_COVERAGE_GENHTML_OPTIONS = \
lcov/coverage.lcov \
--prefix $(abs_top_builddir)/lcov/org/gnome/gjs \
--prefix $(abs_top_builddir) \
$(NULL)
@CODE_COVERAGE_RULES@
......@@ -16,8 +16,9 @@ check_PROGRAMS = $(TEST_PROGS)
INTROSPECTION_GIRS =
## ACLOCAL_AMFLAGS can be removed for Automake 1.13
ACLOCAL_AMFLAGS = -I m4
AM_CXXFLAGS = $(WARN_CXXFLAGS)
AM_CPPFLAGS = -DG_LOG_DOMAIN=\"Gjs\"
AM_CXXFLAGS = $(WARN_CXXFLAGS) $(CODE_COVERAGE_CFLAGS)
AM_CPPFLAGS = -DG_LOG_DOMAIN=\"Gjs\" $(CODE_COVERAGE_CPPFLAGS)
AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
MAINTAINERCLEANFILES = \
$(GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL) \
$(GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN) \
......
......@@ -41,28 +41,12 @@ AC_PROG_SED
GNOME_CXX_WARNINGS([maximum])
# coverage
AC_ARG_ENABLE([coverage],
[AS_HELP_STRING([--enable-coverage],
[enable code coverage])],
, [enable_coverage=no])
if test x$enable_coverage = xyes; then
if test x$GCC != xyes; then
AC_MSG_ERROR([GCC is required for --enable-coverage])
fi
AC_PATH_TOOL([LCOV], [lcov])
AC_PATH_TOOL([GENHTML], [genhtml])
if test x$LCOV = x || test x$GENHTML = x; then
AC_MSG_ERROR([lcov and genhtml are required for --enable-coverage])
fi
CFLAGS="$CFLAGS -g -O0 --coverage"
CXXFLAGS="$CXXFLAGS -g -O0 --coverage"
LIBS="$LIBS -lgcov"
fi
AM_CONDITIONAL([ENABLE_COVERAGE], [test x$enable_coverage = xyes])
AX_CODE_COVERAGE
dnl Clang does not need to link with -lgcov
AX_CHECK_LINK_FLAG([-lgcov],, [
CODE_COVERAGE_LIBS=
CODE_COVERAGE_LDFLAGS=
])
# Checks for libraries.
m4_define(glib_required_version, 2.42.0)
......@@ -243,4 +227,5 @@ AC_MSG_RESULT([
dtrace: ${enable_dtrace:-no}
systemtap: ${enable_systemtap:-no}
Run tests under: ${TEST_MSG}
Code coverage: ${enable_code_coverage}
])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment