TestBashHonorsAlreadyCancelledParent: a pre-cancelled parent (Ctrl+C raced the dispatch) must report "(cancelled)", not "(empty command)" or, worse, spawn a fresh /bin/sh. The cancel must win even on the empty-cmd fast path.
(t *testing.T)
| 107 | // the dispatch) must report "(cancelled)", not "(empty command)" or, worse, |
| 108 | // spawn a fresh /bin/sh. The cancel must win even on the empty-cmd fast path. |
| 109 | func TestBashHonorsAlreadyCancelledParent(t *testing.T) { |
| 110 | parent, cancel := context.WithCancel(context.Background()) |
| 111 | cancel() |
| 112 | if got := Bash(parent, "", time.Second); got != "(cancelled)" { |
| 113 | t.Fatalf("pre-cancelled bash returned %q, want (cancelled)", got) |
| 114 | } |
| 115 | if got := Bash(parent, "echo nope", time.Second); got != "(cancelled)" { |
| 116 | t.Fatalf("pre-cancelled bash with command returned %q, want (cancelled)", got) |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | func TestBashTimeout(t *testing.T) { |
| 121 | out := Bash(context.Background(), "sleep 2", 100*time.Millisecond) |