Skip to content

Commit

Permalink
Fix bug in IO test directory traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
olorin committed Mar 30, 2016
1 parent 44d25f7 commit 9cd53d6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/Test/IO/Warden.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import Test.Warden.Arbitrary

import Warden.Data
import Warden.Error
import Warden.View

import X.Control.Monad.Trans.Either

Expand Down Expand Up @@ -153,7 +152,10 @@ traverseTestDirectory :: DirName -> EitherT WardenError (ResourceT IO) [FilePath
traverseTestDirectory dn =
fmap directoryFiles $ traverseTestDirectory' (MaxDepth 10) [] dn

traverseTestDirectory' :: MaxDepth -> [DirName] -> DirName -> EitherT WardenError (ResourceT IO) DirTree
traverseTestDirectory' :: MaxDepth
-> [DirName]
-> DirName
-> EitherT WardenError (ResourceT IO) DirTree
traverseTestDirectory' (MaxDepth 0) _ _ = left $ WardenTraversalError MaxDepthExceeded
traverseTestDirectory' (MaxDepth depth) preds dn =
let preds' = preds <> [dn] in do
Expand All @@ -162,7 +164,7 @@ traverseTestDirectory' (MaxDepth depth) preds dn =
let branches = fmap (DirName . fst) $
filter (uncurry visitable) $ zip ls sts
let leaves = fmap (FileName . fst) $ filter (uncurry validLeaf) $ zip ls sts
subtrees <- mapM (traverseDirectory (MaxDepth $ depth - 1) preds') branches
subtrees <- mapM (traverseTestDirectory' (MaxDepth $ depth - 1) preds') branches
pure $ DirTree dn subtrees leaves
where
visitable ('.':_) _ = False
Expand Down

0 comments on commit 9cd53d6

Please sign in to comment.