Commit graph

87 commits

Author SHA1 Message Date
d674f255e6
docs: improve macos_fsevents option description 2026-03-13 07:43:41 +01:00
6b0cbe7171
build: add option to install tests 2026-03-09 12:19:23 +01:00
5b2962fdc0
build: rename test executable 2026-03-09 12:15:52 +01:00
2aa3c1afc7
refactor: clean-up empty test targets 2026-03-09 12:14:14 +01:00
163150690f
feat(cli): add colored output when stdout is a tty 2026-03-09 11:56:09 +01:00
19b7fd4c4a
refactor: move on watch messages to stdout 2026-03-09 11:45:53 +01:00
7b47ff775a
refactor: comment on watch messages 2026-03-09 11:42:40 +01:00
e0eac53bca
fix: flush stderr after watch startup 2026-03-09 11:39:58 +01:00
d1864f26fb
fix: cli should use the selected watcher interface 2026-03-09 11:37:40 +01:00
adc8f81b4f
refactor: run tests for all available variants 2026-03-09 11:33:40 +01:00
0813294652
refactor: select fsevents by default if it is enabled in build 2026-03-09 11:19:32 +01:00
b82c86acc9
refactor: misc cleanup 2026-03-09 11:17:59 +01:00
dd2bbb66ed
refactor: use polling interface on linux in nightwatch cli 2026-03-09 11:14:47 +01:00
6f8cfc946b
refactor: misc minor clean-ups 2026-03-09 11:02:47 +01:00
aa4e2920dd
build: allow selecting a backend at comptime instead of via a build flag 2026-03-09 10:46:29 +01:00
6930adae7f
refactor: re-organize backends into separate files 2026-03-09 09:51:01 +01:00
e5373cb143
build: remove unused flags dep 2026-03-08 22:17:36 +01:00
dfebd9ba4b
feat: add --ignore option to cli 2026-03-08 22:17:09 +01:00
37f16a03b7
refactor: make detects_file_modifications a backend member 2026-03-08 22:04:01 +01:00
08ff4a6231
feat: add alternate directory only kqueue backend 2026-03-08 22:02:34 +01:00
3ba8b2bac5
refactor: arean allocate temporaries in kqueue backend 2026-03-08 21:24:33 +01:00
0548953460
refactor: move pending_renames so we don't have to re-allocate it all the time 2026-03-08 21:20:20 +01:00
e3c093c729
refactor: fixup windows backend allocator usage 2026-03-08 20:57:08 +01:00
0dcd30acb4
feat: add object type to APIs and CLI output 2026-03-08 20:49:49 +01:00
a2523a5b53
docs: add some more platform support details to the readme 2026-03-08 20:11:18 +01:00
a951162c52
docs: reformat README.md 2026-03-08 20:10:56 +01:00
0f048dc47d
build: add the other BSDs 2026-03-08 20:06:56 +01:00
1e29da7765
fix(fsevents): fix FSEvents backend
Three bugs caused all integration tests to fail with -Dmacos_fsevents=true:

- FSEventStreamCreate was passed *CallbackContext directly as the context
  parameter, which expects *FSEventStreamContext (a struct with version=0,
  info=ptr, retain/release/copyDescription). The handler pointer landed in
  the version field (must be 0) and info received by callbacks was garbage,
  so the callback returned immediately on every event.

- FSEvents coalesces operations into a single delivery with multiple flags
  set (e.g. ItemCreated|ItemModified, ItemRenamed|ItemModified). The
  callback used an if/else chain that only emitted the first matching event
  type, so a write coalesced with a create or rename produced no 'modified'
  event. Fixed by checking each flag independently.

- FSEvents delivers spurious historical events for watched root directories
  at stream start (even with kFSEventStreamEventIdSinceNow), causing
  phantom dir_created events. Fixed by snapshotting the watched root paths
  in CallbackContext at arm() time and skipping events whose path exactly
  matches a root.

Also: arm() is now a no-op when no paths are watched yet (stream starts on
the first add_watch call), add_watch/remove_watch restart the stream so
paths added or removed take effect immediately, and makeTempDir resolves
/tmp to /private/tmp on macOS so test-constructed paths match FSEvents
canonical output.
2026-03-08 14:11:41 +01:00
4a8ab550e9
build: rename use_fsevents build option to macos_fsevents 2026-03-08 09:57:30 +01:00
82344d475b
refactor: enable linux background read thread by default 2026-03-08 09:49:25 +01:00
5502f8940a
feat: add support for a background read thread in linux too 2026-03-08 09:49:03 +01:00
1cbbdbd3cb
docs: add a basic manual test script for windows 2026-03-08 09:22:49 +01:00
7851312cfe
fix(windows): more cross platform path join to fix tests on windows 2026-03-08 09:22:32 +01:00
8491389023
fix(windows): use cross platform path join to fix tests on windows 2026-03-07 21:38:11 +01:00
24a3537ef8
fix(windows): use proper temp dir for testing on windows 2026-03-07 21:37:19 +01:00
240f3f148f
fix(linux): prevent double delete notification on directories 2026-03-07 21:14:48 +01:00
d66fd9348a
docs: add simple manual test script 2026-03-07 21:12:30 +01:00
5deb3dfa8b
fix: don't resolve symlinks when making a relative path absolute
Using realpath() in watch() caused events to be emitted under the resolved
path (e.g. /private/tmp/...) rather than the path the caller provided (e.g.
/tmp/..., where /tmp is a symlink on macOS). This broke all integration
tests on macOS since the test file paths didn't match the emitted event
paths.

For absolute paths, use them unchanged. For relative paths, join with the
current working directory without further symlink resolution. This
preserves the caller's view of the path while still satisfying the kqueue
backend's requirement for absolute paths.
2026-03-07 20:49:03 +01:00
eab9b328ba
fix(kqueue): dangling stack pointer to full_path 2026-03-07 20:34:32 +01:00
db7d954a50
fix: automatically bump the kqueue file limit to the hard limit 2026-03-07 20:33:27 +01:00
8ad17f5189
fix: make sure paths are absolute before watching them 2026-03-07 20:32:13 +01:00
3554794234
fix(kqueue): add per-file watches to detect modifications and fix rename ordering
kqueue's NOTE_WRITE on a directory fires only when directory entries are
added or removed, not when file contents change. This meant writes to
existing files were never reported as 'modified' events on macOS/FreeBSD.

Fix by maintaining a second set of kqueue watches on individual files
(file_watches), registered with NOTE_WRITE|NOTE_EXTEND. When either flag
fires on a file fd, a 'modified' event is emitted. File watches are
registered in take_snapshot (for files already present when watch() is
called) and in scan_dir (for newly created files), and deregistered when
files are deleted or the directory is unwatched.

Also fix two related bugs:
- NOTE_DELETE was incorrectly defined as 0x04 (NOTE_EXTEND); the correct
  value is 0x01. This could cause NOTE_EXTEND events on watched directories
  to be misreported as directory-deleted events.
- scan_dir emitted created events before deleted events, so a rename
  (old name disappears, new name appears) reported the destination before
  the source. Swapped the order so deletions are always emitted first.

Simplify thread_fn/arm to pass *KQueueBackend directly now that the backend
lives at a stable heap address inside the heap-allocated Interceptor.

All 10 integration tests now pass on FreeBSD.
2026-03-07 20:18:05 +01:00
ae4b56b62a
fix: dangling interceptor crash 2026-03-07 20:02:40 +01:00
9b4d7c2121
feat: implement auto subdirectory watching for platforms that don't watch trees 2026-03-07 19:54:49 +01:00
9dda7efc25
refactor: add a little flair 2026-03-07 19:24:40 +01:00
4569a33382
fix: windows build 2026-03-07 19:20:30 +01:00
e4cc1b82fe
feat: add basic command line executable 2026-03-07 19:10:48 +01:00
f3463dd0dc
fix(kqueue): emit scan_dir events outside the snapshot lock
Handler callbacks invoked while holding snapshots_mutex could deadlock if
the handler called watch() or unwatch(), which also acquires that lock.
Refactor scan_dir to collect all pending events (dir_created, created,
deleted) into temporary lists under the lock, then emit them after
releasing it. Also consolidate the two directory iteration passes into one.
2026-03-07 18:19:00 +01:00
8dc759db61
fix: add a watches mutex to kqueue 2026-02-26 14:55:38 +01:00
9679b0cedf
fix: more test fixes 2026-02-26 14:47:38 +01:00