Skip to content

Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦

C

test(loader): compare paths as paths, not as strings

Kenneth-Javier Ortigoza1f76e498cc34
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 4652fb5b..4a07a6ec 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -73,12 +73,11 @@ jobs:
# tests do not apply. They need no GPU and no HIP SDK — the fixtures are
# stub DLLs this job's MinGW gcc/objdump build on the fly.
#
- # shell: pwsh overrides the job default on purpose. Under the MSYS2 shell
- # the UCRT64 interpreter reports os.sep == '/', so the loader's
- # backslash-joined paths compare unequal and the path tests fail; the same
- # interpreter reports '\' when launched from PowerShell. Run the tests from
- # pwsh with the runner's native CPython, and put MSYS2's UCRT64 bin on PATH
- # only so gcc/objdump are reachable for fixture compilation.
+ # shell: pwsh overrides the job default so the tests run outside the MSYS2
+ # shell; MSYS2 is on PATH only so gcc/objdump/make are reachable for
+ # fixture compilation. The tests themselves are separator-agnostic (they
+ # normalise both sides before comparing), so neither interpreter choice nor
+ # the shape of the temp root can decide the outcome.
- name: Windows backend-loader contract tests (no GPU)
if: matrix.os == 'windows-latest'
shell: pwsh
@@ -101,12 +100,9 @@ jobs:
'HIP_VISIBLE_DEVICES','CUDA_VISIBLE_DEVICES') {
Remove-Item "env:$v" -ErrorAction SilentlyContinue
}
- python -c "import sys, os; print('python', sys.executable); print('os.sep', repr(os.sep))"
+ python -c "import sys, os, tempfile; print('python', sys.executable); print('os.sep', repr(os.sep)); print('tmp', tempfile.gettempdir())"
gcc --version | Select-Object -First 1
make --version | Select-Object -First 1
- if ((python -c "import os; print(os.sep)") -ne '\') {
- throw "expected a native Windows CPython (os.sep '\'); the loader path tests need it"
- }
cd c
$out = python -m unittest tests.test_backend_loader -v 2>&1 | Out-String
$out
diff --git a/c/tests/test_backend_loader.py b/c/tests/test_backend_loader.py
index 9e7939d6..0b5d5253 100644
--- a/c/tests/test_backend_loader.py
+++ b/c/tests/test_backend_loader.py
@@ -129,6 +129,19 @@ _FORBIDDEN_IMPORT_MARKERS = ("cudart", "nvcuda", "hiprtc", "rocblas", "rocwmma",
_RUNTIME_MARKER_A = 0xA1
_RUNTIME_MARKER_B = 0xB2
_RUNTIME_BASENAME = "amdhip64_7.dll"
+
+
+def _same_path(a, b):
+ """Compare two Windows paths as paths, not as strings.
+
+ Both separator conventions can be live in one process: under MSYS2 the temp
+ root arrives as ``D:/a/_temp/msys64/tmp/...`` with forward slashes, while the
+ loader joins with ``\\`` -- which is the correct Windows separator and is not
+ something the loader should change. Comparing the two as raw strings then
+ fails on the separator alone, so normalise both sides instead.
+ """
+ return (os.path.normcase(os.path.normpath(str(a)))
+ == os.path.normcase(os.path.normpath(str(b))))
_TEST_ACCESSOR = "coli_test_bound_runtime"
_RUNTIME_DIR_VAR = "COLI_HIP_RUNTIME_DIR"
@@ -1686,8 +1699,10 @@ class LoaderPathHelperTest(_HelperTestBase):
f = self.fixture
proc, out = f.run_helper("configured", f.runtime_a_dir)
self.assertEqual(out.get("valid"), "1", proc.stdout)
- self.assertEqual(out["cfg_path"],
- str(f.runtime_a_dir / _RUNTIME_BASENAME))
+ self.assertTrue(_same_path(out["cfg_path"],
+ f.runtime_a_dir / _RUNTIME_BASENAME),
+ "%r != %r" % (out["cfg_path"],
+ str(f.runtime_a_dir / _RUNTIME_BASENAME)))
self.assertTrue(out["cfg_final"].lower().endswith(_RUNTIME_BASENAME))
self.assertEqual(out.get("cfg_error"), "0")
@@ -1697,7 +1712,9 @@ class LoaderPathHelperTest(_HelperTestBase):
proc, out = self.fixture.run_helper("configured", missing)
self.assertEqual(out.get("valid"), "0", proc.stdout)
# The path is still built, so a diagnostic can name it.
- self.assertEqual(out["cfg_path"], str(missing / _RUNTIME_BASENAME))
+ self.assertTrue(_same_path(out["cfg_path"], missing / _RUNTIME_BASENAME),
+ "%r != %r" % (out["cfg_path"],
+ str(missing / _RUNTIME_BASENAME)))
self.assertNotEqual(out.get("cfg_error"), "0")