Skip to content

Commit c045633

Browse files
luispedrohs-viktor
authored andcommitted
Improve tests by using newer APIs
1 parent 5eb0993 commit c045633

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

tests/FileStatus.hs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import System.Posix.Directory
1010
import System.Posix.IO
1111
import Control.Exception as E
1212
import Control.Monad
13+
import Test.Tasty.HUnit
1314

1415
main = do
1516
cleanup
@@ -70,24 +71,16 @@ testLink = do
7071
createLink regular hlink_regular
7172
(fs, _) <- getStatus regular -- we need to retrieve it again as creating the link causes it to change!
7273
(fs', ls) <- getStatus hlink_regular
73-
let expected = (
74+
snd (statusElements ls) @?= (
7475
False, -- isBlockDevice
7576
False, -- isCharacterDevice
7677
False, -- isNamedPipe
7778
True, -- isRegularFile
7879
False, -- isDirectory
7980
False, -- isSymbolicLink
8081
False) -- isSocket
81-
actualF = snd (statusElements ls)
82-
83-
when (actualF /= expected) $
84-
fail "unexpected file status bits for hard link to regular file"
85-
86-
when (linkCount fs' /= 2) $
87-
fail "newly created hard link was expected to contain have a link count of 2"
88-
89-
when (statusElements fs /= statusElements fs') $
90-
fail "status for a file does not match when it's accessed via a link"
82+
linkCount fs' == 2 @? "Newly created hard link was expected to have a link count of 2"
83+
statusElements fs @?= statusElements fs' -- status for a file should match when accessed via a link
9184

9285

9386
cleanup = do

0 commit comments

Comments
 (0)