on aa2b166 help sign in
86 lines 3.0 kB history raw
1-- |
2-- Module : Streamly.Test.FileSystem.Event.Darwin
3-- Copyright : (c) 2020 Composewell Technologies
4-- License : BSD-3-Clause
5-- Maintainer : streamly@composewell.com
6-- Stability : experimental
7-- Portability : GHC
8--
9module Streamly.Test.FileSystem.Event.Darwin (main) where
11import qualified Streamly.Internal.FileSystem.Event.Darwin as Event
13import Streamly.Test.FileSystem.Event.Common
15moduleName :: String
16moduleName = "FileSystem.Event.Darwin"
18-- TODO:
19-- Creation/deletion/move of hard links
20-- Deletion of last hard link
21-- If a directory is a symlink is it followed in recursive mode?
23main :: IO ()
24main = do
25 let symLinkRootTests =
26 dirCreateWithParent "subdir/dir"
27 (\dir -> [(dir, dirEvent Event.isCreated)])
28 : fileCreateWithParent "subdir/file"
29 (\file ->
30 [ (file, fileEvent Event.isCreated)
31 , (file, fileEvent Event.isAttrsModified)
32 ]
33 )
34 : fileCreate "file-create-attrs"
35 (\file ->
36 [ (file, fileEvent Event.isCreated)
37 , (file, fileEvent Event.isAttrsModified)
38 ]
39 )
40 : fileModify
41 "file-mod-attrs"
42 (\file -> [(file, fileEvent Event.isAttrsModified)])
43 : dirDelete "dir-sec" (\dir ->
44 [ (dir, dirEvent Event.isDeleted)
45 , (dir, dirEvent Event.isSecurityModified)
46 ]
47 )
48 : commonTests
49 ++ commonRecTests
50 let regularRootTests =
51 dirDelete "" (\dir ->
52 [ (dir, dirEvent Event.isDeleted)
53 , (dir, dirEvent Event.isSecurityModified)
54 , (dir, Event.isRootPathEvent)
55 ]
56 )
57 -- The watch root create event always seems to come even though the
58 -- root is created before the watch is started. That may be because
59 -- of batching?
60 -- XXX Need to create watch root after adding the watch, otherwise
61 -- it fails intermittently.
62 -- : dirCreate "" (\dir -> [(dir, dirEvent Event.isCreated)])
63 : rootDirMove "moved" (\src ->
64 [ (src, Event.isRootPathEvent)
65 , (src, Event.isMoved)
66 ])
67 : symLinkRootTests
69 let fileRootTests =
70 [ fileDelete "" (\path ->
71 [ (path, Event.isRootPathEvent)
72 , (path, Event.isDeleted)
73 ])
74 , rootFileMove "moved" (\path ->
75 [(path, Event.isRootPathEvent)
76 , (path, Event.isMoved)
77 ])
78 , fileModify "" (const [])
79 ]
81 let w = Event.watchWith (Event.setAllEvents Event.On)
82 run = runTests moduleName "recursive" w
84 run DirType regularRootTests
85 run SymLinkResolvedPath symLinkRootTests
86 run FileType fileRootTests