diff --git a/.gitignore b/.gitignore index b94a21d8..acc08e3c 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,9 @@ nosetests.xml coverage.xml report.xml pytest_report.xml +.coverage.picamera +.coverage.main +picamera_test_hashes.json # Translations *.mo diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4bbb1e73..244f5025 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -130,15 +130,31 @@ pytest: - git config --global user.name "Sir Unit of Test" - git config --global user.email "fake@email.no" - pytest + - mv .coverage .coverage.main # --gitlab-code-quality-report=pytest-warnings.json # can restore when it installs ok - coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/' artifacts: when: always paths: - report.xml + - .coverage.main + +# Combine CI coverage with coverage from Picamera +combined-tests: + stage: testing + extends: .python + needs: + - job: pytest + artifacts: true + script: + - ./picamera_tests.py unzip + - coverage combine + - coverage report + - coverage xml + coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/' + artifacts: + when: always reports: junit: report.xml -# codequality: pytest-warnings.json coverage_report: coverage_format: cobertura path: coverage.xml diff --git a/hardware-specific-tests/README.md b/hardware-specific-tests/README.md index 62172610..d5bc7191 100644 --- a/hardware-specific-tests/README.md +++ b/hardware-specific-tests/README.md @@ -10,7 +10,7 @@ It is essential to stop the server first: However, this will not archive the tests in the Git repository for reporting the coverage. For this see the section below on reporting the coverage. -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 statments. It is also often useful to use `--pdb` to drop you into a python debug session on any failure. For example, you might run: +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 diff --git a/picamera_coverage.zip b/picamera_coverage.zip new file mode 100644 index 00000000..0eab078c Binary files /dev/null and b/picamera_coverage.zip differ diff --git a/picamera_tests.py b/picamera_tests.py index da648d4e..17dd5662 100755 --- a/picamera_tests.py +++ b/picamera_tests.py @@ -25,14 +25,14 @@ HASHED_FILES = [ def _get_hashes(include_coverage=False): - """Return a dictonary of Git hashes for the HASHED FILES. + """Return a dictionary of Git hashes for the HASHED FILES. The key is the posixpath to the file so matching works even if the dictionary is compared to a dictionary created on another system. The coverage file is hashed when running for debug purposes. - Git hashes are so the files are line ending indpendent. + Git hashes are so the files are line ending independent. """ hashes = {} filepaths = HASHED_FILES