Skip to content

Commit 592400a

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/python-1.2.0-environments
2 parents af7ca87 + 48cbeae commit 592400a

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

‎e2e/host/desktop/internal/workbench/python_current_file_run_e2e_test.go‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func checkPythonCurrentFileRun(t *testing.T, interpreter pythonRunInterpreter) {
169169
run := awaitProcessRun(t, h, p, "main.py", nil)
170170
checkOutput := func(output string) {
171171
t.Helper()
172-
if !strings.Contains(output, "current file ran") || !strings.Contains(output, wantPrefix) {
172+
if !strings.Contains(output, "current file ran") || !printsPrefix(output, wantPrefix) {
173173
t.Fatalf("expected the program to run with sys.prefix %q:\n%s", wantPrefix, output)
174174
}
175175
}
@@ -204,3 +204,24 @@ func checkPythonCurrentFileRun(t *testing.T, interpreter pythonRunInterpreter) {
204204
}
205205
t.Fatal("the build model no longer exposes the main.py target")
206206
}
207+
208+
// printsPrefix reports whether a line of output names the directory prefix
209+
// once links are resolved. A framework build of Python, such as Homebrew's,
210+
// prints its sys.prefix through the opt link even when it starts from the
211+
// Cellar directory the test resolved and pinned.
212+
func printsPrefix(output, prefix string) bool {
213+
want, err := filepath.EvalSymlinks(prefix)
214+
if err != nil {
215+
return false
216+
}
217+
for _, line := range strings.Split(output, "\n") {
218+
line = strings.TrimSpace(line)
219+
if line == "" {
220+
continue
221+
}
222+
if got, err := filepath.EvalSymlinks(line); err == nil && got == want {
223+
return true
224+
}
225+
}
226+
return false
227+
}

0 commit comments

Comments
 (0)