-
-
Notifications
You must be signed in to change notification settings - Fork 760
test: fix failing watcher tests on macOS #7549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
1a5ace9 to
4735f02
Compare
Walkthrough
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
crates/biome_service/src/scanner/watcher.rs (1)
193-200: Don’t hinge on the first path; partition by existenceRare, but if a platform emits multiple paths for a Modify, basing the action on
paths[0]could mishandle some entries. Partition and handle both buckets.Try:
- ModifyKind::Data(_) | ModifyKind::Name(RenameMode::Any) | ModifyKind::Any => { - // It's possible to receive Modify(Data) event after the file is removed on macOS. - let path = &paths[0]; - if workspace.fs().path_is_file(path) || workspace.fs().path_is_dir(path) { - Self::index_paths(workspace, paths) - } else { - Self::unload_paths(workspace, paths) - } - } + ModifyKind::Data(_) | ModifyKind::Name(RenameMode::Any) | ModifyKind::Any => { + // On macOS, Modify(Data) can follow a removal; decide per path. + let (existing, missing): (Vec<_>, Vec<_>) = paths + .into_iter() + .partition(|p| workspace.fs().path_is_file(p) || workspace.fs().path_is_dir(p)); + let mut diagnostics = Vec::new(); + if !existing.is_empty() { + diagnostics.extend(Self::index_paths(workspace, existing)?); + } + if !missing.is_empty() { + diagnostics.extend(Self::unload_paths(workspace, missing)?); + } + Ok(diagnostics) + }crates/biome_service/src/scanner/watcher.tests.rs (1)
59-62: LGTM; macOS settle time is a pragmatic fixThe guarded 1s sleeps make the tests sane on FSEvents. Consider a tiny helper to de‑dupe and centralise the delay.
Apply this change and call it from both spots:
+#[cfg(target_os = "macos")] +fn wait_for_fsevents_ready() { + sleep(Duration::from_secs(1)); +} + @@ - #[cfg(target_os = "macos")] - sleep(Duration::from_secs(1)); + #[cfg(target_os = "macos")] + wait_for_fsevents_ready(); @@ - #[cfg(target_os = "macos")] - sleep(Duration::from_secs(1)); + #[cfg(target_os = "macos")] + wait_for_fsevents_ready();Also applies to: 129-131
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
crates/biome_service/src/scanner/watcher.rs(1 hunks)crates/biome_service/src/scanner/watcher.tests.rs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_service/src/scanner/watcher.rscrates/biome_service/src/scanner/watcher.tests.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Format all Rust source files before committing (just f)
Files:
crates/biome_service/src/scanner/watcher.rscrates/biome_service/src/scanner/watcher.tests.rs
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:53:15.299Z
Learning: Applies to crates/biome_service/src/workspace/watcher.tests.rs : Place watcher tests for workspace methods in src/workspace/watcher.tests.rs
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:53:15.299Z
Learning: Applies to crates/biome_service/src/workspace_watcher.rs : Keep workspace state in sync with the filesystem using WorkspaceWatcher; only active in daemon mode
📚 Learning: 2025-08-11T11:53:15.299Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:53:15.299Z
Learning: Applies to crates/biome_service/src/workspace/watcher.tests.rs : Place watcher tests for workspace methods in src/workspace/watcher.tests.rs
Applied to files:
crates/biome_service/src/scanner/watcher.tests.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Documentation
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Check Dependencies
- GitHub Check: End-to-end tests
- GitHub Check: Test Node.js API
- GitHub Check: autofix
4735f02 to
ed308ae
Compare
Summary
Fixed some workspace watcher tests that are failing on macOS. They have had two problems:
Modify(Data)event after the file is already deleted. It triggered the workspace to re-index the file.Test Plan
I have tested on my own machine, and on GitHub Actions: https://github.com/biomejs/biome/actions/runs/17890793472/job/50870844033?pr=7549
Docs
N/A