Skip to content

Commit 2f65dec

Browse files
committed
Update test utils to use .proto submodule with fallback to sibling directory
Changes to examples/serdes/tests/utils.py: - Updated get_wamp_proto_path() to check for .proto submodule first - Falls back to sibling directory ../wamp-proto for local development - Provides clear error messages with both paths tried - Ensures flexibility for both CI (submodule) and local dev (sibling) Path resolution order: 1. .proto/ submodule (preferred for CI/CD) 2. ../wamp-proto sibling (local development) This allows: - CI to use git submodule (works in GitHub Actions) - Developers to use either submodule or sibling directory - Clear error messages if neither location exists Related: #1764, wamp-proto#556
1 parent e0e03a9 commit 2f65dec

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

examples/serdes/tests/utils.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,38 @@ def get_wamp_proto_path() -> Path:
1111
"""
1212
Get path to wamp-proto repository.
1313
14-
Assumes wamp-proto is a sibling directory to autobahn-python:
15-
~/work/wamp/autobahn-python/
16-
~/work/wamp/wamp-proto/
14+
Tries multiple locations in order:
15+
1. Git submodule at autobahn-python/.proto (preferred for CI/CD)
16+
2. Sibling directory at ../wamp-proto (local development)
17+
18+
Directory structure:
19+
~/work/wamp/autobahn-python/.proto/ (submodule - CI)
20+
~/work/wamp/autobahn-python/ (this repo)
21+
~/work/wamp/wamp-proto/ (sibling - local dev)
1722
"""
1823
current_file = Path(__file__).resolve()
19-
# Go up from tests/ -> serdes/ -> examples/ -> autobahn-python/ -> wamp/
24+
# Go up from tests/ -> serdes/ -> examples/ -> autobahn-python/
2025
autobahn_root = current_file.parent.parent.parent.parent
21-
wamp_proto = autobahn_root.parent / "wamp-proto"
2226

23-
if not wamp_proto.exists():
24-
raise FileNotFoundError(
25-
f"wamp-proto repository not found at {wamp_proto}. "
26-
"Please ensure wamp-proto is in the same parent directory as autobahn-python."
27-
)
27+
# Try 1: Check for .proto submodule (CI/CD and new developers)
28+
wamp_proto_submodule = autobahn_root / ".proto"
29+
if wamp_proto_submodule.exists() and (wamp_proto_submodule / "testsuite").exists():
30+
return wamp_proto_submodule
31+
32+
# Try 2: Check for sibling directory (local development)
33+
wamp_proto_sibling = autobahn_root.parent / "wamp-proto"
34+
if wamp_proto_sibling.exists() and (wamp_proto_sibling / "testsuite").exists():
35+
return wamp_proto_sibling
36+
37+
# Neither location found
38+
raise FileNotFoundError(
39+
f"wamp-proto repository not found. Tried:\n"
40+
f" 1. Submodule: {wamp_proto_submodule}\n"
41+
f" 2. Sibling: {wamp_proto_sibling}\n\n"
42+
f"Please either:\n"
43+
f" - Run 'git submodule update --init --recursive' to initialize submodules, OR\n"
44+
f" - Clone wamp-proto as a sibling directory to autobahn-python"
45+
)
2846

2947
return wamp_proto
3048

0 commit comments

Comments
 (0)