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 c7282288..38b37143 100644 Binary files a/picamera_coverage.zip and b/picamera_coverage.zip differ diff --git a/picamera_tests.py b/picamera_tests.py index e8cadfe5..a1bd38d0 100755 --- a/picamera_tests.py +++ b/picamera_tests.py @@ -38,7 +38,7 @@ def _get_hashes(include_coverage: bool = False) -> 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!")