Skip to content

Commit

Permalink
chore: require explicitly building for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ramsey committed Sep 11, 2023
1 parent eff8e9b commit 5f4c7b7
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- name: "Build and install ecma_intl"
run: |
phpize
./configure --enable-ecma_intl --enable-criterion
./configure --enable-ecma_intl --enable-criterion --enable-code-coverage
make -j$(nproc)
php -d extension="$PWD/modules/ecma_intl.so" --ri ecma_intl
Expand Down
2 changes: 1 addition & 1 deletion Makefile.frag
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ check-criterion:
fi

tests/criterion/runner: check-criterion $(criterion_objects)
$(CXX) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -fprofile-arcs -ftest-coverage -O0 $(LDFLAGS) $(EXTRA_LDFLAGS) $(criterion_objects) -o tests/criterion/runner $(ECMA_INTL_SHARED_LIBADD) $(CRITERION_LIBS)
$(CXX) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(COVERAGE_FLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(criterion_objects) -o tests/criterion/runner $(ECMA_INTL_SHARED_LIBADD) $(CRITERION_LIBS)

#
# In CLion, set the "Build target" to "dev" in the Makefile project settings,
Expand Down
16 changes: 15 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@
"test:coverage:html": {
"override": true,
"script": [
"git clean -fX ./build/coverage/.",
"@dev:test:criterion",
"gcovr --exclude-directories tests --html-nested --html-syntax-highlighting -o build/coverage/coverage.html"
"gcovr --exclude-directories tests --html-nested --html-syntax-highlighting -o build/coverage/index.html"
]
}
},
Expand All @@ -102,13 +103,26 @@
"./configure --enable-ecma_intl --enable-criterion",
"make -j$(nproc) dev"
],
"dev:build:coverage": [
"make clean || true",
"phpize",
"./configure --enable-ecma_intl --enable-criterion --enable-code-coverage",
"make -j$(nproc) dev"
],
"dev:build:local": [
"./tools/tool-check",
"make clean || true",
"./tools/phpize",
"PKG_CONFIG_PATH=$(brew --prefix icu4c)/lib/pkgconfig ./configure --enable-ecma_intl --enable-criterion --with-php-config=tools/php-config",
"make -j$(nproc) dev"
],
"dev:build:local:coverage": [
"./tools/tool-check",
"make clean || true",
"./tools/phpize",
"PKG_CONFIG_PATH=$(brew --prefix icu4c)/lib/pkgconfig ./configure --enable-ecma_intl --enable-criterion --enable-code-coverage --with-php-config=tools/php-config",
"make -j$(nproc) dev"
],
"dev:docker:run": [
"Composer\\Config::disableProcessTimeout",
"docker compose up -d --build",
Expand Down
18 changes: 18 additions & 0 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ PHP_ARG_ENABLE(
[no]
)

PHP_ARG_ENABLE(
[code-coverage],
[whether to enable support for code coverage symbols],
[AS_HELP_STRING(
[--enable-code-coverage],
[Enable support for code coverage reports (development only)])
],
[no],
[no]
)

if test "$PHP_ECMA_INTL" != "no"; then
PKG_CHECK_MODULES([ICU], [icu-uc >= 70.1 icu-i18n icu-io])

Expand Down Expand Up @@ -166,4 +177,11 @@ if test "$PHP_ECMA_INTL" != "no"; then

PHP_SUBST(criterion_objects)
fi

if test "$PHP_CODE_COVERAGE" != "no"; then
AC_DEFINE(HAVE_CODE_COVERAGE, 1, [ Have code coverage support ])
COVERAGE_FLAGS="-fprofile-arcs -ftest-coverage -O0"
fi

PHP_SUBST(COVERAGE_FLAGS)
fi
4 changes: 2 additions & 2 deletions m4/tests.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ dnl Adapted from PHP_BUILD_PROGRAM in php.m4.
dnl
AC_DEFUN([TEST_BUILD_PROGRAM],[
test_c_pre='$(CC)'
test_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -fprofile-arcs -ftest-coverage -O0'
test_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(COVERAGE_FLAGS)'
test_c_post=
test_cxx_pre='$(CXX)'
test_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) -fprofile-arcs -ftest-coverage -O0'
test_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) $(COVERAGE_FLAGS)'
test_cxx_post=
])

Expand Down

0 comments on commit 5f4c7b7

Please sign in to comment.