diff --git a/pkgs/mcpx/internal/e2e/dispatch_settings_test.go b/pkgs/mcpx/internal/e2e/dispatch_settings_test.go index 0727e5e61b..87c5076b92 100644 --- a/pkgs/mcpx/internal/e2e/dispatch_settings_test.go +++ b/pkgs/mcpx/internal/e2e/dispatch_settings_test.go @@ -46,12 +46,27 @@ func TestScriptCwdIsReachableFromTheEnvironment(t *testing.T) { defer func() { e.envVars = saved }() out := e.run("run", script) - // The dispatch notice shares the stream; the script's pwd is the - // last line it printed. - lines := strings.Split(strings.TrimSpace(out), "\n") - got, _ := filepath.EvalSymlinks(strings.TrimSpace(lines[len(lines)-1])) + // The dispatch notice shares the stream and is written to stderr, so + // its position against the script's own stdout output is not + // ordered (observed in the flake-binary leg of run 45251429763, + // where the notice followed the pwd). Find the pwd by value instead + // of assuming it is the last line: a run that stayed in the caller's + // directory prints that directory and matches nothing here. want, _ := filepath.EvalSymlinks(sub) + var got string + for _, line := range strings.Split(strings.TrimSpace(out), "\n") { + cand := strings.TrimSpace(line) + if !filepath.IsAbs(cand) { + continue + } + resolved, err := filepath.EvalSymlinks(cand) + if err != nil || resolved != want { + continue + } + got = resolved + break + } if got != want { - t.Fatalf("MCPX_SCRIPT_CWD=script: pwd = %q, want %q\n%s", got, want, out) + t.Fatalf("MCPX_SCRIPT_CWD=script: no output line is the script directory %q\n%s", want, out) } } diff --git a/pkgs/mcpx/internal/e2e/envguard_test.go b/pkgs/mcpx/internal/e2e/envguard_test.go index c4554ce0b2..252d918eb8 100644 --- a/pkgs/mcpx/internal/e2e/envguard_test.go +++ b/pkgs/mcpx/internal/e2e/envguard_test.go @@ -32,6 +32,7 @@ import ( // harnessSetMCPX is every registry variable the harness sets: newEnv for // every child, or a test's withEnv/append for its own. var harnessSetMCPX = map[string]struct{}{ + "MCPX_ADAPTERS_ALLOW_BARE": {}, "MCPX_ARTIFACTS_MAX_BYTES": {}, "MCPX_AUTONOMY_MAX": {}, "MCPX_AUTOSTART_ARGS": {}, diff --git a/pkgs/mcpx/internal/pool/pool.go b/pkgs/mcpx/internal/pool/pool.go index c8d9953683..b23dbc882b 100644 --- a/pkgs/mcpx/internal/pool/pool.go +++ b/pkgs/mcpx/internal/pool/pool.go @@ -1293,6 +1293,9 @@ func (p *Pool) refreshSchemasScoped(ctx context.Context, scoped *config.Resolved // recording a guaranteed failure as the server's state. return p.refreshFailed(staleGen, fmt.Errorf("server %q: schema refresh deferred: definition requires a caller scope", p.cfg.Name)) } + if err := ctx.Err(); err != nil { + return p.refreshFailed(staleGen, err) + } lease, err := p.Acquire(ctx, acquireScope) if err != nil { return p.refreshFailed(staleGen, err)