Skip to content

Commit b177c02

Browse files
committed
Introduce skipping for mpitests in case of MPI version incompatible with subprocess
1 parent a3ed25e commit b177c02

10 files changed

+35
-5
lines changed

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ markers = [
44
"skipif_missing_hdf5: skip test if NEST was built without HDF5 support",
55
"skipif_missing_mpi: skip test if NEST was built without MPI support",
66
"skipif_missing_threads: skip test if NEST was built without multithreading support",
7+
"skipif_incompatible_mpi: skip if NEST with built with MPI that does not work with subprocess",
78
"simulation: the simulation class to use. Always pass a 2nd dummy argument"
89
]
910

testsuite/pytests/conftest.py

+20
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def test_gsl():
3434
import dataclasses
3535
import os
3636
import pathlib
37+
import subprocess
3738
import sys
3839

3940
import nest
@@ -156,6 +157,25 @@ def have_plotting():
156157
return False
157158

158159

160+
@pytest.fixture(scope="session")
161+
def subprocess_compatible_mpi():
162+
"""Until at least OpenMPI 4.1.6, the following fails due to a bug in OpenMPI, from 5.0.7 is definitely safe."""
163+
164+
res = subprocess.run(["mpirun", "-np", "1", "echo"])
165+
return res.returncode == 0
166+
167+
168+
@pytest.fixture(autouse=True)
169+
def skipif_incompatible_mpi(request, subprocess_compatible_mpi):
170+
"""
171+
Globally applied fixture that skips tests marked to be skipped when MPI is
172+
not compatible with subprocess.
173+
"""
174+
175+
if not subprocess_compatible_mpi and request.node.get_closest_marker("skipif_incompatible_mpi"):
176+
pytest.skip("skipped because MPI is incompatible with subprocess")
177+
178+
159179
@pytest.fixture(autouse=True)
160180
def simulation_class(request):
161181
return getattr(request, "param", testsimulation.Simulation)

testsuite/pytests/sli2py_mpi/test_all_to_all.py

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727

2828
# Parametrization over the number of nodes here only to show hat it works
29+
@pytest.mark.skipif_incompatible_mpi
2930
@pytest.mark.parametrize("N", [4, 7])
3031
@MPITestAssertEqual([1, 4], debug=False)
3132
def test_all_to_all(N):

testsuite/pytests/sli2py_mpi/test_gap_junctions_mpi.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
# You should have received a copy of the GNU General Public License
2020
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
2121

22-
22+
import pytest
2323
from mpi_test_wrapper import MPITestAssertEqual
2424

2525

26+
@pytest.mark.skipif_incompatible_mpi
27+
@pytest.mark.skipif_missing_gsl
2628
@MPITestAssertEqual([1, 2, 4], debug=False)
2729
def test_gap_junctions_mpi():
2830
"""

testsuite/pytests/sli2py_mpi/test_issue_1957.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
# You should have received a copy of the GNU General Public License
2020
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
2121

22-
22+
import pytest
2323
from mpi_test_wrapper import MPITestAssertEqual
2424

2525

26+
@pytest.mark.skipif_incompatible_mpi
2627
@MPITestAssertEqual([2, 4])
2728
def test_issue_1957():
2829
"""

testsuite/pytests/sli2py_mpi/test_issue_2119.py

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
]
3333

3434

35+
@pytest.mark.skipif_incompatible_mpi
3536
@pytest.mark.parametrize(["kind", "specs"], random_params)
3637
@MPITestAssertEqual([1, 2, 4])
3738
def test_issue_2119(kind, specs):

testsuite/pytests/sli2py_mpi/test_issue_281.py

+2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
2121

2222

23+
import pytest
2324
from mpi_test_wrapper import MPITestAssertCompletes
2425

2526

27+
@pytest.mark.skipif_incompatible_mpi
2628
@MPITestAssertCompletes([1, 2, 4])
2729
def test_issue_281():
2830
"""

testsuite/pytests/sli2py_mpi/test_issue_600.py

+2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
2121

2222

23+
import pytest
2324
from mpi_test_wrapper import MPITestAssertEqual
2425

2526

27+
@pytest.mark.skipif_incompatible_mpi
2628
@MPITestAssertEqual([1, 2, 4], debug=False)
2729
def test_issue_600():
2830
"""

testsuite/pytests/sli2py_mpi/test_mini_brunel_ps.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
# You should have received a copy of the GNU General Public License
2020
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
2121

22-
22+
import pytest
2323
from mpi_test_wrapper import MPITestAssertEqual
2424

2525

26+
@pytest.mark.skipif_incompatible_mpi
2627
@MPITestAssertEqual([1, 2, 4])
2728
def test_mini_brunel_ps():
2829
"""

testsuite/pytests/sli2py_mpi/test_self_get_conns_with_empty_ranks.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
# You should have received a copy of the GNU General Public License
2020
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
2121

22-
import numpy as np
23-
import pandas
2422
import pytest
2523
from mpi_test_wrapper import MPITestAssertEqual
2624

2725

2826
# Parametrization over the number of nodes here only to show hat it works
27+
@pytest.mark.skipif_incompatible_mpi
2928
@MPITestAssertEqual([1, 2, 4], debug=False)
3029
def test_self_get_conns_with_empty_ranks():
3130
"""

0 commit comments

Comments
 (0)