diff --git a/docs/linux/README.md b/docs/linux/README.md index d848e215ed..f76408f24b 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 0000000000..d52d27d056 --- /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 e4b50cdc90..3dfb340477 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 da2212609d..b98ff97ff8 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 549b33596e..bfa4b62c3b 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