fix(daemon): fix flaky file-watcher workflow test on macOS #175
@@ -74,23 +74,28 @@ describe("createFileWatcher — workflow file changes (Phase 3)", () => {
|
||||
expect(wfChange.workflowName).toBe("my-workflow");
|
||||
}, 10_000);
|
||||
|
||||
// TODO: flaky on macOS — fs.watch sometimes coalesces events across files.
|
||||
// See https://git.shazhou.work/uncaged/nerve/issues/149
|
||||
it.skip("does NOT emit workflow change for nerve.yaml", async () => {
|
||||
const root = makeTempNerveRoot();
|
||||
it("does NOT emit workflow change for nerve.yaml", async () => {
|
||||
// Use a root with NO workflow files — avoids macOS fs.watch coalescing
|
||||
// stale workflow creation events into the nerve.yaml write window.
|
||||
const dir = mkdtempSync(join(tmpdir(), "nerve-fw-wf-noworkflow-"));
|
||||
mkdirSync(join(dir, "senses"), { recursive: true });
|
||||
writeFileSync(join(dir, "nerve.yaml"), "senses: {}\nreflexes: []\n");
|
||||
|
||||
const changes: FileChange[] = [];
|
||||
watcher = createFileWatcher(dir, (change) => changes.push(change), 50);
|
||||
|
||||
watcher = createFileWatcher(root, (change) => changes.push(change), 50);
|
||||
|
||||
await new Promise((r) => setTimeout(r, 100));
|
||||
// Isolate the nerve.yaml write from fs.watch startup / coalesced events on some platforms
|
||||
// Let watcher settle
|
||||
await new Promise((r) => setTimeout(r, 200));
|
||||
changes.length = 0;
|
||||
writeFileSync(join(root, "nerve.yaml"), "senses: {}\nreflexes: []\n# changed\n");
|
||||
|
||||
writeFileSync(join(dir, "nerve.yaml"), "senses: {}\nreflexes: []\n# changed\n");
|
||||
|
||||
await waitFor(() => changes.some((c) => c.kind === "config"), 3000);
|
||||
|
||||
const wfChanges = changes.filter((c) => c.kind === "workflow");
|
||||
expect(wfChanges).toHaveLength(0);
|
||||
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}, 10_000);
|
||||
|
||||
it("debounces rapid workflow file changes", async () => {
|
||||
|
||||
Reference in New Issue
Block a user