20 lines
652 B
Go
20 lines
652 B
Go
package apply
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// A command killed because its context ended says so, and why: "docker exited -1:" said nothing while novox's bus
|
|
// container was half replaced (issue 1945, live on 2026-10-25 at 11:23).
|
|
func TestACommandKilledByItsContextSaysWhy(t *testing.T) {
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
go func() { time.Sleep(50 * time.Millisecond); cancel() }()
|
|
_, err := ExecRunner(ctx, "sleep", "5")
|
|
if err == nil || !strings.Contains(err.Error(), "killed") || !strings.Contains(err.Error(), "context canceled") {
|
|
t.Fatalf("a command its context killed said: %v", err)
|
|
}
|
|
}
|