From e7d5b8bd1f99c35f67e1ee6cc0143504c7a08a42 Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Tue, 29 Jul 2025 18:42:15 +0100 Subject: [PATCH] Improve README a for hardware specific tests, and make fixes to picamera_tests script --- hardware-specific-tests/README.md | 28 ++++++++++++++++++++++++++-- picamera_coverage.zip | Bin 53913 -> 53913 bytes picamera_tests.py | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/hardware-specific-tests/README.md b/hardware-specific-tests/README.md index d5bc7191..7e6e83e9 100644 --- a/hardware-specific-tests/README.md +++ b/hardware-specific-tests/README.md @@ -12,7 +12,7 @@ However, this will not archive the tests in the Git repository for reporting the When writing and debugging these unit tests it is often best to run a specific test and to use the `-s` flag to see the print statements. It is also often useful to use `--pdb` to drop you into a python debug session on any failure. For example, you might run: - /picamera2/test_exposure_time_drift.py::test_exposure_time_saves_and_loads -s --pdb + pytest hardware-specific-tests/picamera2/test_exposure_time_drift.py::test_exposure_time_saves_and_loads -s --pdb ### Reporting the coverage @@ -20,4 +20,28 @@ To create a coverage report that will be included into the repository run: ./picamera_tests.py run -This will create a zip of test results along with hashes of the picamera files and the base camera file. The server will include this overage report if the source files remain the same. \ No newline at end of file +This will create a zip of test results along with hashes of the picamera files and the base camera file. The server will include this coverage report if the source files remain the same. + +### Creating a combined report locally + +To create a combined coverage report locally (similar to the one created on CI) first run all normal tests with `pytest`. + +Copy the `.coverage` file to `.coverage.main` + + cp .coverage .coverage.main + +Then run: + + ./picamera_tests.py unzip + +to get the `.coverage.picamera` file. + +To combine reports run: + + coverage combine + +It is then possible to run: + +* `coverage report` to get the in-terminal report of the coverage. +* `coverage html` to get the HTML overview of covered lines. +* `coverage xml` to get an XML report any software that may need it. diff --git a/picamera_coverage.zip b/picamera_coverage.zip index c72822888cdf36bb69a9cd5f8134e3c6f83353d8..38b3714374152b266402b9829af91e734b7d1558 100644 GIT binary patch delta 45 xcmbQalzHY-W}X0VW)=|!5a64-kw@ dict[str, str]: filepaths = HASHED_FILES if include_coverage: filepaths.append(COVERAGE_FILE) - for filepath in HASHED_FILES: + for filepath in filepaths: if not os.path.isfile(filepath): # Sys exit rather than raise for better command line experience print(f"ERROR: {filepath} does not exist!")