MCPcopy Index your code
hub / github.com/coder/coder / TestProcGroupProcessExit

Function TestProcGroupProcessExit

scripts/develop/main_test.go:687–708  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

685}
686
687func TestProcGroupProcessExit(t *testing.T) {
688 t.Parallel()
689
690 logger := slog.Make(sloghuman.Sink(&bytes.Buffer{}))
691 group := newProcGroup(t.Context(), logger)
692
693 cmd := exec.CommandContext(t.Context(), "false")
694 cmd.Env = os.Environ()
695 require.NoError(t, group.Start("dies-fast", cmd))
696
697 // Process exit should cancel the group context.
698 select {
699 case <-group.Ctx().Done():
700 case <-time.After(5 * time.Second):
701 t.Fatal("timed out waiting for context cancellation")
702 }
703
704 // Wait should return an error naming the exited process.
705 err := group.Wait()
706 require.Error(t, err)
707 assert.Contains(t, err.Error(), "dies-fast")
708}
709
710func TestProcGroupGracefulShutdown(t *testing.T) {
711 t.Parallel()

Callers

nothing calls this directly

Calls 11

newProcGroupFunction · 0.85
CtxMethod · 0.80
FatalMethod · 0.80
ContextMethod · 0.65
CommandContextMethod · 0.65
EnvironMethod · 0.65
StartMethod · 0.65
WaitMethod · 0.65
DoneMethod · 0.45
ErrorMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected