From 03274aa9184e2f265d2a32736d242f9359833aed Mon Sep 17 00:00:00 2001 From: kdmukai Date: Wed, 6 Nov 2024 09:49:36 -0600 Subject: [PATCH] Adds `coverage` convenience script --- pyproject.toml | 2 +- tests/README.md | 11 ++++++++++- tests/run_full_coverage.sh | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100755 tests/run_full_coverage.sh diff --git a/pyproject.toml b/pyproject.toml index e7a8a5aa..f0edccaa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ omit = [ "*/tests/*", "*/pyzbar/*", ] -skip_covered = true +skip_covered = false skip_empty = true [tool.coverage.run] diff --git a/tests/README.md b/tests/README.md index 686c7b86..e948cfba 100644 --- a/tests/README.md +++ b/tests/README.md @@ -2,6 +2,7 @@ The tests are designed to be run on non-Raspi hardware. +## Setup On your testing machine you'll have to install: ```bash # general dependencies @@ -16,6 +17,14 @@ Then make the `seedsigner` python module visible/importable to the tests by inst pip3 install -e . ``` +## Running all tests, calculating overall test coverage +tldr: just run the convenience script from the project root: + +```bash +./tests/run_full_coverage.sh +``` + +## Running tests manually Run the whole test suite: ``` pytest @@ -52,7 +61,7 @@ it is actually implemented to be run by `pytest`. see: [Screenshot generator README](screenshot_generator/README.md) -## Test Coverage +## Generate coverage manually Run tests and generate test coverage ```bash coverage run -m pytest diff --git a/tests/run_full_coverage.sh b/tests/run_full_coverage.sh new file mode 100755 index 00000000..0eca3f00 --- /dev/null +++ b/tests/run_full_coverage.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Run the full test suite +coverage run -m pytest + +# Generate screenshots (only need to run for one locale to assess coverage) +coverage run -m pytest tests/screenshot_generator/generator.py --locale es + +# Combine the above coverage results; also cleans up any prior .coverage.* results files +coverage combine + +# Show the cli report +coverage report + +# Generate the interactive html report +coverage html