From 62aa3779566650c3aa8d97fba321a7cf960c5df7 Mon Sep 17 00:00:00 2001 From: Joe Knapper Date: Wed, 13 May 2026 17:49:38 +0100 Subject: [PATCH 1/4] Allow -x in hardware tests to fail fast --- picamera_tests.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/picamera_tests.py b/picamera_tests.py index 8f4c4cdd..695aa45e 100755 --- a/picamera_tests.py +++ b/picamera_tests.py @@ -50,9 +50,16 @@ def _get_hashes(include_coverage: bool = False) -> dict[str, str]: return hashes -def run_tests() -> None: +def run_tests(exitfirst: bool = False) -> None: """Run the picamera tests, zip the coverage database, hash relevant source files.""" - subprocess.run(["pytest", "tests/hardware_specific_tests"], check=True) + pytest_cmd = ["pytest"] + + if exitfirst: + pytest_cmd.append("-x") + + pytest_cmd.append("tests/hardware_specific_tests") + subprocess.run(pytest_cmd, check=True) + shutil.copyfile(".coverage", COVERAGE_FILE) hash_dict = _get_hashes(include_coverage=True) with open(HASH_FILE, "w", encoding="utf-8") as json_file: @@ -103,16 +110,22 @@ def main() -> None: ) subparsers = parser.add_subparsers(dest="command", required=True) - subparsers.add_parser("run", help="Run hardware-specific tests on the PiCamera") + run_parser = subparsers.add_parser( + "run", + help="Run hardware-specific tests on the PiCamera", + ) - subparsers.add_parser( - "unzip", help="Unzip and verify coverage data on another machine" + run_parser.add_argument( + "-x", + "--exitfirst", + action="store_true", + help="Stop on first test failure", ) args = parser.parse_args() if args.command == "run": - run_tests() + run_tests(exitfirst=args.exitfirst) elif args.command == "unzip": unzip_coverage() From f3f5141e81a9d90b3577854db7a49079b3bc7952 Mon Sep 17 00:00:00 2001 From: jaknapper Date: Thu, 14 May 2026 11:57:28 +0100 Subject: [PATCH 2/4] Update readme --- tests/hardware_specific_tests/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/hardware_specific_tests/README.md b/tests/hardware_specific_tests/README.md index ec86b9d2..cb063ebf 100644 --- a/tests/hardware_specific_tests/README.md +++ b/tests/hardware_specific_tests/README.md @@ -20,6 +20,8 @@ To create a coverage report that will be included into the repository (and repor ./picamera_tests.py run +This will run every hardware test, recording their success or failure. As these tests are slow to run, it may be useful to set it to exit on first failure. To do this, run the above command with ` -x` at the end. + This will first run `pytest` on the hardware specific tests. This creates a `.coverage` database that can be used to analyse the code coverage of these tests. This will be copied to `.coverage.picamera`. The script will then create a zip of these test results along with hashes of source code for the Pi Camera: * `picamera.py` From c673d2ab2a2bb0880eb63059faae396f802b0859 Mon Sep 17 00:00:00 2001 From: jaknapper Date: Thu, 14 May 2026 12:15:06 +0100 Subject: [PATCH 3/4] Picamera --- picamera_coverage.zip | Bin 54038 -> 54038 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/picamera_coverage.zip b/picamera_coverage.zip index e1c41f1e8f939f3f0e9fddc228da6e458fe388ce..fb57989b62a11e8cc42bc1ee8f9b3665abc9a709 100644 GIT binary patch delta 45 wcmbQXjCtBJW}X0VW)=|!5a>_d$fI|GsXuwM%>_>;rvBu~?U(F8)bUIH05B{Mc>n+a delta 45 wcmbQXjCtBJW}X0VW)=|!5HJYe$fI|G$sl~Q%>_>;CWG+F?U(F8)bUIH02A;H%>V!Z From 5c3e228411e78c26e7212403ac0c3822716c3c4c Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Thu, 14 May 2026 12:51:22 +0000 Subject: [PATCH 4/4] Reinstate unzip command in picamera tests --- picamera_tests.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/picamera_tests.py b/picamera_tests.py index 695aa45e..a20b6dc9 100755 --- a/picamera_tests.py +++ b/picamera_tests.py @@ -115,6 +115,9 @@ def main() -> None: help="Run hardware-specific tests on the PiCamera", ) + subparsers.add_parser( + "unzip", help="Unzip and verify coverage data on another machine" + ) run_parser.add_argument( "-x", "--exitfirst",