Skip to content

Commit e4e900c

Browse files
committed
Add custom ci mark to skip non-primary tests
1 parent f127f95 commit e4e900c

12 files changed

+48
-6
lines changed

array_api_tests/test_array_object.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from . import xps
1515
from .typing import DataType, Param, Scalar, ScalarType, Shape
1616

17+
pytestmark = pytest.mark.ci
18+
1719

1820
def scalar_objects(dtype: DataType, shape: Shape) -> st.SearchStrategy[List[Scalar]]:
1921
"""Generates scalars or nested sequences which are valid for xp.asarray()"""

array_api_tests/test_constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from ._array_module import mod as xp
88
from .typing import Array
99

10+
pytestmark = pytest.mark.ci
11+
1012

1113
def assert_scalar_float(name: str, c: Any):
1214
assert isinstance(c, SupportsFloat), f"{name}={c!r} does not look like a float"

array_api_tests/test_creation_functions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import math
2+
import pytest
23
from itertools import count
34
from typing import Iterator, NamedTuple, Union
45

@@ -14,6 +15,8 @@
1415
from . import xps
1516
from .typing import DataType, Scalar
1617

18+
pytestmark = pytest.mark.ci
19+
1720

1821
class frange(NamedTuple):
1922
start: float

array_api_tests/test_linalg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
from . import _array_module
3636
from ._array_module import linalg
3737

38+
pytestmark = pytest.mark.ci
39+
40+
3841

3942
# Standin strategy for not yet implemented tests
4043
todo = none()

array_api_tests/test_manipulation_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from . import xps
1515
from .typing import Array, Shape
1616

17+
pytestmark = pytest.mark.ci
18+
1719
MAX_SIDE = hh.MAX_ARRAY_SIZE // 64
1820
MAX_DIMS = min(hh.MAX_ARRAY_SIZE // MAX_SIDE, 32) # NumPy only supports up to 32 dims
1921

array_api_tests/test_operators_and_elementwise_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
from .algos import broadcast_shapes
2929
from .typing import Array, DataType, Param, Scalar
3030

31+
pytestmark = pytest.mark.ci
32+
3133
# When appropiate, this module tests operators alongside their respective
3234
# elementwise methods. We do this by parametrizing a generalised test method
3335
# with every relevant method and operator.

array_api_tests/test_searching_functions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from hypothesis import given
23
from hypothesis import strategies as st
34

@@ -9,6 +10,8 @@
910
from . import xps
1011
from .algos import broadcast_shapes
1112

13+
pytestmark = pytest.mark.ci
14+
1215

1316
@given(
1417
x=xps.arrays(

array_api_tests/test_set_functions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# TODO: disable if opted out, refactor things
22
import math
3+
import pytest
34
from collections import Counter, defaultdict
45

56
from hypothesis import assume, given
@@ -11,6 +12,8 @@
1112
from . import shape_helpers as sh
1213
from . import xps
1314

15+
pytestmark = pytest.mark.ci
16+
1417

1518
@given(xps.arrays(dtype=xps.scalar_dtypes(), shape=hh.shapes(min_side=1)))
1619
def test_unique_all(x):

array_api_tests/test_sorting_functions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import math
2+
import pytest
23
from typing import Set
34

45
from hypothesis import given
@@ -13,6 +14,8 @@
1314
from . import xps
1415
from .typing import Scalar, Shape
1516

17+
pytestmark = pytest.mark.ci
18+
1619

1720
def assert_scalar_in_set(
1821
func_name: str,

array_api_tests/test_statistical_functions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import math
2+
import pytest
23
from typing import Optional
34

45
from hypothesis import assume, given
@@ -13,6 +14,8 @@
1314
from . import xps
1415
from .typing import DataType
1516

17+
pytestmark = pytest.mark.ci
18+
1619

1720
def kwarg_dtypes(dtype: DataType) -> st.SearchStrategy[Optional[DataType]]:
1821
dtypes = [d2 for d1, d2 in dh.promotion_table if d1 == dtype]

array_api_tests/test_utility_functions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from hypothesis import given
23
from hypothesis import strategies as st
34

@@ -8,6 +9,8 @@
89
from . import shape_helpers as sh
910
from . import xps
1011

12+
pytestmark = pytest.mark.ci
13+
1114

1215
@given(
1316
x=xps.arrays(dtype=xps.scalar_dtypes(), shape=hh.shapes(min_side=1)),

conftest.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,19 @@ def pytest_addoption(parser):
3535
default=[],
3636
help="disable testing for Array API extension(s)",
3737
)
38+
# CI
39+
parser.addoption(
40+
"--ci",
41+
action="store_true",
42+
help="run just the tests appropiate for CI",
43+
)
3844

3945

4046
def pytest_configure(config):
4147
config.addinivalue_line(
4248
"markers", "xp_extension(ext): tests an Array API extension"
4349
)
50+
config.addinivalue_line("markers", "primary: primary test")
4451
# Hypothesis
4552
hypothesis_max_examples = config.getoption("--hypothesis-max-examples")
4653
disable_deadline = config.getoption("--hypothesis-disable-deadline")
@@ -76,20 +83,26 @@ def xp_has_ext(ext: str) -> bool:
7683

7784
def pytest_collection_modifyitems(config, items):
7885
disabled_exts = config.getoption("--disable-extension")
86+
ci = config.getoption("--ci")
7987
for item in items:
80-
# disable extensions
81-
try:
82-
ext_mark = next(m for m in item.iter_markers() if m.name == "xp_extension")
88+
markers = list(item.iter_markers())
89+
# skip if disabled or non-existent extension
90+
ext_mark = next((m for m in markers if m.name == "xp_extension"), None)
91+
if ext_mark is not None:
8392
ext = ext_mark.args[0]
8493
if ext in disabled_exts:
8594
item.add_marker(
8695
mark.skip(reason=f"{ext} disabled in --disable-extensions")
8796
)
8897
elif not xp_has_ext(ext):
8998
item.add_marker(mark.skip(reason=f"{ext} not found in array module"))
90-
except StopIteration:
91-
pass
92-
# workflow xfail_ids
99+
# xfail if specified in xfails.txt
93100
for id_ in xfail_ids:
94101
if item.nodeid.startswith(id_):
95102
item.add_marker(mark.xfail(reason="xfails.txt"))
103+
break
104+
# skip if test not appropiate for CI
105+
if ci:
106+
ci_mark = next((m for m in markers if m.name == "ci"), None)
107+
if ci_mark is None:
108+
item.add_marker(mark.skip(reason="disabled via --ci"))

0 commit comments

Comments
 (0)