Skip to content

Tests hang if no events are received #26

Closed
@jakerr

Description

I was doing some debugging of the tests trying to figure out why a CREATE event was delivered even though a file should have existed before the watch. My debugging uncovered a deadlock in watch when a sleep_ms is performed before it. Something about the CFRunLoop code I imagine but I couldn't track it down.

This causes the deadlock:

diff --git a/tests/notify.rs b/tests/notify.rs
index 7fb5bb9..73fb23f 100644
--- a/tests/notify.rs
+++ b/tests/notify.rs
@@ -25,6 +25,7 @@ fn validate_watch_single_file<F, W>(ctor: F) where
   let mut file = NamedTempFile::new().unwrap();
   let (tx, rx) = channel();
   let mut w = ctor(tx).unwrap();
+  thread::sleep_ms(1000);
   w.watch(file.path()).unwrap();
   thread::sleep_ms(1000);
   file.write_all(b"foo").unwrap();

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions