directory_to_file &&
- test-tool fsmonitor-client query --token 0 &&
-
- grep "^event: dir1$" .git/trace
+ retry_grep "^event: dir1$" .git/trace
'
+test_expect_success 'rapid nested directory creation' '
+ test_when_finished "git fsmonitor--daemon stop; rm -rf rapid" &&
+
+ start_daemon --tf "$PWD/.git/trace" &&
+
+ # Rapidly create nested directories to exercise race conditions
+ # where directory watches may be added concurrently during
+ # event processing and recursive scanning.
+ for i in $(test_seq 1 20)
+ do
+ mkdir -p "rapid/nested/dir$i/subdir/deep" || return 1
+ done &&
+
+ # Give the daemon time to process all events
+ sleep 1 &&
+
+ test-tool fsmonitor-client query --token 0 &&
+
+ # Verify daemon is still running (did not crash)
+ git fsmonitor--daemon status
+'
+
# The next few test cases exercise the token-resync code. When filesystem
# drops events (because of filesystem velocity or because the daemon isn't
# polling fast enough), we need to discard the cached data (relative to the