Repository navigation
Expand file tree
/
Copy pathconftest.py
More file actions
63 lines (48 loc) · 2.48 KB
/
Copy pathconftest.py
File metadata and controls
63 lines (48 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""Pytest config: backend-marker taxonomy.
CI selects tests positively: each job runs ``pytest -m "<backend>"`` for one run-target marker.
Run-target markers (exactly one per test; mutually exclusive):
isaacsim / mujoco — needs that simulator backend
no_sim — pure test, no simulator (CPU job)
requires_inference — needs the inference env (e2e job)
Sub-tags (not used to pick a job; for manual ``-m`` selection):
mujoco_classic / mujoco_warp — which MuJoCo backend a mujoco test uses
multi_gpu — needs multiple GPUs
``pytest_collection_modifyitems`` auto-applies the umbrella by directory and falls back to
no_sim, so every item ends with exactly one run-target and positive ``-m`` selection cannot
skip a test by omission. A sim test outside ``tests/simulators/<backend>/`` must set its
umbrella explicitly; a pure test inside such a dir opts out with ``pytest.mark.no_sim``.
"""
import os
import pytest
_RUN_TARGETS = ("isaacsim", "mujoco", "no_sim", "requires_inference")
_SIM_DIRS = ("isaacsim", "mujoco")
_ALL_MARKERS = {
"isaacsim": "Isaac Sim",
"mujoco": "MuJoCo (either backend)",
"mujoco_classic": "the MuJoCo ClassicBackend (CPU)",
"mujoco_warp": "the MuJoCo WarpBackend (CUDA)",
"multi_gpu": "multiple GPUs",
"no_sim": "no simulator (pure / CPU-only)",
"requires_inference": "the inference environment",
}
def pytest_configure(config):
for marker, msg in _ALL_MARKERS.items():
config.addinivalue_line("markers", f"{marker}: marks tests as requiring {msg}")
def pytest_collection_modifyitems(config, items):
for item in items:
own = {m.name for m in item.iter_markers()}
# mujoco_classic/mujoco_warp imply the mujoco umbrella.
if (own & {"mujoco_classic", "mujoco_warp"}) and "mujoco" not in own:
item.add_marker(pytest.mark.mujoco)
own.add("mujoco")
# Directory umbrella, unless an explicit run-target already set it.
if not (own & set(_RUN_TARGETS)):
path = str(getattr(item, "path", item.fspath)).replace(os.sep, "/")
for backend in _SIM_DIRS:
if f"/tests/simulators/{backend}/" in path:
item.add_marker(getattr(pytest.mark, backend))
own.add(backend)
break
# Fallback for anything without a run-target.
if not (own & set(_RUN_TARGETS)):
item.add_marker(pytest.mark.no_sim)