Merge branch 'hardware-test-exit' into 'v3'
Allow -x in hardware tests to fail fast See merge request openflexure/openflexure-microscope-server!589
This commit is contained in:
commit
b646efa047
3 changed files with 22 additions and 4 deletions
Binary file not shown.
|
|
@ -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,25 @@ 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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue