From 6ce2fa050b800e0814833cddc2a128559bacffc5 Mon Sep 17 00:00:00 2001 From: David Ogden <12831266+dav-og@users.noreply.github.com> Date: Thu, 3 Dec 2026 23:26:32 +0000 Subject: [PATCH 1/3] Report the demo feature test as skipped when pytest skips part of it. test_demo_features.py exited with 0 when pytest skipped some of its tests, so the MHKiT writer tests were left out without a trace wherever MHKiT is not installed, including continuous integration. Run as a script, it now returns the skip code when any test was skipped. The Chrono jobs install MHKiT from the requirements file of the demo feature tools, so all of its tests run. --- .github/workflows/ci.yml | 15 +++++++++++---- tests/README.md | 2 +- tests/unit/CMakeLists.txt | 4 ++-- tests/unit/python/test_demo_features.py | 25 ++++++++++++++++++++++--- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2ac3ef..09fe9eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -213,11 +213,14 @@ jobs: echo "CMAKE_BUILD_PARALLEL_LEVEL=3" } >> "${GITHUB_ENV}" - # pytest runs tests/unit/python/test_demo_features.py, which is skipped without it. + # tests/unit/python/test_demo_features.py runs under pytest and tests the + # demo feature tools, which need MHKiT. It reports itself as skipped when + # pytest is missing or when pytest skips any of its tests. - name: Install Python packages run: | python3 -m pip install --requirement tests/regression/run_seastack/requirements.txt python3 -m pip install pytest + python3 -m pip install --requirement data/demos/run_seastack/features/requirements.txt - name: Record the environment run: | @@ -236,7 +239,7 @@ jobs: echo "ninja $(ninja --version)" c++ --version | head -n 1 python3 --version - python3 -m pip list --format=freeze | grep -i -E '^(numpy|h5py|pyyaml|matplotlib|pytest)==' + python3 -m pip list --format=freeze | grep -i -E '^(numpy|h5py|pyyaml|matplotlib|pytest|mhkit|scipy|pandas|ruamel\.yaml)==' echo "OMP_NUM_THREADS=${OMP_NUM_THREADS} CTEST_JOBS=${CTEST_JOBS} FULL_SUITES=${FULL_SUITES}" echo "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:-}" git log -1 --format='Source: %H %s' @@ -626,12 +629,16 @@ jobs: path: ${{ steps.deps.outputs.archives }} key: ${{ steps.vcpkg-cache.outputs.cache-primary-key }} - # pytest runs tests/unit/python/test_demo_features.py, which is skipped without it. + # tests/unit/python/test_demo_features.py runs under pytest and tests the + # demo feature tools, which need MHKiT. It reports itself as skipped when + # pytest is missing or when pytest skips any of its tests. - name: Install Python packages run: | python -m pip install --requirement tests/regression/run_seastack/requirements.txt if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } python -m pip install pytest + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + python -m pip install --requirement data/demos/run_seastack/features/requirements.txt - name: Record the environment run: | @@ -644,7 +651,7 @@ jobs: "ninja $(ninja --version)" "MSVC tools $env:VCToolsVersion" python --version - python -m pip list --format=freeze | Select-String -Pattern '^(numpy|h5py|pyyaml|matplotlib|pytest)==' | ForEach-Object { $_.Line } + python -m pip list --format=freeze | Select-String -Pattern '^(numpy|h5py|pyyaml|matplotlib|pytest|mhkit|scipy|pandas|ruamel\.yaml)==' | ForEach-Object { $_.Line } "OMP_NUM_THREADS=$env:OMP_NUM_THREADS CTEST_JOBS=$env:CTEST_JOBS FULL_SUITES=$env:FULL_SUITES" git log -1 --format='Source: %H %s' diff --git a/tests/README.md b/tests/README.md index b9025d4..83e6ff3 100644 --- a/tests/README.md +++ b/tests/README.md @@ -69,7 +69,7 @@ GitHub Actions builds and tests SEA-Stack on Linux, macOS and Windows ([`.github The Chrono job also runs the **full suites** (verification, comparison, long regression, the demo cases through `run_tests.py --all` and `--extended`, and the benchmarks) every night on `dev`, on a manual run of the workflow, and on a pull request that carries the label `full-tests`. - **Threads:** two tests run at a time, each with `OMP_NUM_THREADS=2`. -- **Skipped tests fail the run.** CTest exits with 0 when a test returns its skip code, for example when a Python package is missing; `scripts/ci/check_ctest_junit.py` reads the JUnit report of each suite and fails unless every test ran and passed. The suite scripts write that report with `--junit FILE` (Unix) or `-Junit FILE` (Windows). +- **Skipped tests fail the run.** CTest exits with 0 when a test returns its skip code, for example when a Python package is missing; `scripts/ci/check_ctest_junit.py` reads the JUnit report of each suite and fails unless every test ran and passed. The suite scripts write that report with `--junit FILE` (Unix) or `-Junit FILE` (Windows). `test_demo_features_python` runs under pytest and returns the skip code when pytest skips any of its tests, so the Chrono jobs install MHKiT from `data/demos/run_seastack/features/requirements.txt`. - **Benchmarks do not fail the run.** Timings on shared runners are for information only. - **Results:** each job uploads its JUnit reports and logs. The page of a workflow run shows each report's table of checks against limits for every platform. - **PDF reports:** the artifact `test-reports` holds the reports of all three platforms as PDF, in the folders `linux`, `macos` and `windows`, with the figures resampled to 150 dpi for reading on screen. The regression reports are in every run; the verification and comparison reports come with the full suites. The Chrono jobs write the reports as Markdown, and a final job converts them on Linux, where pandoc and LaTeX are installed. diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 5a2bf3e..1cc2838 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -425,8 +425,8 @@ if(TARGET seastack_external) endif() endif() -# Demo feature tools (h5_reader.py, MHKiT_writer.py). Writer tests skip -# without MHKiT; exit code 77 = pytest not installed. +# Demo feature tools (h5_reader.py, MHKiT_writer.py). Exit code 77 = pytest +# not installed, or pytest skipped a test (the writer tests without MHKiT). find_package(Python3 COMPONENTS Interpreter QUIET) if(Python3_FOUND) add_test(NAME test_sampled_history diff --git a/tests/unit/python/test_demo_features.py b/tests/unit/python/test_demo_features.py index e557fd2..7c2fd00 100644 --- a/tests/unit/python/test_demo_features.py +++ b/tests/unit/python/test_demo_features.py @@ -5,8 +5,9 @@ ruamel.yaml, PyYAML). Its tests are skipped when MHKiT is not installed; nothing here downloads NDBC data. -Run with pytest, or as a script (CTest): exit code 77 means pytest is -missing and the test is skipped. +Run with pytest, or as a script (CTest). As a script, exit code 77 means that +pytest is missing or that pytest skipped at least one test; CTest then reports +the test as skipped, not as passed. Analytic references: - Significant wave height Hm0 = 4 * sqrt(m0), m0 = integral S(f) df. @@ -294,5 +295,23 @@ def test_writer_spectrum_file_end_to_end(writer, tmp_path): assert list((case / "outputs").glob("results*.h5")), "run_seastack wrote no results file" +class _SkipRecorder: + """pytest plugin: collects the tests that were skipped.""" + + def __init__(self): + self.skipped = [] + + def pytest_runtest_logreport(self, report): + if report.skipped: + self.skipped.append(report.nodeid) + + if __name__ == "__main__": - sys.exit(pytest.main([__file__, "-q", "-rs"])) + recorder = _SkipRecorder() + status = pytest.main([__file__, "-q", "-rs"], plugins=[recorder]) + if status == 0 and recorder.skipped: + # A run that left tests out must not count as passed: report it to + # CTest as skipped (SKIP_RETURN_CODE). + print(f"{len(recorder.skipped)} test(s) skipped; reporting test_demo_features as skipped") + sys.exit(77) + sys.exit(status) From f1181eacc3488f65bf80d0453a59fbcab454da6e Mon Sep 17 00:00:00 2001 From: David Ogden <12831266+dav-og@users.noreply.github.com> Date: Thu, 3 Dec 2026 23:26:33 +0000 Subject: [PATCH 2/3] Prepend the DLL directories to the PATH of the Windows unit tests. The test environment was set as "PATH=