MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestWriteFileRefusesNonRegular

Function TestWriteFileRefusesNonRegular

internal/tools/nonregular_unix_test.go:53–65  ·  view source on GitHub ↗

TestWriteFileRefusesNonRegular: write_file to an existing FIFO with no reader blocks identically in open(2) O_WRONLY; same guard, same contract.

(t *testing.T)

Source from the content-addressed store, hash-verified

51// TestWriteFileRefusesNonRegular: write_file to an existing FIFO with no
52// reader blocks identically in open(2) O_WRONLY; same guard, same contract.
53func TestWriteFileRefusesNonRegular(t *testing.T) {
54 path := mkfifo(t)
55 done := make(chan string, 1)
56 go func() { done <- WriteFile(path, "data") }()
57 select {
58 case got := <-done:
59 if !strings.Contains(got, "not a regular file") {
60 t.Fatalf("want a not-a-regular-file refusal, got %q", got)
61 }
62 case <-timeoutC(t):
63 t.Fatal("WriteFile blocked on the FIFO instead of refusing")
64 }
65}
66
67// TestEditFileRefusesNonRegular: edit_file reads the target first, so it needs
68// the same guard as read_file.

Callers

nothing calls this directly

Calls 3

mkfifoFunction · 0.85
WriteFileFunction · 0.85
timeoutCFunction · 0.85

Tested by

no test coverage detected