From 0ed8d35bb2f494539dcacb6a900bf43bf86a2043 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Fri, 13 Oct 2023 17:38:08 +0200 Subject: [PATCH 1/2] chore(linux): Add code coverage index page This change adds an index page that can show the reports for the child projects. Also fix a path problem in the `keyman-system-service/build.sh` script. --- docs/linux/README.md | 15 +++++++++++ linux/CodeCoverageReports.html | 37 ++++++++++++++++++++++++++++ linux/README.md | 2 -- linux/build.sh | 9 +++++++ linux/keyman-system-service/build.sh | 6 ++--- 5 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 linux/CodeCoverageReports.html diff --git a/docs/linux/README.md b/docs/linux/README.md index d848e215ed1..f76408f24b2 100644 --- a/docs/linux/README.md +++ b/docs/linux/README.md @@ -87,6 +87,21 @@ scripts/run-tests The `run-tests` script accepts different arguments which can be seen with `scripts/run-tests --help`. +### Code Coverage Report + +All three projects (ibus-keyman, keyman-config, and keyman-system-service) +can produce code coverage reports. + +Run `./build.sh --debug --coverage --report test` to create the report. + +**Note:** You might have to run `./build.sh clean` first. + +There's also an index page (`linux/CodecoverageReports.html`) that links to all +three reports. You can run +`linux/build.sh --debug --coverage --report --no-integration test` +to create the coverage reports for all three Linux projects and open the +index page in the browser. + ## Running Keyman for Linux ### Setting up Ibus diff --git a/linux/CodeCoverageReports.html b/linux/CodeCoverageReports.html new file mode 100644 index 00000000000..d52d27d056f --- /dev/null +++ b/linux/CodeCoverageReports.html @@ -0,0 +1,37 @@ + + + Keyman for Linux Code Coverage + + + +
+
+

Keyman for Linux Code Coverage Reports

+ + + +
+ +
+ + + + + diff --git a/linux/README.md b/linux/README.md index e4b50cdc905..3dfb3404779 100644 --- a/linux/README.md +++ b/linux/README.md @@ -1,5 +1,3 @@ # Keyman for Linux See [/docs/linux/README.md](../docs/linux/README.md) for documentation. - -. \ No newline at end of file diff --git a/linux/build.sh b/linux/build.sh index da2212609d2..b98ff97ff82 100755 --- a/linux/build.sh +++ b/linux/build.sh @@ -30,3 +30,12 @@ builder_describe \ builder_parse "$@" builder_run_child_actions clean configure build test install uninstall + +test_action() { + if builder_has_option --report; then + builder_echo "Opening coverage reports in browser..." + xdg-open "file://${THIS_SCRIPT_PATH}/CodeCoverageReports.html" + fi +} + +builder_run_action test test_action diff --git a/linux/keyman-system-service/build.sh b/linux/keyman-system-service/build.sh index 549b33596ef..bfa4b62c3bf 100755 --- a/linux/keyman-system-service/build.sh +++ b/linux/keyman-system-service/build.sh @@ -50,14 +50,14 @@ builder_run_action clean rm -rf "$THIS_SCRIPT_PATH/build/" # shellcheck disable=SC2086 builder_run_action configure meson setup "$MESON_PATH" --werror --buildtype $MESON_TARGET ${MESON_COVERAGE} "${builder_extra_params[@]}" +cd "$MESON_PATH" || true + if builder_start_action build; then - cd "$MESON_PATH" ninja builder_finish_action success build fi if builder_start_action test; then - cd "$MESON_PATH" meson test --print-errorlogs $builder_verbose if builder_has_option --coverage; then # Note: requires lcov > 1.16 to properly work (see https://github.com/mesonbuild/meson/issues/6747) @@ -67,13 +67,11 @@ if builder_start_action test; then fi if builder_start_action install; then - cd "$MESON_PATH" ninja install builder_finish_action success install fi if builder_start_action uninstall; then - cd "$MESON_PATH" ninja uninstall builder_finish_action success uninstall fi From 943370d682136dc81e7e6cde886d25f28bf0f40e Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Mon, 16 Oct 2023 17:22:41 +0200 Subject: [PATCH 2/2] chore(linux): Add `--open` option to open coverage reports in browser This addresses code review comments. --- docs/linux/README.md | 2 +- linux/build.sh | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/linux/README.md b/docs/linux/README.md index f76408f24b2..354ee895318 100644 --- a/docs/linux/README.md +++ b/docs/linux/README.md @@ -98,7 +98,7 @@ Run `./build.sh --debug --coverage --report test` to create the report. There's also an index page (`linux/CodecoverageReports.html`) that links to all three reports. You can run -`linux/build.sh --debug --coverage --report --no-integration test` +`linux/build.sh --debug --coverage --report --open --no-integration test` to create the coverage reports for all three Linux projects and open the index page in the browser. diff --git a/linux/build.sh b/linux/build.sh index b98ff97ff82..9a4959c5d0e 100755 --- a/linux/build.sh +++ b/linux/build.sh @@ -24,15 +24,16 @@ builder_describe \ "install install artifacts" \ "uninstall uninstall artifacts" \ "--no-integration+ don't run integration tests" \ + "--coverage+ capture test coverage" \ "--report+ create coverage report" \ - "--coverage+ capture test coverage" + "--open open the coverage reports in the browser" builder_parse "$@" builder_run_child_actions clean configure build test install uninstall test_action() { - if builder_has_option --report; then + if builder_has_option --open; then builder_echo "Opening coverage reports in browser..." xdg-open "file://${THIS_SCRIPT_PATH}/CodeCoverageReports.html" fi