Skip to content

Commit

Permalink
Use full-suite conditional params in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
MTCam committed Nov 2, 2024
1 parent 3de6f13 commit e743d0e
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 26 deletions.
32 changes: 32 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pytest
import os

# Global FULL_SUITE flag to control which parameter sets are used
FULL_SUITE = None

def pytest_addoption(parser):
"""Add the --full-suite command-line option for pytest."""
parser.addoption(
"--full-suite", action="store_true", default=False, help="Run the full test suite"
)

def pytest_configure(config):
"""Set the FULL_SUITE flag based on --full-suite option or environment variable."""
global FULL_SUITE
FULL_SUITE = config.getoption("--full-suite") or os.getenv("FULL_TESTS") == "1"


def conditional_parametrize(argnames, quick_params, full_params):
"""Decorator for conditional parameterization based on FULL_SUITE flag."""
def decorator(func):
if FULL_SUITE:
return pytest.mark.parametrize(argnames, full_params)(func)
else:
return pytest.mark.parametrize(argnames, quick_params)(func)
return decorator


def conditional_value(quick_value, full_value):
if FULL_SUITE:
return quick_value
return full_value
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[pytest]
markers =
octave: test requires Octave
full: Mark tests to be included in the full suite of tests
quick: Mark tests to be included in the quick suite of tests

65 changes: 39 additions & 26 deletions test/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
as_dofdesc
)
from sympy import cos, acos, symbols, integrate, simplify # type: ignore
from conftest import conditional_parametrize, conditional_value

sys.path.append(os.path.dirname(__file__))
import mesh_data # noqa: E402 # type: ignore # pylint: disable=import-error
Expand Down Expand Up @@ -227,32 +228,44 @@ def central_flux_boundary(actx, dcoll, soln_func, dd_bdry):
return op.project(dcoll, bnd_tpair.dd, dd_allfaces, flux_weak)


# (2, "tet_box2_rot", np.array([0, 0, 1]), False),
# (3, "tet_box3_rot1", np.array([0, 0, 1]), False),
# (3, "tet_box3_rot2", np.array([0, 1, 1]), False),
# (2, "hex_box2_rot", np.array([0, 0, 1]), False),
# (3, "hex_box3_rot1", np.array([0, 0, 1]), False),
# (3, "hex_box3_rot2", np.array([0, 1, 1]), False),
# @pytest.mark.parametrize("order", [1, 2, 3])
@pytest.mark.parametrize(("dim", "mesh_name", "rot_axis", "wonk"),
@conditional_parametrize(("dim", "mesh_name", "rot_axis", "wonk"),
[(1, "tet_box1", None, False),
(2, "tet_box2", None, False),
(3, "tet_box3", None, False),
(2, "hex_box2", None, False),
(3, "hex_box3", None, False),
(3, "tet_box3_rot3", np.array([1, 1, 1]), False),
(3, "hex_box3_rot3", np.array([1, 1, 1]), False),
],
[(1, "tet_box1", None, False),
(2, "tet_box2", None, False),
(3, "tet_box3", None, False),
(2, "hex_box2", None, False),
(3, "hex_box3", None, False),
(3, "tet_box3_rot3", np.array([1, 1, 1]), False),
(3, "hex_box3_rot3", np.array([1, 1, 1]), False),
(2, "tet_box2_rot", np.array([0, 0, 1]), False),
(3, "tet_box3_rot1", np.array([0, 0, 1]), False),
(3, "tet_box3_rot2", np.array([0, 1, 1]), False),
(2, "hex_box2_rot", np.array([0, 0, 1]), False),
(3, "hex_box3_rot1", np.array([0, 0, 1]), False),
(3, "hex_box3_rot2", np.array([0, 1, 1]), False),
])
@conditional_parametrize("order", [2], [1, 2, 3])
@conditional_parametrize("sym_test_func_factory",
[
(1, "tet_box1", None, False),
(2, "tet_box2", None, False),
(3, "tet_box3", None, False),
(2, "hex_box2", None, False),
(3, "hex_box3", None, False),
(3, "tet_box3_rot3", np.array([1, 1, 1]), False),
(3, "hex_box3_rot3", np.array([1, 1, 1]), False),
])
@pytest.mark.parametrize("order", [2]) # Test 2nd order only in CI
@pytest.mark.parametrize("sym_test_func_factory", [
partial(_coord_test_func, order=0),
partial(_coord_test_func, order=1),
lambda dim: 2*_coord_test_func(dim, order=1),
partial(_coord_test_func, order=2),
_trig_test_func,
_cv_test_func
])
partial(_coord_test_func, order=1),
partial(_coord_test_func, order=2),
_trig_test_func,
],
[
partial(_coord_test_func, order=0),
partial(_coord_test_func, order=1),
lambda dim: 2*_coord_test_func(dim, order=1),
partial(_coord_test_func, order=2),
_trig_test_func,
_cv_test_func
])
@pytest.mark.parametrize("quad", [False, True])
def test_grad_operator(actx_factory, dim, mesh_name, rot_axis, wonk,
order, sym_test_func_factory, quad):
Expand Down Expand Up @@ -483,7 +496,7 @@ def test_correctness_of_quadrature(actx_factory, name):
# Test base and quadrature discretizations with order=[1,8]
# for incoming geometry and element type
# Test range(1, 8) to create fuller table, (1,3) for CI.
for discr_order in range(1, 3):
for discr_order in range(conditional_value((1, 3), (1, 8))):
ndofs_base = 0
ndofs_quad = 0
dofs_per_el_base = 0
Expand Down

0 comments on commit e743d0e

Please sign in to comment.