@@ -20,7 +20,9 @@ builder_describe \
2020 " install install artifacts" \
2121 " uninstall uninstall artifacts" \
2222 " @/core:arch" \
23- " --no-integration don't run integration tests"
23+ " --no-integration don't run integration tests" \
24+ " --report create coverage report" \
25+ " --coverage capture test coverage"
2426
2527builder_parse " $@ "
2628
@@ -40,6 +42,12 @@ builder_describe_outputs \
4042 configure " ${MESON_PATH} /build.ninja" \
4143 build " ${MESON_PATH} /src/ibus-engine-keyman"
4244
45+ if builder_has_option --coverage; then
46+ MESON_COVERAGE=-Db_coverage=true
47+ else
48+ MESON_COVERAGE=
49+ fi
50+
4351if builder_start_action clean; then
4452 rm -rf " $THIS_SCRIPT_PATH /../build/"
4553 builder_finish_action success clean
4856if builder_start_action configure; then
4957 cd " $THIS_SCRIPT_PATH "
5058 # shellcheck disable=SC2086
51- meson setup " $MESON_PATH " --werror --buildtype $MESON_TARGET " ${builder_extra_params[@]} "
59+ meson setup " $MESON_PATH " --werror --buildtype $MESON_TARGET ${MESON_COVERAGE} " ${builder_extra_params[@]} "
5260 builder_finish_action success configure
5361fi
5462
@@ -65,6 +73,10 @@ if builder_start_action test; then
6573 else
6674 meson test --print-errorlogs $builder_verbose
6775 fi
76+ if builder_has_option --coverage; then
77+ # Note: requires lcov > 1.16 to properly work (see https://github.com/mesonbuild/meson/issues/6747)
78+ ninja coverage-html
79+ fi
6880 builder_finish_action success test
6981fi
7082
0 commit comments