Skip to content

Commit 3458029

Browse files
committed
Skip fork-dependent integration tests when user namespaces unavailable
Signed-off-by: Cong Wang <cwang@multikernel.io>
1 parent 0879945 commit 3458029

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/test_integration.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,29 @@
1313

1414
import pytest
1515

16+
17+
def _can_unshare_userns() -> bool:
18+
"""Check if the system supports unprivileged user namespaces."""
19+
try:
20+
result = subprocess.run(
21+
["unshare", "--user", "--map-root-user", "true"],
22+
capture_output=True, timeout=5,
23+
)
24+
return result.returncode == 0
25+
except (FileNotFoundError, subprocess.TimeoutExpired):
26+
return False
27+
28+
1629
needs_branchfs = pytest.mark.skipif(
1730
not os.environ.get("BRANCHFS_MOUNT"),
1831
reason="BRANCHFS_MOUNT not set (no live branchfs)",
1932
)
2033

34+
needs_userns = pytest.mark.skipif(
35+
not _can_unshare_userns(),
36+
reason="Kernel does not support unprivileged user namespaces",
37+
)
38+
2139

2240
@pytest.fixture
2341
def ws():
@@ -100,6 +118,7 @@ def test_sibling_branches_first_wins(ws):
100118

101119

102120
@needs_branchfs
121+
@needs_userns
103122
def test_speculate_parallel(ws):
104123
"""Speculate runs candidates in parallel, commits the winner."""
105124
from branching import Speculate
@@ -121,6 +140,7 @@ def candidate_fail(path: Path) -> bool:
121140

122141

123142
@needs_branchfs
143+
@needs_userns
124144
def test_tree_of_thoughts_multi_level(ws):
125145
"""TreeOfThoughts with expand commits accumulated state across levels."""
126146
from branching import TreeOfThoughts

0 commit comments

Comments
 (0)