Skip to content

Commit

Permalink
Merge pull request #480 from 3dgeo-heidelberg/pytests_rev
Browse files Browse the repository at this point in the history
Regression testing setup + fixturized pytests
  • Loading branch information
han16nah authored Dec 5, 2024
2 parents 4d1c3ba + f3d2901 commit 5c53c67
Show file tree
Hide file tree
Showing 23 changed files with 709 additions and 268 deletions.
27 changes: 23 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ on:
- dev
- alpha-dev
workflow_dispatch:
inputs:
upload-outputs:
description: 'Whether to upload outputs'
default: false
type: boolean

jobs:
build-and-test:
Expand Down Expand Up @@ -58,9 +63,23 @@ jobs:
env:
SETUPTOOLS_SCM_SUBPROCESS_TIMEOUT: "120"

- name: Run tests
# Disable MacOS for now - we do not yet officially support it and we need to invest a bit
# more efforts into investigating broken LAZ files written by Helios on MacOS.
if: runner.os != 'macOS'
# Do not run on MacOS for now - we do not yet officially support it and we need to invest a bit
# more efforts into investigating broken LAZ files written by Helios on MacOS.

- name: Run tests (incl. regression tests)
if: runner.os == 'Windows'
run: |
python -m pytest --regression-tests
- name: Run tests (excl. regression tests)
if: runner.os == 'Linux'
run: |
python -m pytest
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: github.event.inputs.upload-outputs == 'true'
with:
name: test-results
path: output/*
retention-days: 1
2 changes: 1 addition & 1 deletion data/surveys/demo/tls_arbaro_demo_angular_resolution.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<document>
<!-- Default scanner settings: -->
<scannerSettings id="profile1" active="true" pulseFreq_hz="100000" scanAngle_deg="100"/>
<survey name="arbaro_demo_tls" scene="data/scenes/demo/arbaro_demo.xml#arbaro_demo" platform="data/platforms.xml#tripod" scanner="data/scanners_tls.xml#riegl_vz400">
<survey name="arbaro_demo_tls_ang_res" scene="data/scenes/demo/arbaro_demo.xml#arbaro_demo" platform="data/platforms.xml#tripod" scanner="data/scanners_tls.xml#riegl_vz400">
<FWFSettings binSize_ns="0.2" beamSampleQuality="3" />
<leg>
<platformSettings x="-4.0" y="-2.5" onGround="true" />
Expand Down
3 changes: 3 additions & 0 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ dependencies:
- pytest
- laspy
- lazrs-python
- pandas
- scipy
- pooch
4 changes: 4 additions & 0 deletions pytests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import pytest


pytest.register_assert_rewrite("pytests.pcloud_utils")
61 changes: 61 additions & 0 deletions pytests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import os
import pathlib
import pooch
import pytest
import shutil


TEST_DATA_ARCHIVE = "https://github.com/dokempf/helios-test-data/releases/download/2024-08-29/data.tar.gz"
TEST_DATA_CHECKSUM = "df4490f41cd5f9e17fd794429ea7b2fa1f0ad58848b5df44199d24c820cb324b"


@pytest.fixture
def regression_data(request):
""" A fixture that ensures the existence of regression data
Returns the Path to where that data is located after (cached) download
from GitHub.
"""

if not request.config.getoption("--regression-tests"):
return None

# Define the cache location
cache = pooch.os_cache("helios")

# Trigger the download
pooch.retrieve(
TEST_DATA_ARCHIVE,
TEST_DATA_CHECKSUM,
path=cache,
downloader=pooch.HTTPDownloader(timeout=(3, None)),
processor=pooch.Untar(extract_dir="."),
)

return cache


@pytest.fixture(scope="session")
def output_dir(request):
dir = pathlib.Path(os.getcwd()) / "pytest-output"

yield dir

if request.config.getoption("--delete-output"):
shutil.rmtree(dir)


def pytest_addoption(parser):
parser.addoption(
"--regression-tests",
action="store_true",
default=False,
help="run regression tests",
)

parser.addoption(
"--delete-output",
action="store_true",
default=False,
help="run regression tests",
)
Loading

0 comments on commit 5c53c67

Please sign in to comment.