From 8bb4a0bc78d02c88f90236c4f5ebb9ee2485af62 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Thu, 24 Feb 2022 14:09:26 -0700 Subject: zmake: document how to generate coverage report Add instructions for running zmake unit tests outside the chroot and generating coverage data. BRANCH=None BUG=b:219062927 TEST=Ran the commands Signed-off-by: Jeremy Bettis Change-Id: Ib1e9a2ddba95d64c2a20973be444edff0e22c30a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3491404 Tested-by: Jeremy Bettis Auto-Submit: Jeremy Bettis Reviewed-by: Jack Rosenthal Commit-Queue: Jack Rosenthal --- .gitignore | 1 + zephyr/README.md | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/.gitignore b/.gitignore index aacb38ac3a..db195ffc98 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ cscope.* __pycache__ *.egg-info .hypothesis/ +zephyr/zmake/.coverage # Clangd language server .cache/clangd/index/* diff --git a/zephyr/README.md b/zephyr/README.md index 07645fa177..e23aa15a82 100644 --- a/zephyr/README.md +++ b/zephyr/README.md @@ -59,3 +59,17 @@ report, but not in the chroot, as some pip modules are missing there. The [latest coverage report](https://gitlab.com/zephyr-ec/ec/-/jobs/artifacts/main/file/zephyr/zmake/htmlcov/index.html?job=zmake_coverage ) is on gitlab. + +You can run the coverage report outside of the chroot easily: + +``` +# Install test dependencies +cd ~/chromiumos/src/platform/ec +python3 -m pip install 'zephyr/zmake[tests]' --user +# Run tests with coverage +cd ~/chromiumos/src/platform/ec/zephyr/zmake +coverage run --source=zmake -m pytest . +coverage report +coverage html +xdg-open htmlcov/index.html +``` -- cgit v1.2.1