mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-13 11:40:53 +08:00
The scrub ran in main after server.New returned, but New resumes every non-terminal task before returning, and those loops start workers that run shells. Move the scrub into New, right after both environment readers, and start MCP discovery after it as well: both paths spawn child processes. New takes an option rather than scrubbing unconditionally. The test suite builds several servers in one process and still needs ARTEX_PG_DSN on later calls, so only the binary opts in.
22 lines
582 B
Go
22 lines
582 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/Autumn-27/artex/agent"
|
|
)
|
|
|
|
// The shutdown cause must survive the parent context being cancelled first;
|
|
// losing it would drop the diagnostic on every graceful stop.
|
|
func TestShutdownContextPreservesNamedCause(t *testing.T) {
|
|
signalCtx, signalCancel := context.WithCancel(context.Background())
|
|
ctx, shutdown := shutdownContext(signalCtx)
|
|
defer shutdown(nil)
|
|
signalCancel()
|
|
<-ctx.Done()
|
|
if code, _, _, ok := agent.AbortReason(ctx); !ok || code != "shutdown" {
|
|
t.Fatalf("code=%q ok=%v, want shutdown", code, ok)
|
|
}
|
|
}
|