-
Notifications
You must be signed in to change notification settings - Fork 109
Pytest integrated #3331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Pytest integrated #3331
Changes from all commits
a102ffe
a55dda0
053f62a
db34143
0ed0750
fdd93e0
f0b4405
4dd41cc
0fa8b81
f9e2374
d00629c
393ac3e
4deaf22
82ff7ca
681c2fb
01cc49c
09114fe
be04639
abe75f2
52436a8
f7378bc
5a959a2
e977ed6
9afb0b2
18b9c90
c55ab8f
125dd80
ede926e
cc47c24
79204e5
a4ebe18
fc99e0d
a961978
0e87bf4
869ba61
47a9596
7dbb5a7
8d87bda
e3bb3cd
c6e02eb
9b63aaf
e3e853c
0cfa087
27d8225
715babf
fe49bef
ada42eb
c0a1e2c
9be45a4
f8d07da
d81e62f
bcbd7d8
666835f
c748b9c
5c3488d
f8f83cc
13c3be5
68d0583
5eede91
f59b194
595b0b7
4fd9bc6
3a3c23b
f964b09
5069936
01f6c87
d08672f
2374566
cac189b
a429e6d
0c67687
b4bb8fc
4129021
10b1d82
534163b
e6a15ea
e0722af
93737b5
91aede7
1e8b9f2
72d1605
73d8b06
eb35e01
b30a71f
e820b8f
472d6fb
39b292f
3d92158
b9ad55c
95a5a04
a3d8a55
d58ba64
abd771d
a4d97ab
a104a82
dc2ac7b
2f0422e
75e3f7f
6392849
4bc9c67
f23ec42
3ad7e13
45041cb
04f4b92
41f7434
b0ebaa9
7e32a45
621fbe1
5a90ffa
478e2a4
9756e1d
241e790
ca85ceb
22ec152
cc5c273
4fc666d
74b5fa0
c99c2f5
0b3d631
45292e3
d44ec6a
585aaf7
ba32f9f
1e800fe
7b459b7
4681b19
7cefd0a
a48c093
94c11c8
07aa431
b22da30
e6f9cb7
3d19303
07d7add
dd003e5
b9841d1
2b9d46a
1953565
81631d5
ffa90b2
4fd66d7
4bca28c
a42bc36
3f99cce
7822ca9
a2e6bb4
6fceadd
bf5e02b
b28b5a5
8852248
82bbe9f
f72de98
a60fdc0
c2ef619
5af0f19
b5509a9
7b33082
7c4b0a9
b34d4fb
8389802
967bb07
9b87d16
e05bd51
30b5223
becb76c
a1c67ff
ec6a132
2f99557
8f13964
04c5837
0f47218
bbf2d4c
82c2ee3
bd2bd17
ea877d3
4e8a2cd
c428422
a3fdeab
c5e89cf
516c483
d834f9f
6a6c82e
a36dcdd
0c91d13
183346a
8f0131e
dd61eb3
e9c9f7d
38beaf4
d9db8dc
f75cf19
a59b93b
b6b4e1c
1780209
c3d5172
55c27c5
d6f135c
4fb5805
c193065
81f6d27
b43a1c4
a3d299d
7f920ac
2f0c1f5
dc38981
a9e2006
5704f8b
7123424
1996d27
0642f30
4c7e22a
8deac5b
4e7cb9d
2c384ef
70e341d
9577bbd
883083a
ec7fdd6
66a2c5c
c65424b
1f4c9e1
d0072e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,39 +133,48 @@ jobs: | |
| echo CMake options: ${{ matrix.config.cmake_options }} | ||
|
|
||
| - name: Install dependencies | ||
| run: sudo apt update && | ||
| sudo apt install -y | ||
| libfftw3-dev | ||
| libnetcdf-dev | ||
| libnetcdf-c++4-dev | ||
| netcdf-bin | ||
| python3 | ||
| python3-pip | ||
| python3-pytest | ||
| python3-numpy | ||
| python3-scipy | ||
| lcov | ||
| openmpi-bin | ||
| libopenmpi-dev | ||
| petsc-dev | ||
| slepc-dev | ||
| liblapack-dev | ||
| libparpack2-dev | ||
| libhypre-dev | ||
| run: | | ||
| sudo apt update | ||
| sudo apt install -y \ | ||
| libfftw3-dev \ | ||
| libnetcdf-dev \ | ||
| libnetcdf-c++4-dev \ | ||
| netcdf-bin \ | ||
| lcov \ | ||
| openmpi-bin \ | ||
| libopenmpi-dev \ | ||
| petsc-dev \ | ||
| slepc-dev \ | ||
| liblapack-dev \ | ||
| libparpack2-dev \ | ||
| libhypre-dev | ||
|
|
||
| - uses: actions/checkout@v6 | ||
| with: | ||
| submodules: true | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v5 | ||
| with: | ||
| enable-cache: true | ||
|
|
||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: '3.x' | ||
| cache: 'pip' | ||
|
|
||
| - name: Install pip packages | ||
| - name: Setup virtual environment with uv | ||
| run: | | ||
| python -m pip install --upgrade pip setuptools | ||
| python -m pip install -r requirements.txt | ||
| # uv sync automatically creates a .venv and installs the groups | ||
| uv sync --no-dev --group pytest --inexact | ||
|
|
||
| # Install the core requirements into the same venv | ||
| uv pip install -r requirements.txt | ||
|
Comment on lines
+170
to
+171
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Orthogonal PR -> this file should be merged into |
||
|
|
||
| # Put the venv in the PATH | ||
| echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH | ||
|
|
||
| # Force CMake to recognize the virtual environment | ||
| echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> $GITHUB_ENV | ||
|
|
||
| - name: Cache Zenodo test data | ||
| uses: actions/cache@v5 | ||
|
|
@@ -190,7 +199,9 @@ jobs: | |
| run: BUILD_ADIOS2=${{ matrix.config.build_adios2 }} ./.build_adios2_for_ci.sh | ||
|
|
||
| - name: Build BOUT++ | ||
| run: UNIT_ONLY=${{ matrix.config.unit_only }} ./.ci_with_cmake.sh ${{ matrix.config.cmake_options }} | ||
| run: | | ||
| UNIT_ONLY=${{ matrix.config.unit_only }} ./.ci_with_cmake.sh ${{ matrix.config.cmake_options }} \ | ||
| -DPython3_EXECUTABLE=$GITHUB_WORKSPACE/.venv/bin/python | ||
|
|
||
| Fedora: | ||
| # This is its own job as it doesn't use most of the steps of the | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,9 @@ requires = [] | |||||||||||||||||
| build-backend = "backend" | ||||||||||||||||||
| backend-path = ["tools/pylib/_boutpp_build/"] | ||||||||||||||||||
|
|
||||||||||||||||||
| [tool.pytest.ini_options] | ||||||||||||||||||
| console_output_style = "plain" | ||||||||||||||||||
|
|
||||||||||||||||||
| [dependency-groups] | ||||||||||||||||||
|
tomc271 marked this conversation as resolved.
|
||||||||||||||||||
| dev = [ | ||||||||||||||||||
| "cmake~=4.2", | ||||||||||||||||||
|
|
@@ -19,6 +22,10 @@ dev = [ | |||||||||||||||||
| "sphinx-lint~=1.0", | ||||||||||||||||||
| "sync-with-uv~=0.5.0", | ||||||||||||||||||
| ] | ||||||||||||||||||
| pytest = [ | ||||||||||||||||||
| "pytest~=8.4", | ||||||||||||||||||
| "pytest-xdist~=3.8", | ||||||||||||||||||
| ] | ||||||||||||||||||
|
Comment on lines
+25
to
+28
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add the other test dependencies here too?
Suggested change
|
||||||||||||||||||
| maint = [ | ||||||||||||||||||
| "pygithub~=2.8", | ||||||||||||||||||
| "ruamel-yaml~=0.19", | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import pytest | ||
| import shutil | ||
| import os | ||
| import subprocess | ||
| import time | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| def pytest_configure(config): | ||
| config.addinivalue_line( | ||
| "markers", | ||
| "serial: mark that the test should not be run concurrently with other. ", | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def test_dir(request) -> Path: | ||
| return Path(request.fspath).parent | ||
|
|
||
|
|
||
| @pytest.fixture(scope="function", autouse=True) | ||
| def copy_and_cwd_to_unique_tmp_dir(request, tmp_path_factory, monkeypatch): | ||
| """ | ||
| For each test function, create a unique temporary copy of the test directory | ||
| and change cwd to it. | ||
| """ | ||
|
|
||
| test_file_dir = Path(request.fspath).parent | ||
|
|
||
| if not test_file_dir.is_dir(): | ||
| pytest.fail(f"Expected test directory '{test_file_dir}' not found") | ||
|
|
||
| # Create a unique temp dir for this test | ||
| run_dir = tmp_path_factory.mktemp(test_file_dir.name) | ||
|
|
||
| # Copy the original test directory into it | ||
| shutil.copytree(test_file_dir, run_dir, dirs_exist_ok=True) | ||
|
|
||
| # Change working directory to the copy | ||
| monkeypatch.chdir(run_dir) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def assert_success_in_shell(test_dir): | ||
|
|
||
| def inner_function(command: str): | ||
| # MPI oversubscribe for communications test | ||
| os.environ["OMPI_MCA_rmaps_base_oversubscribe"] = "1" # Allows 18 procs | ||
| start = time.time() | ||
| result = subprocess.run( | ||
| command, shell=True, capture_output=True, text=True, timeout=600 | ||
| ) | ||
| elapsed = time.time() - start | ||
| assert result.returncode == 0, ( | ||
| f"Failed after {elapsed:.3f}s in {test_dir}\n" | ||
| f"Stderr: {result.stderr}\n" | ||
| f"Output: {result.stdout}" | ||
| ) | ||
|
|
||
| return inner_function |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.