Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
a102ffe
Use pytest rather than runtest as the command set in bout_add_integra…
tomchapman Oct 15, 2025
a55dda0
Rename runtest file to test-foo.py for each integrated test
tomchapman Nov 3, 2025
053f62a
Rename runtest file to test-foo.py for each MMS test
tomchapman Nov 3, 2025
db34143
Convert runtest file to use pytest for test_drift_instability
tomchapman Oct 9, 2025
0ed0750
Handle test files for tests named either `test-foo` or `foo`
tomchapman Nov 3, 2025
fdd93e0
Handle test files with hyphens or prefixed with
tomchapman Nov 3, 2025
f0b4405
Update symlink to renamed runtest file
tomchapman Nov 3, 2025
4dd41cc
Rename more runtest files
tomchapman Nov 3, 2025
0fa8b81
Change filename Test run by tpc522 on Mon Nov 3 17:45:34 2025
tomchapman Nov 3, 2025
f9e2374
Rename more runtest files
tomchapman Nov 3, 2025
d00629c
Use PATH-based pytest executable
tomchapman Nov 3, 2025
393ac3e
Fix more renamings
tomchapman Nov 3, 2025
4deaf22
Change custom_target check-integrated-tests to use pytest instead of …
tomchapman Nov 5, 2025
82ff7ca
Some `runtest` files are shell scripts not python scripts, so revert …
tomchapman Nov 5, 2025
681c2fb
Add python tests to run those `runtest` files that are not python scr…
tomchapman Nov 11, 2025
01cc49c
Convert test_cyclic.py to a valid pytest file
tomchapman Nov 11, 2025
09114fe
Convert several more test files to work with pytest
tomchapman Nov 12, 2025
be04639
Change directory before calling `boutpp.init()`
tomchapman Dec 17, 2025
abe75f2
Change directory before calling `boutpp.init()`
tomchapman Dec 17, 2025
52436a8
Change directory before calling `boutpp.Field3D.fromCollect()`
tomchapman Dec 17, 2025
f7378bc
Modify more test files for running via pytest
tomchapman Dec 17, 2025
5a959a2
MPI oversubscribe for communications test
tomchapman Dec 17, 2025
e977ed6
Change directory before removing files in `data` directory
tomchapman Dec 17, 2025
9afb0b2
Modify test_communications to run via pytest
tomchapman Dec 17, 2025
18b9c90
Modify test_delp2 to run via pytest
tomchapman Dec 18, 2025
c55ab8f
Modify test_fci_boundary to run via pytest
tomchapman Dec 18, 2025
125dd80
Modify test_fieldgroupcomm to run via pytest
tomchapman Dec 18, 2025
ede926e
Modify test_gyro to run via pytest
tomchapman Dec 18, 2025
cc47c24
Modify test_interpolate to run via pytest
tomchapman Dec 18, 2025
79204e5
Modify test_multigrid_laplace to run via pytest
tomchapman Dec 28, 2025
a4ebe18
Modify test_laplace to run via pytest
tomchapman Dec 28, 2025
fc99e0d
Modify test_interpolate_z to run via pytest
tomchapman Dec 28, 2025
a961978
Modify test_interchange_instability to run via pytest
tomchapman Dec 28, 2025
0e87bf4
Modify test_naulin_laplace to run via pytest
tomchapman Dec 28, 2025
869ba61
Modify test_options_netcdf to run via pytest
tomchapman Dec 28, 2025
47a9596
Modify test_restart_io to run via pytest
tomchapman Dec 28, 2025
7dbb5a7
Modify test_restarting to run via pytest
tomchapman Dec 28, 2025
8d87bda
Modify test_smooth to run via pytest
tomchapman Dec 28, 2025
e3bb3cd
Modify test_squash to run via pytest
tomchapman Dec 28, 2025
c6e02eb
Add conftest.py, with contextmanager `chdir` and fixture `test_dir`
tomchapman Dec 30, 2025
9b63aaf
Use contextmanager `chdir` in tests
tomchapman Dec 30, 2025
e3e853c
Use monkeypatch.chdir() fixture instead of contextmanager
tomchapman Dec 30, 2025
0cfa087
Modify test_twistshift to run via pytest
tomchapman Dec 30, 2025
27d8225
Modify test_twistshift_staggered to run via pytest
tomchapman Dec 30, 2025
715babf
Modify test_vec to run via pytest
tomchapman Dec 30, 2025
fe49bef
Add `OMPI_MCA_rmaps_base_oversubscribe` environment variable in test_…
tomchapman Dec 30, 2025
ada42eb
Modify test_stopCheck_file to run via pytest
tomchapman Dec 30, 2025
c0a1e2c
Modify test_yupdown_weights to run via pytest
tomchapman Dec 30, 2025
9be45a4
Modify test_griddata_yboundary_guards to run via pytest
tomchapman Dec 30, 2025
f8d07da
Use monkeypatch.chdir() fixture instead of contextmanager
tomchapman Jan 3, 2026
d81e62f
Remove build_and_log() calls
tomchapman Jan 3, 2026
bcbd7d8
Copy conftest.py when building
tomchapman Jan 3, 2026
666835f
Correct assert statement in test_boutpp_collect_staggered
tomchapman Jan 3, 2026
c748b9c
Now have a fixture that handles changing the working directory for ea…
tomchapman Jan 3, 2026
5c3488d
Fix "Copy conftest.py when building"
tomchapman Jan 4, 2026
f8f83cc
Add `finalize_boutpp` fixture, and mark relevant tests with a `boutpp…
tomchapman Jan 4, 2026
13c3be5
Add `finalize_boutpp` fixture, and mark relevant tests with a `boutpp…
tomchapman Jan 4, 2026
68d0583
Add fixture `xdist_each` for boutpp tests
tomchapman Jan 4, 2026
5eede91
Add fixture `make_dir_and_copy_input`
tomchapman Jan 4, 2026
f59b194
Rename `make_dir_and_copy_input` fixture to `copy_data_directory`
tomchapman Jan 4, 2026
595b0b7
Add pytest marker `input_dir`
tomchapman Jan 4, 2026
4fd9bc6
Fix testDirectoryArgumentNonDirectory
tomchapman Jan 4, 2026
3a3c23b
Mark more tests with `input_dir`
tomchapman Jan 4, 2026
f964b09
Combine fixtures `cwd_to_test_file_dir` and `copy_data_directory` int…
tomchapman Jan 5, 2026
5069936
Mark test_boutpp_collect with input_dir(name="input")
tomchapman Jan 5, 2026
01f6c87
`finalize_boutpp` fixture not needed now that using xdist_group
tomchapman Jan 5, 2026
d08672f
Copy and cwd to tmp_dir
tomchapman Jan 5, 2026
2374566
Fix test_datafile_facade
tomchapman Jan 5, 2026
cac189b
Fix assert in test_invpar
tomchapman Jan 7, 2026
a429e6d
Remove input_dir(name="input") markers
tomchapman Jan 7, 2026
0c67687
Restore CMake copying `runtest` files
tomchapman Jan 5, 2026
b4bb8fc
Use tmp_path_factory to ensure a unique temp dir for each test
tomchapman Jan 5, 2026
4129021
Don't change to test directory now that there is a fixture that switc…
tomchapman Jan 5, 2026
10b1d82
Fix CMakeLists.txt for test-fci-boundary
tomchapman Jan 23, 2026
534163b
Add newline at end of file
tomchapman Jan 23, 2026
e6a15ea
Don't change to test directory now that there is a fixture that switc…
tomchapman Jan 23, 2026
e0722af
Copy test-boutpp/conftest.py when building
tomchapman Jan 23, 2026
93737b5
Add missing fixture argument `test_dir`
tomchapman Jan 26, 2026
91aede7
Add run_integrated_tests.sh
tomchapman Jan 26, 2026
1e8b9f2
Fix addinivalue_line "serial" in `pytest_configure` hook
tomchapman Jan 28, 2026
72d1605
Remove ini value for `input_dir` mark in `pytest_configure` hook
tomchapman Jan 28, 2026
73d8b06
Copy tests/run_integrated_tests.sh when building
tomchapman Feb 4, 2026
eb35e01
Modify test_laplace_petsc3d to run via pytest
tomchapman Feb 9, 2026
b30a71f
Use pathlib instead of os.path
tomchapman Feb 10, 2026
e820b8f
Revert "Use pytest rather than runtest as the command set in bout_add…
tomchapman Feb 10, 2026
472d6fb
Copy `runtest` file even if not `USE_RUNTEST`
tomchapman Feb 10, 2026
39b292f
Extract duplicated code to a fixture `run_in_terminal`
tomchapman Feb 11, 2026
3d92158
Path.exists() takes a Path object
tomchapman Feb 11, 2026
b9ad55c
Always copy test file when building
tomchapman Feb 11, 2026
95a5a04
Handle parsing test name for those already prefixed with "test_"
tomchapman Feb 11, 2026
a3d8a55
Fix test_beuler and test_solver
tomchapman Feb 11, 2026
d58ba64
Refactor fixture `assert_success_in_shell` to return a function
tomchapman Feb 11, 2026
abd771d
Modify test-fci-mpi to run via pytest
tomchapman Mar 2, 2026
a4d97ab
Modify test-subdir to run via pytest
tomchapman Mar 2, 2026
a104a82
Modify test_globalfield to run via pytest
tomchapman Mar 2, 2026
dc2ac7b
Modify test_integrate to run via pytest
tomchapman Mar 2, 2026
2f0422e
Modify test_laplacexy_fv to run via pytest
tomchapman Mar 2, 2026
75e3f7f
Modify test_laplace2 to run via pytest
tomchapman Mar 2, 2026
6392849
Modify test_laplacexy to run via pytest
tomchapman Mar 2, 2026
4bc9c67
Modify test_laplace_hypre3d to run via pytest
tomchapman Mar 2, 2026
f23ec42
Modify test_invertable_operator to run via pytest
tomchapman Mar 2, 2026
3ad7e13
Correct function name `test_fci_mpi()`
tomchapman Mar 2, 2026
45041cb
Modify test_collect to run via pytest
tomchapman Mar 2, 2026
04f4b92
Modify test_dataformat to run via pytest
tomchapman Mar 2, 2026
41f7434
Remove obsolete scripts for running tests via autotools
tomchapman Mar 2, 2026
b0ebaa9
Fix merge error.
tomchapman Mar 2, 2026
7e32a45
Modify test_laplacexy2_hypre to run via pytest
tomchapman Mar 2, 2026
621fbe1
Modify test_petsc_laplace to run via pytest
tomchapman Mar 2, 2026
5a90ffa
Modify test_petsc_laplace_MAST_grid to run via pytest
tomchapman Mar 2, 2026
478e2a4
Modify test_region_iterator to run via pytest
tomchapman Mar 2, 2026
9756e1d
Remove unused import
tomchapman Mar 3, 2026
241e790
Fix CMakeLists.txt for `test_fci_mpi`
tomchapman Mar 3, 2026
ca85ceb
Fix test_backtrace
tomchapman Mar 4, 2026
22ec152
Convert test_boutpp_print to from a shell script to python
tomchapman Mar 13, 2026
cc5c273
Skip test_fci_boundary if zoidberg not found
tomchapman Mar 13, 2026
4fc666d
Add boutpp location to PYTHONPATH before running pytest
tomchapman Mar 13, 2026
74b5fa0
Pass through to pytest additional arguments given to run_integrated_t…
tomchapman Mar 13, 2026
c99c2f5
Fix test_boutpp_print (don't split msg)
tomchapman Mar 13, 2026
0b3d631
Set absolute path to boupp in PYTHONPATH
tomchapman Mar 14, 2026
45292e3
Add the pytest option console_output_style = "plain" to pyproject.toml
tomchapman Mar 14, 2026
d44ec6a
Copy pyproject.toml file when building
tomchapman Mar 14, 2026
585aaf7
Pre-build the project to prevent concurrent CMake race conditions
tomchapman Mar 14, 2026
ba32f9f
Fix copying the pyproject.toml file
tomchapman Mar 14, 2026
1e800fe
add quiet option to pytest command, to prevent concurrent console out…
tomchapman Mar 14, 2026
7b459b7
Use the absolute path to the `integrated` directory
tomchapman Mar 14, 2026
4681b19
Refactor run_integrated_tests.sh (to use `PROJECT_ROOT`)
tomchapman Mar 14, 2026
7cefd0a
Revert rename of MMS `runtest` files
tomchapman Mar 17, 2026
a48c093
Revert inclusion of MMS tests when copying test files to build
tomchapman Mar 17, 2026
94c11c8
Make cmake test file copying apply only to integrated tests
tomchapman Mar 17, 2026
07aa431
Revert "Rename runtest file to test-foo.py for each MMS test"
tomchapman Mar 17, 2026
b22da30
Revert "Change filename Test run by tpc522 on Mon Nov 3 17:45:34 2025"
tomchapman Mar 17, 2026
e6f9cb7
Convert test_laplacexy_short to run via pytest
tomchapman Mar 17, 2026
3d19303
Convert test_laplacexz to run via pytest
tomchapman Mar 17, 2026
07d7add
Convert test_slepc_solver to run via pytest
tomchapman Mar 17, 2026
dd003e5
Only copy test files if test has not been skipped
tomchapman Mar 17, 2026
b9841d1
Update .ci_with_cmake.sh to use the cmake target that correctly handl…
tomchapman Mar 18, 2026
2b9d46a
Update the command set in BOUT++functions.cmake to make ctest use pyt…
tomchapman Mar 18, 2026
1953565
Let cmake's configure_file command insert the build directory path in…
tomchapman Mar 24, 2026
81631d5
Fix rebase errors
tomchapman Mar 27, 2026
ffa90b2
Revert "Rename runtest file to test-foo.py for each MMS test"
tomchapman Mar 28, 2026
4fd66d7
Add pytest to requirements.txt
tomchapman Mar 28, 2026
4bca28c
Add boutpp location to PYTHONPATH when launching pytest through cmake…
tomchapman Mar 28, 2026
a42bc36
Fix test_laplace after rebase
tomchapman Mar 28, 2026
3f99cce
Use BOUT_PYTHONPATH instead of PROJECT_BINARY_DIR
tomchapman Mar 28, 2026
7822ca9
Make check-integrated-tests target just run the `run_integrated_tests…
tomchapman Mar 28, 2026
a2e6bb4
Don't rely on BOUT_PYTHONPATH, as not available always
tomchapman Mar 28, 2026
6fceadd
Remove unused boutpp import from conftest.py
tomchapman Mar 28, 2026
bf5e02b
Add pytest-xdist to requirements.txt
tomchapman Mar 28, 2026
b28b5a5
Fix pytest command not found in CI by using `python3 -m pytest`
tomchapman Mar 28, 2026
8852248
Use the Python executable that CMake discovered during configuration
tomchapman Mar 28, 2026
82bbe9f
Add OpenMPI oversubscription overrides
tomchapman Apr 15, 2026
f72de98
Install pytest in fedora ci script
tomchapman Apr 15, 2026
a60fdc0
Add pytest and pytest-xdist to pyproject.toml
tomchapman Apr 25, 2026
c2ef619
Use uv sync instead of pip install, in github `tests` workflow
tomchapman Apr 25, 2026
5af0f19
Add no-install-project option to uv command
tomchapman Apr 25, 2026
b5509a9
Add no-dev option to uv command in github workflow
tomchapman Apr 25, 2026
7b33082
Install python, pip, pytest, numpy, and scipy through uv
tomchapman Apr 26, 2026
7c4b0a9
Set VIRTUAL_ENV to force CMake to recognize the virtual environment
tomchapman Apr 26, 2026
b34d4fb
Pass DPython3_EXECUTABLE to cmake script, to force it to use the venv
tomchapman Apr 26, 2026
8389802
Install the core requirements
tomchapman Apr 26, 2026
967bb07
Remove numpy and scipy from pytest dependency-group in pyproject.toml
tomchapman Apr 27, 2026
9b87d16
Merge branch 'uv-for-pytest' into pytest-integrated
tomchapman Apr 27, 2026
e05bd51
Reinstate timeout for tests
tomchapman Apr 24, 2026
30b5223
Simplify `Path.exists()` expressions
tomchapman Apr 27, 2026
becb76c
Remove previously deleted test
tomchapman Apr 28, 2026
a1c67ff
Prefer numpy.testing.assert_allclose
tomchapman Apr 24, 2026
9ff2e14
Add fail-fast option to run_integrated_tests.sh
tomchapman Apr 28, 2026
235c524
Add autouse fixture to call boutpp.finalise()
tomchapman Apr 28, 2026
0917c92
Fix test_fci_boundary
tomchapman Apr 28, 2026
87931a7
Run pytest verbosely when CI flag is true
tomchapman Apr 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .ci_fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ test . != ".$1" && mpi="$1" || mpi=openmpi
cp -a /tmp/BOUT-dev /home/test/
. /etc/profile.d/modules.sh
module load mpi/${1}-x86_64
export OMPI_MCA_rmaps_base_oversubscribe=yes
sudo dnf install -y python3-pytest
# OpenMPI Oversubscription Overrides
export OMPI_MCA_rmaps_base_oversubscribe=1
export OMPI_MCA_hwloc_base_binding_policy=none
export OMPI_MCA_rmaps_base_mapping_policy=core:OVERSUBSCRIBE
export PRTE_MCA_rmaps_default_mapping_policy=core:OVERSUBSCRIBE
export PRTE_MCA_rmaps_default_mapping_policy=:oversubscribe
export TRAVIS=true
# Try limiting openmp threads
Expand Down
2 changes: 1 addition & 1 deletion .ci_with_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fi

cmake --build build --target build-check -j 2
cd build
ctest --output-on-failure --timeout 300
cmake --build . --target check
Comment thread
tomc271 marked this conversation as resolved.

export LD_LIBRARY_PATH=/home/runner/local/lib:$LD_LIBRARY_PATH

Expand Down
59 changes: 35 additions & 24 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

# 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
Expand All @@ -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
Expand Down
26 changes: 24 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ option(
OFF
)
if(BOUT_TESTS)
set(CMAKE_CTEST_ARGUMENTS "--output-on-failure" "--timeout" "300")
enable_testing()
# Targets for just building the tests
# Tests need to add themselves as dependencies to these targets
Expand All @@ -765,8 +766,8 @@ if(BOUT_TESTS)
add_dependencies(check-unit-tests build-check-unit-tests)
endif()

add_custom_target(
check-integrated-tests COMMAND ctest -R "test-" --output-on-failure
add_custom_target(check-integrated-tests
COMMAND bash "${PROJECT_BINARY_DIR}/tests/run_integrated_tests.sh"
)
add_dependencies(check-integrated-tests build-check-integrated-tests)

Expand All @@ -780,6 +781,27 @@ if(BOUT_TESTS)
add_dependencies(check check-unit-tests)
endif()

# Copy the pytest config file
configure_file(
"${PROJECT_SOURCE_DIR}/tests/conftest.py"
"${PROJECT_BINARY_DIR}/tests/conftest.py")

# Copy the pyproject.toml file
configure_file(
"${PROJECT_SOURCE_DIR}/pyproject.toml"
"${PROJECT_BINARY_DIR}/pyproject.toml")

# Copy the pytest config file for the boutpp tests
configure_file(
"${PROJECT_SOURCE_DIR}/tests/integrated/test-boutpp/conftest.py"
"${PROJECT_BINARY_DIR}/tests/integrated/test-boutpp/conftest.py")

# Copy the pytest shell script
configure_file(
"${PROJECT_SOURCE_DIR}/tests/run_integrated_tests.sh"
"${PROJECT_BINARY_DIR}/tests/run_integrated_tests.sh"
@ONLY)

endif()

option(BOUT_BUILD_EXAMPLES "Build the examples" ON)
Expand Down
29 changes: 24 additions & 5 deletions cmake/BOUT++functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ endfunction()
#
function(bout_add_integrated_or_mms_test BUILD_CHECK_TARGET TESTNAME)
set(options USE_RUNTEST USE_DATA_BOUT_INP)
set(oneValueArgs EXECUTABLE_NAME PROCESSORS DOWNLOAD DOWNLOAD_NAME)
set(oneValueArgs EXECUTABLE_NAME PROCESSORS DOWNLOAD DOWNLOAD_NAME PYTHON_TEST_FILE)
set(multiValueArgs SOURCES EXTRA_FILES REQUIRES CONFLICTS TESTARGS
EXTRA_DEPENDS
)
Expand Down Expand Up @@ -254,16 +254,26 @@ function(bout_add_integrated_or_mms_test BUILD_CHECK_TARGET TESTNAME)

# Set the actual test command
if(BOUT_TEST_OPTIONS_USE_RUNTEST)
add_test(NAME ${TESTNAME} COMMAND ./runtest ${BOUT_TEST_OPTIONS_TESTARGS})
if(BOUT_TEST_OPTIONS_PYTHON_TEST_FILE)
# It's an integrated test with a specific python file
add_test(NAME ${TESTNAME} COMMAND pytest ${BOUT_TEST_OPTIONS_PYTHON_TEST_FILE} ${BOUT_TEST_OPTIONS_TESTARGS})
else()
# It's an MMS test still using the 'runtest' script
add_test(NAME ${TESTNAME} COMMAND ./runtest ${BOUT_TEST_OPTIONS_TESTARGS})
endif()

set_tests_properties(
${TESTNAME} PROPERTIES ENVIRONMENT
PYTHONPATH=${BOUT_PYTHONPATH}:$ENV{PYTHONPATH}
)
bout_copy_file(runtest)
else()
add_test(NAME ${TESTNAME} COMMAND ${TESTNAME} ${BOUT_TEST_OPTIONS_TESTARGS})
endif()

if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/runtest)
bout_copy_file(runtest)
endif()

set_tests_properties(
${TESTNAME} PROPERTIES PROCESSORS ${BOUT_TEST_OPTIONS_PROCESSORS}
PROCESSOR_AFFINITY ON
Expand All @@ -284,11 +294,20 @@ endfunction()

# Add a new integrated test. See `bout_add_integrated_or_mms_test` for arguments
function(bout_add_integrated_test TESTNAME)
# Construct the Python test filename
string(REGEX REPLACE "^(test-)?(.+)$" "test_\\2.py" TEST_FILENAME "${TESTNAME}")
string(REPLACE "-" "_" TEST_FILENAME "${TEST_FILENAME}")
string(REPLACE "test_test_" "test_" TEST_FILENAME "${TEST_FILENAME}")

bout_add_integrated_or_mms_test(
build-check-integrated-tests ${TESTNAME} ${ARGV}
build-check-integrated-tests ${TESTNAME} PYTHON_TEST_FILE ${TEST_FILENAME} ${ARGV}
)
endfunction()

# Only copy the file if the test wasn't skipped due to missing requirements
if(TARGET ${TESTNAME})
bout_copy_file(${TEST_FILENAME})
endif()
endfunction()
# Add a new MMS test. See `bout_add_integrated_or_mms_test` for arguments
function(bout_add_mms_test TESTNAME)
bout_add_integrated_or_mms_test(build-check-mms-tests ${TESTNAME} ${ARGV})
Expand Down
2 changes: 1 addition & 1 deletion manual/sphinx/developer_docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ install the majority of our developer tools at once using `uv

.. code-block:: console
uv sync --only-dev --inexact
uv sync --only-dev --group pytest --inexact
This will install all the developer tools into a virtual environment (creating
one if necessary, typically under ``.venv``). You can then activate the virtual
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ requires = []
build-backend = "backend"
backend-path = ["tools/pylib/_boutpp_build/"]

[tool.pytest.ini_options]
console_output_style = "plain"

[dependency-groups]
Comment thread
tomc271 marked this conversation as resolved.
dev = [
"cmake~=4.2",
Expand All @@ -19,6 +22,10 @@ dev = [
"sphinx-lint~=1.0",
"sync-with-uv~=0.5.0",
]
pytest = [
"pytest~=8.4",
"pytest-xdist~=3.8",
]
maint = [
"pygithub~=2.8",
"ruamel-yaml~=0.19",
Expand Down
54 changes: 54 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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
41 changes: 0 additions & 41 deletions tests/integrated/test-backtrace/runtest

This file was deleted.

23 changes: 23 additions & 0 deletions tests/integrated/test-backtrace/test_backtrace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
import pytest
# Test enabling/disabling exception backtrace from environment variable

# requires all_tests

from boututils.run_wrapper import shell
import os


def test_backtrace():
try:
del os.environ["BOUT_SHOW_BACKTRACE"]
except KeyError:
pass

_, output = shell(["BOUT_SHOW_BACKTRACE=0 ./boutexcept"], pipe=True)

assert "troublemaker" not in output, f"Fail: detected offending function name in output when not expected\n{output}"

_, output = shell(["./boutexcept"], pipe=True)

assert "troublemaker" in output, f"Fail: did not detect offending function name in output when expected\n{output}"
23 changes: 0 additions & 23 deletions tests/integrated/test-beuler/runtest

This file was deleted.

Loading
Loading