aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRüdiger Sonderfeld2012-12-10 06:17:21 -0500
committerEli Zaretskii2012-12-10 06:17:21 -0500
commit81606b10501169a5671061b8461bbc32dcec8705 (patch)
tree6dadb650dc1950fbb1e5d4cf6f0c8d18588e6787 /test
parent265c2fbf11cb8bf9b805df63ecb9508631f08e35 (diff)
downloademacs-81606b10501169a5671061b8461bbc32dcec8705.tar.gz
emacs-81606b10501169a5671061b8461bbc32dcec8705.zip
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 @@
12012-12-10 Rüdiger Sonderfeld <ruediger@c-plusplus.de>
2
3 * automated/inotify-test.el: New test.
4
12012-12-02 Chong Yidong <cyd@gnu.org> 52012-12-02 Chong Yidong <cyd@gnu.org>
2 6
3 * automated/ruby-mode-tests.el 7 * 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 @@
1;;; inotify-tests.el --- Test suite for inotify. -*- lexical-binding: t -*-
2
3;; Copyright (C) 2012 Free Software Foundation, Inc.
4
5;; Author: Rüdiger Sonderfeld <ruediger@c-plusplus.de>
6;; Keywords: internal
7;; Human-Keywords: internal
8
9;; This file is part of GNU Emacs.
10
11;; GNU Emacs is free software: you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
13;; the Free Software Foundation, either version 3 of the License, or
14;; (at your option) any later version.
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23
24;;; Code:
25
26(require 'ert)
27
28(when (featurep 'inotify)
29
30 ;; (ert-deftest filewatch-file-watch-aspects-check ()
31 ;; "Test whether `file-watch' properly checks the aspects."
32 ;; (let ((temp-file (make-temp-file "filewatch-aspects")))
33 ;; (should (stringp temp-file))
34 ;; (should-error (file-watch temp-file 'wrong nil)
35 ;; :type 'error)
36 ;; (should-error (file-watch temp-file '(modify t) nil)
37 ;; :type 'error)
38 ;; (should-error (file-watch temp-file '(modify all-modify) nil)
39 ;; :type 'error)
40 ;; (should-error (file-watch temp-file '(access wrong modify) nil)
41 ;; :type 'error)))
42
43 (ert-deftest inotify-file-watch-simple ()
44 "Test if watching a normal file works."
45 (let ((temp-file (make-temp-file "inotify-simple"))
46 (events 0))
47 (let ((wd
48 (inotify-add-watch temp-file t (lambda (ev)
49 (setq events (1+ events))))))
50 (unwind-protect
51 (progn
52 (with-temp-file temp-file
53 (insert "Foo\n"))
54 (sit-for 5) ;; Hacky. Wait for 5s until events are processed
55 (should (> events 0)))
56 (inotify-rm-watch wd)))))
57)
58
59(provide 'inotify-tests)
60;;; inotify-tests.el ends here.