Subject: bug#21432: 25.0.50; file-notify-rm-watch (inotify) errors if watched dir is deleted

From: Eli Zaretskii <[email-masked]>
Date: Tue, 15 Sep 2015 15:51:16 +0300

> From: Michael Albinus <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Tue, 15 Sep 2015 13:54:08 +0200
> 
> It isn't clear to me why `file-notify--test-event-handler' hasn't
> been called for your test file. That must be something in
> w32notify.c.

What kind of "something"?  Notifications do work, and the rest of the
tests pass.  So it must be something with this particular test.

I think the problem is due to the fact that the directory is deleted
inside the file-notify--test-with-events form: doing that invalidates
the watch, so the events are not reported.  If I remove this line from
the macro body:

          (delete-directory temporary-file-directory t)

then the notifications are received as expected:

  Test file-notify-test04-file-validity condition:
      (ert-test-failed
       ((should
	 (equal '...
	  (mapcar ... events)))
	:form
	(equal
	 (created changed deleted)
	 (created changed))
	:value nil :explanation
	(proper-lists-of-different-length 3 2
					  (created changed deleted)
					  (created changed)
					  first-mismatch-at 2)))

(There's no "deleted" because it's caused by delete-directory call
which I removed.)

So I modified the test to have the directory deletion outside of the
macro, and the test now passes.  I also increased the timeout of
read-event, because 0.1 was borderline: it sometimes worked and
sometimes didn't.

Please see if the modified tests work with inotify (they did for me on
GNU/Linux).