From 03e3ab7145822e461ef9e5bdbea3b3bfa4b69246 Mon Sep 17 00:00:00 2001 From: tensorlink-dev Date: Wed, 25 Nov 2026 01:33:52 +0000 Subject: [PATCH] test(validator): offloaded sweep uv resolution (#903) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01SG5aamoFze4bkhr1suMufY --- tests/unit/test_offload_uv_resolve.py | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/unit/test_offload_uv_resolve.py diff --git a/tests/unit/test_offload_uv_resolve.py b/tests/unit/test_offload_uv_resolve.py new file mode 100644 index 00000000..9e095253 --- /dev/null +++ b/tests/unit/test_offload_uv_resolve.py @@ -0,0 +1,39 @@ +"""#903: the offloaded bench sweep finds uv wherever the host has it.""" +from __future__ import annotations + +import os +import shlex +import stat +import subprocess +from types import SimpleNamespace + +from cascade.validator.eval_offload import DEFAULT_UV_BIN, UV_RESOLVE, build_bench_remote_command + + +def _host(): + return SimpleNamespace(workdir="/root/cascade", cuda_device=None) + + +def test_default_uv_is_resolved_on_the_host(): + cmd = build_bench_remote_command(_host(), "/w/c", "/w/r", suites="gift-eval") + assert UV_RESOLVE in cmd and f"{DEFAULT_UV_BIN} run" not in cmd.replace(UV_RESOLVE, "") + + +def test_explicit_uv_bin_is_used_as_given(): + cmd = build_bench_remote_command(_host(), "/w/c", "/w/r", suites="gift-eval", uv_bin="/bin/uv") + assert shlex.split(cmd)[0] == "/bin/uv" and UV_RESOLVE not in cmd + + +def test_resolver_prefers_path_then_falls_back(tmp_path): + fake = tmp_path / "bin" / "uv" + fake.parent.mkdir() + fake.write_text("#!/bin/sh\n") + fake.chmod(fake.stat().st_mode | stat.S_IEXEC) + script = f"echo {UV_RESOLVE}" + env = {"HOME": str(tmp_path), "PATH": f"{fake.parent}:/usr/bin:/bin"} + assert subprocess.run(["bash", "-c", script], env=env, capture_output=True, text=True).stdout.strip() == str(fake) + env["PATH"] = "/usr/bin:/bin" + got = subprocess.run(["bash", "-c", script], env=env, capture_output=True, text=True).stdout.strip() + want = ("/usr/bin/uv" if os.access("/usr/bin/uv", os.X_OK) else + "/bin/uv" if os.access("/bin/uv", os.X_OK) else os.path.join(str(tmp_path), ".local/bin/uv")) + assert got == want