Stefan Saasen avatar Stefan Saasen committed 26f5d01

Fix tests after moving from hfsevents to fsnotify

Comments (0)

Files changed (2)

src/Spy/Watcher.hs

 spy :: Spy -> IO String
 spy config = withManager $ \wm ->
   watchTree wm (decodeString $ dir config)
-              (not . skipEvent config)
+              (not . skipEvent config . eventPath)
               (handleEvent config) >>
   getLine
 
 
 
 -- | Skip events based on the configuration given
-skipEvent :: Spy -> Event -> Bool
-skipEvent config event = skipHidden || skipNonMatchingGlob
+skipEvent :: Spy -> FilePath -> Bool
+skipEvent config path = skipHidden || skipNonMatchingGlob
     where skipHidden            = let includeHiddenfiles = hidden config
                                   in not includeHiddenfiles && containsHiddenPathElement path
           skipNonMatchingGlob   = maybe False (not . matchesFile path) $ glob config
-          path                  = eventPath event
 
 eventTime :: Event -> UTCTime
 eventTime (Added _ t) = t
 
 import qualified Test.HUnit as H
 import Data.Maybe
-import System.OSX.FSEvents
 import Spy.Watcher
 import Test.QuickCheck hiding ((.&.))
 import Test.Framework (Test, defaultMain, testGroup)
 
 test_skipEventHidden = H.assertBool
   "Skip path if hidden directory and showing hidden files is not enabled"
-  (skipEvent (mockWatch {hidden = False}) (mockEvent "/a/b/.git/refs"))
+  (skipEvent (mockWatch {hidden = False}) "/a/b/.git/refs")
 
 test_containsHiddenPathElement = H.assertBool
   "Should identify hidden directory"
 mockWatch :: Spy
 mockWatch = Watch { dir = ".", glob = Nothing, format = Nothing, hidden = False }
 
-mockEvent :: FilePath -> Event
-mockEvent path = Event path 0x00000001 0x00000001
-------------------------------------------------------------------------
+-- ===========================================================
 -- Test harness
 
 main :: IO ()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.