Skip to content

Commit 7de4663

Browse files
[Crane: crane-migration-python-to-go-full-apm-cli-rewrite] Iteration 34: Fix uv fallback path lookup in completion tests
Changes: - Add lookPathUV() helper to check ~/.local/bin/uv and other common locations when uv is not on PATH (Crane sandbox installs uv via astral installer) - Fixes go_tests/python_tests/benchmarks gates failing in sandboxes where PATH does not include ~/.local/bin after uv install Run: https://github.com/githubnext/apm/actions/runs/26851734533 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1010259 commit 7de4663

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

cmd/apm/parity_completion_test.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,27 @@ func TestParityCompletionStateDiffContracts(t *testing.T) {
332332
})
333333
}
334334

335+
// lookPathUV resolves the uv binary, checking PATH first, then common fallback
336+
// locations (~/.local/bin/uv, /usr/local/bin/uv) so Crane sandbox runs succeed
337+
// even when uv was installed by the astral installer but PATH was not updated.
338+
func lookPathUV() (string, error) {
339+
if p, err := exec.LookPath("uv"); err == nil {
340+
return p, nil
341+
}
342+
home, _ := os.UserHomeDir()
343+
candidates := []string{
344+
filepath.Join(home, ".local", "bin", "uv"),
345+
"/usr/local/bin/uv",
346+
"/usr/bin/uv",
347+
}
348+
for _, c := range candidates {
349+
if _, err := os.Stat(c); err == nil {
350+
return c, nil
351+
}
352+
}
353+
return "", fmt.Errorf("uv not found in PATH or common fallback locations")
354+
}
355+
335356
// TestParityCompletionPythonSuite runs the Python reference unit test suite to
336357
// confirm the Python CLI remains green. Gate 7: python_tests_pass.
337358
func TestParityCompletionPythonSuite(t *testing.T) {
@@ -342,7 +363,7 @@ func TestParityCompletionPythonSuite(t *testing.T) {
342363
root := completionModuleRoot(t)
343364

344365
// Locate uv; required to run the Python test suite.
345-
uvPath, err := exec.LookPath("uv")
366+
uvPath, err := lookPathUV()
346367
if err != nil {
347368
t.Fatalf("HARD-GATE FAILED: uv not found in PATH -- cannot run Python suite: %v", err)
348369
}
@@ -384,7 +405,7 @@ func TestParityCompletionBenchmarks(t *testing.T) {
384405
}
385406

386407
// Locate uv to run the benchmark script.
387-
uvPath, err := exec.LookPath("uv")
408+
uvPath, err := lookPathUV()
388409
if err != nil {
389410
t.Fatalf("HARD-GATE FAILED: uv not found in PATH: %v", err)
390411
}

0 commit comments

Comments
 (0)