summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRüdiger Sonderfeld <ruediger@c-plusplus.de>2012-12-10 06:17:21 -0500
committerEli Zaretskii <eliz@gnu.org>2012-12-10 06:17:21 -0500
commit81606b10501169a5671061b8461bbc32dcec8705 (patch)
tree6dadb650dc1950fbb1e5d4cf6f0c8d18588e6787 /test
parent265c2fbf11cb8bf9b805df63ecb9508631f08e35 (diff)
downloademacs-81606b10501169a5671061b8461bbc32dcec8705.tar.gz
Support filesystem notification through inotify on GNU/Linux.
configure.ac (inotify): New option. (HAVE_INOTIFY): Test for inotify. src/termhooks.h (enum event_kind) [HAVE_INOTIFY]: Add FILE_NOTIFY_EVENT. src/lisp.h (syms_of_inotify) [HAVE_INOTIFY]: Add prototype. src/keyboard.c (Qfile_inotify) [HAVE_INOTIFY]: New variable. (syms_of_keyboard): DEFSYM it. (kbd_buffer_get_event) [HAVE_INOTIFY]: Generate FILE_NOTIFY_EVENT. (make_lispy_event): Support FILE_NOTIFY_EVENT by generating Qfile_inotify events. (keys_of_keyboard) [HAVE_INOTIFY]: Bind file-inotify events in special-event-map to inotify-handle-event. src/emacs.c (main) [HAVE_INOTIFY]: Call syms_of_inotify. src/Makefile.in (base_obj): Add inotify.o. src/inotify.c: New file. lisp/subr.el (inotify-event-p, inotify-handle-event): New functions. test/automated/inotify-test.el: New test.
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog4
-rw-r--r--test/automated/inotify-test.el60
2 files changed, 64 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 21f0f29b73b..7633d974f57 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
+2012-12-10 Rüdiger Sonderfeld <ruediger@c-plusplus.de>
+
+ * automated/inotify-test.el: New test.
+
2012-12-02 Chong Yidong <cyd@gnu.org>
* automated/ruby-mode-tests.el
diff --git a/test/automated/inotify-test.el b/test/automated/inotify-test.el
new file mode 100644
index 00000000000..edda7ef0418
--- /dev/null
+++ b/test/automated/inotify-test.el
@@ -0,0 +1,60 @@
+;;; inotify-tests.el --- Test suite for inotify. -*- lexical-binding: t -*-
+
+;; Copyright (C) 2012 Free Software Foundation, Inc.
+
+;; Author: Rüdiger Sonderfeld <ruediger@c-plusplus.de>
+;; Keywords: internal
+;; Human-Keywords: internal
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+
+(when (featurep 'inotify)
+
+ ;; (ert-deftest filewatch-file-watch-aspects-check ()
+ ;; "Test whether `file-watch' properly checks the aspects."
+ ;; (let ((temp-file (make-temp-file "filewatch-aspects")))
+ ;; (should (stringp temp-file))
+ ;; (should-error (file-watch temp-file 'wrong nil)
+ ;; :type 'error)
+ ;; (should-error (file-watch temp-file '(modify t) nil)
+ ;; :type 'error)
+ ;; (should-error (file-watch temp-file '(modify all-modify) nil)
+ ;; :type 'error)
+ ;; (should-error (file-watch temp-file '(access wrong modify) nil)
+ ;; :type 'error)))
+
+ (ert-deftest inotify-file-watch-simple ()
+ "Test if watching a normal file works."
+ (let ((temp-file (make-temp-file "inotify-simple"))
+ (events 0))
+ (let ((wd
+ (inotify-add-watch temp-file t (lambda (ev)
+ (setq events (1+ events))))))
+ (unwind-protect
+ (progn
+ (with-temp-file temp-file
+ (insert "Foo\n"))
+ (sit-for 5) ;; Hacky. Wait for 5s until events are processed
+ (should (> events 0)))
+ (inotify-rm-watch wd)))))
+)
+
+(provide 'inotify-tests)
+;;; inotify-tests.el ends here.