Siqi commited on
Commit
18c4140
·
1 Parent(s): 588bf8c

Skip live engine tests without openra_train

Browse files
Files changed (1) hide show
  1. tests/conftest.py +30 -0
tests/conftest.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Shared pytest collection guards for optional Rust-engine tests."""
2
+ from __future__ import annotations
3
+
4
+ import importlib.util
5
+ import inspect
6
+
7
+ import pytest
8
+
9
+
10
+ _ENGINE_SKIP = pytest.mark.skip(reason="Rust env wheel not installed")
11
+ _ENGINE_TOKENS = ("run_level(", "RustEnvPool(")
12
+
13
+
14
+ def pytest_collection_modifyitems(config, items):
15
+ """Skip live Rust-engine tests when the openra_train wheel is absent.
16
+
17
+ CI for this repo installs Python requirements but does not build the
18
+ optional OpenRA-Rust extension. Structural/schema tests should still run;
19
+ only tests that directly exercise the live engine via run_level or
20
+ RustEnvPool are skipped.
21
+ """
22
+ if importlib.util.find_spec("openra_train") is not None:
23
+ return
24
+ for item in items:
25
+ try:
26
+ src = inspect.getsource(item.obj)
27
+ except (OSError, TypeError):
28
+ continue
29
+ if any(token in src for token in _ENGINE_TOKENS):
30
+ item.add_marker(_ENGINE_SKIP)