Skip to content

Commit

Permalink
Merge pull request #9758 from keymanapp/chore/linux/coverage
Browse files Browse the repository at this point in the history
chore(linux): Add code coverage index page
  • Loading branch information
ermshiperete authored Oct 17, 2023
2 parents af3ba1f + 943370d commit 2ab9334
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 7 deletions.
15 changes: 15 additions & 0 deletions docs/linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 --open --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
Expand Down
37 changes: 37 additions & 0 deletions linux/CodeCoverageReports.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<html>
<head>
<title>Keyman for Linux Code Coverage</title>
<style type="text/css">
body, html {width: 100%; height: 100%; margin-left: 0; padding-left: 0;}
.row-container {display: flex; width: 100%; height: 100%; flex-direction: column; overflow: hidden;}
.second-row { flex-grow: 1; border: none; margin: 0; padding: 0; border: none; }
.tablink { background-color: #555; color: white; float: left; border: none; border-right: 1px solid black; outline: none; cursor: pointer; padding: 14px 16px; font-size: 17px; width: 33.3%; }
.tablink:hover { background-color: #777; }
</style>
</head>
<body>
<div class="row-container">
<div class="first-row">
<h1>Keyman for Linux Code Coverage Reports</h1>
<button class="tablink" onclick="openPage(this, 'build/x86_64/debug/meson-logs/coveragereport/index.html')" id="defaultOpen">ibus-keyman</button>
<button class="tablink" onclick="openPage(this, 'keyman-config/build/coveragereport/index.html')">keyman-config</button>
<button class="tablink" onclick="openPage(this, 'keyman-system-service/build/x86_64/debug/meson-logs/coveragereport/index.html')">keyman-system-service</button>
</div>
<iframe id="iframe_a" class="second-row"></iframe>
</div>

<script>
function openPage(elmnt, filename) {
document.getElementById('iframe_a').src = filename;
tablinks = document.getElementsByClassName("tablink");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].style.backgroundColor = "";
}
elmnt.style.backgroundColor = "#777";
}

document.getElementById("defaultOpen").click();
</script>

</body>
</html>
2 changes: 0 additions & 2 deletions linux/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Keyman for Linux

See [/docs/linux/README.md](../docs/linux/README.md) for documentation.

.
12 changes: 11 additions & 1 deletion linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,19 @@ 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 --open; then
builder_echo "Opening coverage reports in browser..."
xdg-open "file://${THIS_SCRIPT_PATH}/CodeCoverageReports.html"
fi
}

builder_run_action test test_action
6 changes: 2 additions & 4 deletions linux/keyman-system-service/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

0 comments on commit 2ab9334

Please sign in to comment.