From a870b9a6c05f85ad3466d3e3af799bf119fcbd6a Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Mon, 18 Sep 2023 18:44:11 +0200 Subject: [PATCH 1/3] chore(linux): Add coverage action to `ibus-keyman/build.sh` --- docs/settings/linux/tasks.json | 17 +++++++++++++++++ linux/ibus-keyman/build.sh | 22 ++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/docs/settings/linux/tasks.json b/docs/settings/linux/tasks.json index 9751c95a44c..c5f2d063614 100644 --- a/docs/settings/linux/tasks.json +++ b/docs/settings/linux/tasks.json @@ -166,6 +166,23 @@ "group": "build", "detail": "run unit and integration tests of ibus-keyman" }, + { + "type": "shell", + "label": "ibus-keyman: report", + "command": "./build.sh", + "args": [ + "test", + "report", + "--debug", + "--coverage", + "--no-integration" + ], + "options": { + "cwd": "${workspaceFolder}/linux/ibus-keyman/", + }, + "group": "build", + "detail": "create unit test coverage" + }, { "type": "shell", "label": "keyman-config: tests", diff --git a/linux/ibus-keyman/build.sh b/linux/ibus-keyman/build.sh index 58bc0576916..ecb6bd5e089 100755 --- a/linux/ibus-keyman/build.sh +++ b/linux/ibus-keyman/build.sh @@ -19,11 +19,16 @@ builder_describe \ "test" \ "install install artifacts" \ "uninstall uninstall artifacts" \ + "report create coverage report" \ "@/core:arch" \ - "--no-integration don't run integration tests" + "--no-integration don't run integration tests" \ + "--coverage capture test coverage" builder_parse "$@" +builder_describe_internal_dependency \ + report:engine test:engine + if builder_is_debug_build; then MESON_TARGET=debug export CPPFLAGS=-DG_MESSAGES_DEBUG @@ -40,6 +45,12 @@ builder_describe_outputs \ configure "${MESON_PATH}/build.ninja" \ build "${MESON_PATH}/src/ibus-engine-keyman" +if builder_has_option --coverage; then + MESON_COVERAGE=-Db_coverage=true +else + MESON_COVERAGE= +fi + if builder_start_action clean; then rm -rf "$THIS_SCRIPT_PATH/../build/" builder_finish_action success clean @@ -48,7 +59,7 @@ fi if builder_start_action configure; then cd "$THIS_SCRIPT_PATH" # shellcheck disable=SC2086 - meson setup "$MESON_PATH" --werror --buildtype $MESON_TARGET "${builder_extra_params[@]}" + meson setup "$MESON_PATH" --werror --buildtype $MESON_TARGET ${MESON_COVERAGE} "${builder_extra_params[@]}" builder_finish_action success configure fi @@ -79,3 +90,10 @@ if builder_start_action uninstall; then ninja uninstall builder_finish_action success uninstall fi + +if builder_start_action report; then + cd "$THIS_SCRIPT_PATH/$MESON_PATH" + # Note: requires lcov > 1.16 to properly work (see https://github.com/mesonbuild/meson/issues/6747) + ninja coverage-html + builder_finish_action success report +fi From 3f4dae023180e2aa3531b731e6f3f6d6f695c7ce Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Tue, 19 Sep 2023 10:23:00 +0200 Subject: [PATCH 2/3] chore(linux): make `--report` an option instead of action This addresses code review comments. --- docs/settings/linux/tasks.json | 4 ++-- linux/ibus-keyman/build.sh | 13 +++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/settings/linux/tasks.json b/docs/settings/linux/tasks.json index c5f2d063614..891c8b5d154 100644 --- a/docs/settings/linux/tasks.json +++ b/docs/settings/linux/tasks.json @@ -172,7 +172,7 @@ "command": "./build.sh", "args": [ "test", - "report", + "--report", "--debug", "--coverage", "--no-integration" @@ -181,7 +181,7 @@ "cwd": "${workspaceFolder}/linux/ibus-keyman/", }, "group": "build", - "detail": "create unit test coverage" + "detail": "run tests and create unit test coverage report" }, { "type": "shell", diff --git a/linux/ibus-keyman/build.sh b/linux/ibus-keyman/build.sh index ecb6bd5e089..9f9de96488d 100755 --- a/linux/ibus-keyman/build.sh +++ b/linux/ibus-keyman/build.sh @@ -19,9 +19,9 @@ builder_describe \ "test" \ "install install artifacts" \ "uninstall uninstall artifacts" \ - "report create coverage report" \ "@/core:arch" \ "--no-integration don't run integration tests" \ + "--report create coverage report" \ "--coverage capture test coverage" builder_parse "$@" @@ -76,6 +76,10 @@ if builder_start_action test; then else meson test --print-errorlogs $builder_verbose fi + if builder_has_option --coverage; then + # Note: requires lcov > 1.16 to properly work (see https://github.com/mesonbuild/meson/issues/6747) + ninja coverage-html + fi builder_finish_action success test fi @@ -90,10 +94,3 @@ if builder_start_action uninstall; then ninja uninstall builder_finish_action success uninstall fi - -if builder_start_action report; then - cd "$THIS_SCRIPT_PATH/$MESON_PATH" - # Note: requires lcov > 1.16 to properly work (see https://github.com/mesonbuild/meson/issues/6747) - ninja coverage-html - builder_finish_action success report -fi From 20149b6a2ff2fb03e18ce90280ab93bf350efe03 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Wed, 20 Sep 2023 08:52:13 +0200 Subject: [PATCH 3/3] chore(linux): Remove obsolete code Addresses code review comment. --- linux/ibus-keyman/build.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/linux/ibus-keyman/build.sh b/linux/ibus-keyman/build.sh index 9f9de96488d..bc136546d63 100755 --- a/linux/ibus-keyman/build.sh +++ b/linux/ibus-keyman/build.sh @@ -26,9 +26,6 @@ builder_describe \ builder_parse "$@" -builder_describe_internal_dependency \ - report:engine test:engine - if builder_is_debug_build; then MESON_TARGET=debug export CPPFLAGS=-DG_MESSAGES_DEBUG