TestCmdDoAutoRefusesWhenAlreadyRunning: a second --auto launch while a prior run is still 'running' (live pid) is refused without --force.
(t *testing.T)
| 150 | // TestCmdDoAutoRefusesWhenAlreadyRunning: a second --auto launch while a |
| 151 | // prior run is still 'running' (live pid) is refused without --force. |
| 152 | func TestCmdDoAutoRefusesWhenAlreadyRunning(t *testing.T) { |
| 153 | setupFlowRoot(t) |
| 154 | seedTask(t, "auto-task") |
| 155 | stubITerm(t) |
| 156 | stubAutoLauncher(t, 4242) |
| 157 | |
| 158 | // Mark the pid alive so the running-guard fires. |
| 159 | oldAlive := processAlive |
| 160 | processAlive = func(pid int) bool { return true } |
| 161 | t.Cleanup(func() { processAlive = oldAlive }) |
| 162 | |
| 163 | if rc := cmdDo([]string{"auto-task", "--auto"}); rc != 0 { |
| 164 | t.Fatalf("first --auto rc=%d, want 0", rc) |
| 165 | } |
| 166 | if rc := cmdDo([]string{"auto-task", "--auto"}); rc != 1 { |
| 167 | t.Errorf("second --auto rc=%d, want 1 (already running)", rc) |
| 168 | } |
| 169 | if rc := cmdDo([]string{"auto-task", "--auto", "--force"}); rc != 0 { |
| 170 | t.Errorf("--auto --force rc=%d, want 0 (override running guard)", rc) |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | // stubAutoRunner replaces autoRunner with fn. |
| 175 | func stubAutoRunner(t *testing.T, fn func(h harness.Harness, sessionID, prompt string, opts harness.LaunchOpts) error) { |
nothing calls this directly
no test coverage detected