@@ -19,7 +19,7 @@ import Control.Monad ( forM_ )
1919import Data.List ( sort , isPrefixOf )
2020import Data.Typeable
2121import System.Directory
22- import System.FilePath ((</>) )
22+ import System.FilePath ((</>) )
2323import System.Exit (ExitCode (ExitSuccess , ExitFailure ))
2424import Control.Monad.Extra (unlessM )
2525import qualified HIE.Bios.Ghc.Gap as Gap
@@ -48,17 +48,7 @@ main = do
4848
4949 defaultMainWithIngredients (ignoreToolTests: defaultIngredients) $
5050 testGroup " Bios-tests"
51- [ testGroup " Find cradle"
52- [ testCaseSteps " simple-cabal" $
53- runTestEnvLocal " ./simple-cabal" $ do
54- findCradleForModuleM " B.hs" (Just " hie.yaml" )
55-
56- -- Checks if we can find a hie.yaml even when the given filepath
57- -- is unknown. This functionality is required by Haskell IDE Engine.
58- , testCaseSteps " simple-cabal-unknown-path" $
59- runTestEnvLocal " ./simple-cabal" $ do
60- findCradleForModuleM " Foo.hs" (Just " hie.yaml" )
61- ]
51+ [ testGroup " Find cradle" findCradleTests
6252 , testGroup " Symlink" symbolicLinkTests
6353 , testGroup " Loading tests"
6454 [ testGroup " bios" biosTestCases
@@ -301,6 +291,26 @@ directTestCases =
301291 testDirectoryM isMultiCradle " B.hs"
302292 ]
303293
294+ findCradleTests :: [TestTree ]
295+ findCradleTests =
296+ [ cradleFileTest " Simple Existing File" " ./simple-cabal" " B.hs" (Just " hie.yaml" )
297+ -- Checks if we can find a hie.yaml even when the given filepath
298+ -- is unknown. This functionality is required by Haskell IDE Engine.
299+ , cradleFileTest " Existing File" " cabal-with-ghc" " src/MyLib.hs" (Just " hie.yaml" )
300+ , cradleFileTest " Non-existing file" " cabal-with-ghc" " src/MyLib2.hs" (Just " hie.yaml" )
301+ , cradleFileTest " Non-existing file 2" " cabal-with-ghc" " MyLib2.hs" (Just " hie.yaml" )
302+ , cradleFileTest " Directory 1" " cabal-with-ghc" " src/" (Just " hie.yaml" )
303+ , cradleFileTest " Directory 2" " simple-cabal" " " (Just " hie.yaml" )
304+ -- Unknown directory in a project, ought to work as well.
305+ , cradleFileTest " Directory 3" " simple-cabal" " src/" (Just " hie.yaml" )
306+ , cradleFileTest " Directory does not exist" " doesnotexist" " A.hs" Nothing
307+ ]
308+ where
309+ cradleFileTest :: String -> FilePath -> FilePath -> Maybe FilePath -> TestTree
310+ cradleFileTest testName dir fpTarget result = testCaseSteps testName $ do
311+ runTestEnv dir $ do
312+ findCradleForModuleM fpTarget result
313+
304314-- ------------------------------------------------------------------
305315-- Unit-test Helper functions
306316-- ------------------------------------------------------------------
0 commit comments