File: test005-move-file.hs

package info (click to toggle)
haskell-hinotify 0.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 144 kB
  • sloc: haskell: 271; sh: 25; makefile: 6
file content (46 lines) | stat: -rw-r--r-- 919 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module Main where

import Data.Maybe

import Control.Monad

import System.Directory
import System.IO

import System.INotify as INotify

import Utils

file = "hello"
file2 = file ++ "2"

write path = do
    writeFile (path ++ '/':file) ""

move path = do
    renameFile (path ++ '/':file) (path ++ '/':file2)

remove path = do
    removeFile (path ++ '/':file2)

action path = do
    write path
    move path
    remove path
    
main =
    inTestEnviron [AllEvents] action $ \ events -> do
        let cookie = head [ c | MovedOut _ _ c <- events ]
        when (expected cookie ~= events)
            testSuccess
        explainFailure (expected cookie) events

expected cookie =
    [ Created   False file
    , Opened    False (Just file)
    , Modified  False (Just file)
    , Closed    False (Just file) True
    , MovedOut  False file  cookie
    , MovedIn   False file2 cookie
    , Deleted   False file2
    ]