MCPcopy Create free account
hub / github.com/JordanCoin/codemap / TestStopTerminatesProcessAndRemovesPID

Function TestStopTerminatesProcessAndRemovesPID

watch/state_more_test.go:218–245  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

216}
217
218func TestStopTerminatesProcessAndRemovesPID(t *testing.T) {
219 root := t.TempDir()
220 codemapDir := filepath.Join(root, ".codemap")
221 if err := os.MkdirAll(codemapDir, 0o755); err != nil {
222 t.Fatal(err)
223 }
224
225 cmd := exec.Command("sleep", "5")
226 if err := cmd.Start(); err != nil {
227 t.Fatalf("start sleep: %v", err)
228 }
229 defer func() {
230 _ = cmd.Process.Kill()
231 _, _ = cmd.Process.Wait()
232 }()
233
234 pidPath := filepath.Join(codemapDir, "watch.pid")
235 if err := os.WriteFile(pidPath, []byte(strconv.Itoa(cmd.Process.Pid)), 0o644); err != nil {
236 t.Fatal(err)
237 }
238
239 if err := Stop(root); err != nil {
240 t.Fatalf("Stop error: %v", err)
241 }
242 if _, err := os.Stat(pidPath); !os.IsNotExist(err) {
243 t.Fatalf("expected pid file to be removed, stat err=%v", err)
244 }
245}

Callers

nothing calls this directly

Calls 2

StopFunction · 0.85
StartMethod · 0.65

Tested by

no test coverage detected