Skip to content

Commit 9f0f4ee

Browse files
committed
test: handle Windows short paths in CI
1 parent 8c10e62 commit 9f0f4ee

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎tests/test_agent_readiness.py‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,46 @@
1010
ROOT = Path(__file__).resolve().parents[1]
1111

1212

13+
def _long_windows_path(path):
14+
text = str(path)
15+
if os.name != "nt":
16+
return text
17+
try:
18+
import ctypes
19+
20+
buffer = ctypes.create_unicode_buffer(32768)
21+
result = ctypes.windll.kernel32.GetLongPathNameW(text, buffer, len(buffer))
22+
if result:
23+
return buffer.value
24+
except Exception:
25+
pass
26+
return text
27+
28+
29+
def _path_variants(path):
30+
values = {str(path), _long_windows_path(path)}
31+
return {value for value in values if value}
32+
33+
34+
def _paths_equal(left, right):
35+
left_values = {os.path.normcase(os.path.normpath(value)) for value in _path_variants(left)}
36+
right_values = {os.path.normcase(os.path.normpath(value)) for value in _path_variants(right)}
37+
return not left_values.isdisjoint(right_values)
38+
39+
40+
def _assert_path_equal(testcase, left, right):
41+
testcase.assertTrue(_paths_equal(left, right), f"{left!r} is not the same path as {right!r}")
42+
43+
44+
def _assert_path_in_text(testcase, path, text):
45+
escaped_variants = {value.replace("\\", "\\\\") for value in _path_variants(path)}
46+
testcase.assertTrue(any(value in text for value in escaped_variants), f"none of {escaped_variants!r} found in text")
47+
48+
49+
def _assert_path_in_values(testcase, path, values):
50+
testcase.assertTrue(any(_paths_equal(value, path) for value in values), f"{path!r} not found in {values!r}")
51+
52+
1353
class AgentReadinessTests(unittest.TestCase):
1454
def test_project_mcp_config_uses_bootstrap_runner(self):
1555
config = json.loads((ROOT / ".mcp.json").read_text(encoding="utf-8"))

0 commit comments

Comments
 (0)