Add first simple test case.
authorOlof-Joachim Frahm <olof@macrolet.net>
Thu, 15 Jan 2015 23:36:12 +0000 (23:36 +0000)
committerOlof-Joachim Frahm <olof@macrolet.net>
Fri, 16 Jan 2015 00:49:28 +0000 (00:49 +0000)
tests/inotify.lisp

index 9458654..585a166 100644 (file)
 (in-package #:cl-inotify-tests)
 
 (in-suite cl-inotify)
+\f
+;; note that for all of these tests other programs might interfere, so
+;; they might fail for no apparent reason
+
+(def-test read-raw-event-from-stream.1 ()
+  (let ((tmp (osicat-posix:mkdtemp
+              (concatenate 'string
+                           (namestring osicat:*temporary-directory*)
+                           "cl-inotify-XXXXXX"))))
+    (with-unregistered-inotify (inotify T (tmp :all-events))
+      (ensure-directories-exist (concatenate 'string tmp "/foo/"))
+      (unwind-protect
+           (let ((available (event-available-p inotify)))
+             (is-true available "No event was read")
+             (when available
+               (let ((event (read-raw-event-from-stream (inotify-stream inotify))))
+                 (is-true event "No event was read")
+                 (is (equal "foo" (inotify-event-name event))))))
+        (osicat:delete-directory-and-files tmp)))))