Skip to content

Fix more tests on macOS - #13324

Closed
samoht wants to merge 2 commits into
ocaml:mainfrom
samoht:more-fix-tests
Closed

samoht wants to merge 2 commits into
ocaml:mainfrom
samoht:more-fix-tests

Conversation

@samoht

@samoht samoht commented Jan 15, 2026

Copy link
Copy Markdown
Member

No description provided.

@rgrinberg rgrinberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a description for the changes in fsevents_tests? Glancing over the diff is not enough to understand the goal, so Ia description would be helpful.

@samoht

samoht commented Jan 15, 2026

Copy link
Copy Markdown
Member Author

I've added a description in the commit message.

@rgrinberg

Copy link
Copy Markdown
Member

Thanks. That makes more sense. I'm still alarmed at the event types being dropped though. We do rely on those being reported a certain way in dune. Are we just not going to test those?

@samoht

samoht commented Jan 16, 2026

Copy link
Copy Markdown
Member Author

FSEVents is coaliscing events, so the results of that test will never be deterministic. But let me try to keep the event kind somehow.

@samoht

samoht commented Jan 16, 2026 •

Copy link
Copy Markdown
Member Author

(and more generally if Dune expects too precise information to happen from the filesystem events, it might be quickly disappointed on macOS :p)

@samoht
samoht force-pushed the more-fix-tests branch 3 times, most recently from 4df64af to 18b0c8d Compare January 16, 2026 18:18
(match Fsevents.Event.action event with
| Rename ->
(* For renames, check if path exists to determine old vs new *)
[ ev (if Path.exists path then Created else Deleted) ]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if Path.exists here is acceptable

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem suspicious. I'm wondering if there's a potential for races here.

@samoht

samoht commented Jan 16, 2026

Copy link
Copy Markdown
Member Author

I've tried to make the FSEvent code a bit more robust and to run the same file watcher test on both Linux and macOS. Will see if that works 😅

wait_for [ "d/w/x" ];
[%expect {| saw: d/w/x |}];
(* Test 4: file creation in existing directory is detected *)
Stdio.Out_channel.write_all "d/w/y" ~data:"y";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all of these tests present in the linux test suite?

Comment thread test/blackbox-tests/dune Resolved
- Fix FSEvents to produce consistent events with inotify:
  - Use ItemInodeMetaMod to disambiguate coalesced Create+Modify events
  - Convert Rename to Deleted/Created based on path existence

- Merge Linux and macOS file watcher tests into a single cross-platform test
  that verifies identical file event semantics on both platforms

Signed-off-by: Thomas Gazagnaire <[email protected]>
@rgrinberg

rgrinberg commented Jan 19, 2026 •

Copy link
Copy Markdown
Member

By the way, I find that the goals of this PR have been changed a few times.

1.Started with making the fsevents reproducible
2. Continued to fix bugs in our fsevents implementation
3. Went on to unify our linux and macos file watching test suites

All of these goals are good, but I'd much rather have these addressed separately. Especially given that it really is quite hard to review file watcher related changes.

@samoht

samoht commented Jan 19, 2026

Copy link
Copy Markdown
Member Author

Do you want me to open separate PRs for each of those cases?

I'm quite happy with the current state of my fixes now (and I'm happy to revert the previous "fixes" which were simplifying the tests too much).

@rgrinberg

rgrinberg commented Jan 19, 2026 •

Copy link
Copy Markdown
Member

I'm not confident on what's the best way to approach this would be, but let me try come up with a constructive suggestion. First, I'd move merging the test suites into a separate PR (probably after the fix?). Preferably, there should be some justification explaining why this can be done.

Now regarding the fix. Before we submit the fix, we need to demonstrate the bug. Obviously, that's made complicated by the fact that macos coalesces events non deterministically. Is it at all possible to demonstrate this in a test? For example, by artificially increasing the latency in a test. If this isn't possible, can we at least right a unit test for this that demonstrates what kind of events dune will try to "unmerge". Maybe this will require moving some of the logic from the stubs into OCaml? That seems fine with me.

Are there any other events that may be coalesced in this way? For example, can we have a create and a delete event coalesced into one event. If so, it would be helpful to systematically treat those.

rgrinberg pushed a commit that referenced this pull request Jan 19, 2026
…#13380)

This reverts commit d52ff76.

The root cause is actually a bug in the FSEvent bindings (see #13324),
so it's best to fix the bug rather than the tests!

Signed-off-by: Thomas Gazagnaire <[email protected]>
@robinbb robinbb self-assigned this May 4, 2026
@robinbb
robinbb marked this pull request as draft May 6, 2026 18:33
@rgrinberg

Copy link
Copy Markdown
Member

I fixed a bunch of these issues. Please submit fresh reports/repros.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants