Skip to content

test: stabilize macOS filesystem event expectations - #17301

Open
anmonteiro wants to merge 4 commits into
ocaml:mainfrom
anmonteiro:fix/fsevents-test-expectations
Open

anmonteiro wants to merge 4 commits into
ocaml:mainfrom
anmonteiro:fix/fsevents-test-expectations

Conversation

@anmonteiro

@anmonteiro anmonteiro commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

This is the combined experiment behind the fork drafts below. It is not ready to merge as a whole. The aim is to enable meaningful macOS filesystem tests while separating demonstrated harness bugs from changes to what the tests accept.

There are two suites: test/expect-tests/fsevents exercises raw bindings, callbacks, flags, exclusions, and multiple streams/paths; test/expect-tests/dune_file_watcher exercises conversion into Dune's path/kind events. They have separate CI gates. Every draft below changes tests or their gates; production bindings fixes need their own reproductions.

The relevant history is:

The split is a set of candidates to evaluate, not a plan to merge all eleven:

Draft What it changes Evidence and remaining decision
#280 Log the callback's final batch before stopping Controlled timing experiment reproduced lost output and passed after reordering. Merged upstream as #17313.
#281 Finish after restoring cwd/removing the temp directory Controlled cleanup delay reproduced cross-test directory races. Merged upstream as #17310; fork draft closed. Timeout cleanup remains unresolved.
#282 Refresh constructor rendering in snapshots Mechanical consequence of #14725; unchanged semantic expectations. Merged upstream as #17314.
#283 Recognize repeated/coalesced markers; sort callback batches Marker hypothesis needs raw-flag evidence. Sorting has no isolated justification; the C callback preserves macOS array order.
#284 Add flushes around marker boundaries Need a residual boundary failure after the ordering fixes; flushes can conceal the callback-completion race.
#285 Isolate operations, deduplicate logs, accept a rename action set Changes coverage. Need justification for accepted Unknown, lost multiplicity/ordering, and removal of combined operations.
#286 Shut down the macOS test watcher Independent lifecycle cleanup; no reproduced missed-event fix. Merged upstream as #17315.
#287 Collect unique typed events per operation The rebased combined branch still loses the initial creation locally; clean main's watcher test passed in the comparison run. Blanket root filtering, deduplication, and operation boundaries need resolution.
#288 Raise the raw timeout from 3s to 10s No timing data yet justifies this bound. Does not fix event loss or timeout cleanup.
#289 Enable raw tests in CI Latest combined raw candidate run passed locally; selection and reliability questions remain.
#290 Enable watcher tests in CI Blocked by the missing initial x Created event after 10s and the collector's unresolved assumptions.

In the fork, anmonteiro#285 is based on anmonteiro#282, and anmonteiro#287 on anmonteiro#286. The raw CI draft combines the seven raw candidates above; the watcher CI draft combines shutdown and the watcher expectations. Other drafts target the pinned upstream review base 6924c149a2b304ac6cc4c58cc7e8dd312a64f28d, avoiding unrelated differences from the fork's older main. These comparison bases do not prove technical prerequisites.

The callback and cleanup reproductions were temporary perturbations in the combined branch, not committed regressions in the isolated drafts. Mutation experiments caught an incompatible action and a missing rename path, but do not establish that all normalization is safe. All draft @check @fmt checks passed; for the nine drafts that leave the CI gates intact, the CI=true full runs retained the relevant suite's gate. Earlier full local checks also had failures reproduced on the unchanged review base in autolock-with-watch-server.t, source-backed-artifact-repair.t, and stanzas/rule-plugins/failures.t.

The combined macOS CI job passed at e8884fd49cd66f23829acb9b9bebd823cfa9851a. That is one combined result, not proof of each draft's correctness or absence of flakes.

Current baseline: #17310, #17313, #17314, and #17315 are merged. This branch is rebased onto main at acc06319b49f0bd50f0d68e32daa1d6b6c1da4ce, with head 8a6fb2c99babd680d7230eab6bc8f79780bcc118. The remaining diff is four test files (+107/-58); the four accepted fixes are no longer part of it. No further candidate is ready to select merely because the combined experiment passes.

After refreshing the bootstrap from current main, a local comparison used the same Nix shell with CI=false and the Dune cache disabled, running both filesystem suites:

Checkout Raw FSEvents suite Dune watcher suite
Clean main (acc06319b4) Failed: timeouts and a Create/Unknown mismatch in the relative-exclusion case Passed
Rebased combined branch (8a6fb2c99b) Passed Failed: initial x Created missing after 10s

This is one run per checkout. The watcher operations and expectations differ between the two versions; the missing event is reproduced in the experimental test, not established as a failure of the clean-main test. The raw timeouts can also leave workers running, so later failures may be affected by the unresolved timeout-cleanup problem. @check @fmt passed on the rebased branch.

The subsequent CI=true ./dune.exe build @check @fmt @runtest -j 4 --display quiet --cache=disabled run exited 1 with nine failing files: depend-on/the-universe.t/run.t, engine/source-backed-artifact-repair.t, pkg/autolock-with-watch-server.t, stanzas/rule-plugins/failures.t, the foreign-library basic.t, foreign-archives.t, and include-dirs.t cases, foreign-stubs/fs-mode-dependent/fsmd-exe.t/run.t, and dune_rpc_registry_test.ml. Failures included watch-server timeouts, 60-second cram timeouts, and RPC shutdown timeout. These were not all reproduced on clean current main in this comparison.

The full-run trace confirms that the experimental watcher test reran and passed; it had failed in the focused run above. The raw suite had no new execution recorded in the full-run trace. This leaves the watcher outcome intermittent and does not establish reliability.

Keep the marker, flush, normalization, and timeout proposals experimental until their individual justifications are established. Diagnose the missing watcher creation event with raw diagnostics. Event kinds, missing and unexpected paths, both rename paths, and combined-operation behavior need an explicit test contract before normalization is accepted.

The CI switches, anmonteiro#289 and anmonteiro#290, come last for their respective suites. Rebuild their comparison branches from the accepted changes and validate reliable runs. Neither switch depends on the other; the watcher switch remains blocked by the missing creation event in the experimental collector.

The CI Documentation job fails on the existing format-generated-corrections cross-references. Its three Sphinx warnings match the earlier failure on #17314; the documentation tree is identical to current main.

01a20619-183b-76f3-b8a7-18c1b28eb1c0

anmonteiro added a commit that referenced this pull request Nov 29, 2026
Signal normal FSEvents test completion after restoring the process
working directory and removing the temporary directory. Previously,
`finish` ran inside `Exn.protect`, allowing the next test to start
before the previous test's cleanup changed the shared working directory.

A temporary experiment in the combined #17301 branch inserted a 0.05s
delay before restoring the directory. The old ordering produced missing
output and errors for a deleted previous directory; moving completion
after cleanup passed with the same delay. The delay is not committed
here.

Standalone extraction from #17301 and anmonteiro#281. It preserves
event expectations and the existing CI gate. This fixes normal
completion; timeout cleanup remains a separate issue, and this
reproduction does not establish the cause of the historical CI
disablement.

`@check @fmt` pass. The full local `CI=true` check retains three
failures reproduced on the unchanged base (listed in #17301), while the
raw suite remains disabled by its existing gate. The timing experiment
above used the combined branch.

01a20619-183b-76f3-b8a7-18c1b28eb1c0

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
anmonteiro added a commit that referenced this pull request Nov 29, 2026
Record the final FSEvents callback batch before stopping the stream
wakes the waiter, preventing the log from being flushed before those
events are recorded.

Standalone extraction from #17301 and anmonteiro#280; complements
the cleanup-ordering fix in #17310. The timing reproduction and
local-check limitations are documented in anmonteiro#280.

01a20619-183b-76f3-b8a7-18c1b28eb1c0

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
anmonteiro added a commit that referenced this pull request Nov 29, 2026
Update the raw FSEvents snapshots for the constructor rendering
introduced by #14725, removing obsolete quotes around action and kind
names.

Standalone extraction from #17301 and anmonteiro#282. Event
actions, kinds, paths, counts, and ordering are unchanged.

01a20619-183b-76f3-b8a7-18c1b28eb1c0

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
anmonteiro added a commit that referenced this pull request Nov 29, 2026
Shut down the macOS test watcher after its file operations finish,
releasing the resources created by the test.

Standalone cleanup extracted from #17301 and anmonteiro#286.

01a20619-183b-76f3-b8a7-18c1b28eb1c0

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
Compare affected paths without depending on FSEvents batching, callback counts, or delivery of the test root creation event. Keep exact action mapping covered by deterministic tests.

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
Signed-off-by: Antonio Nuno Monteiro <[email protected]>
Signed-off-by: Antonio Nuno Monteiro <[email protected]>
@anmonteiro
anmonteiro force-pushed the fix/fsevents-test-expectations branch from e8884fd to 8a6fb2c Compare November 29, 2026 05:25
anmonteiro added a commit that referenced this pull request Nov 29, 2026
Recognize the raw FSEvents tests’ start/end markers by file kind and
name, and ignore repeated start markers while recording. Captured
creation/modification flags decode as `Unknown`, causing the existing
file-create test to time out when markers require `Create`.

Minimal extraction from #17301 and anmonteiro#283, preserving
callback order. `@check @fmt` pass; the marker probe now reaches the
file operation. Other raw-suite failures and four full-suite watch-test
failures remain; CI enablement stays separate.

01a20619-183b-76f3-b8a7-18c1b28eb1c0

Signed-off-by: Antonio Nuno Monteiro <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant