Fix tests
This commit is contained in:
parent
34fedd8ad3
commit
7ae22a9226
@ -243,6 +243,7 @@ Test-Suite spec
|
|||||||
Spec
|
Spec
|
||||||
TestUtils
|
TestUtils
|
||||||
BrowseSpec
|
BrowseSpec
|
||||||
|
CustomPackageDbSpec
|
||||||
CheckSpec
|
CheckSpec
|
||||||
FlagSpec
|
FlagSpec
|
||||||
InfoSpec
|
InfoSpec
|
||||||
|
@ -79,25 +79,3 @@ spec = do
|
|||||||
let ghcOpts = head opts
|
let ghcOpts = head opts
|
||||||
pkgs = pkgOptions ghcOpts
|
pkgs = pkgOptions ghcOpts
|
||||||
pkgs `shouldBe` ["Cabal","base"]
|
pkgs `shouldBe` ["Cabal","base"]
|
||||||
|
|
||||||
describe "getCustomPkgDbStack" $ do
|
|
||||||
it "works" $ do
|
|
||||||
let tdir = "test/data/custom-cradle"
|
|
||||||
Just stack <- runD' tdir $ getCustomPkgDbStack
|
|
||||||
stack `shouldBe` [ GlobalDb
|
|
||||||
, UserDb
|
|
||||||
, PackageDb "package-db-a"
|
|
||||||
, PackageDb "package-db-b"
|
|
||||||
, PackageDb "package-db-c"
|
|
||||||
]
|
|
||||||
|
|
||||||
describe "getPackageDbStack'" $ do
|
|
||||||
it "fixes out of sync custom pkg-db stack" $ do
|
|
||||||
withDirectory_ "test/data/custom-cradle" $ do
|
|
||||||
_ <- system "cabal configure"
|
|
||||||
(s, s') <- runD $ do
|
|
||||||
Just stack <- getCustomPkgDbStack
|
|
||||||
withCabal $ do
|
|
||||||
stack' <- getCabalPackageDbStack
|
|
||||||
return (stack, stack')
|
|
||||||
s' `shouldBe` s
|
|
||||||
|
35
test/CustomPackageDbSpec.hs
Normal file
35
test/CustomPackageDbSpec.hs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
module CustomPackageDbSpec where
|
||||||
|
|
||||||
|
import Language.Haskell.GhcMod.CabalHelper
|
||||||
|
import Language.Haskell.GhcMod.CustomPackageDb
|
||||||
|
import Language.Haskell.GhcMod.Error
|
||||||
|
import System.Process
|
||||||
|
import Test.Hspec
|
||||||
|
import Prelude
|
||||||
|
|
||||||
|
import Dir
|
||||||
|
import TestUtils
|
||||||
|
|
||||||
|
spec :: Spec
|
||||||
|
spec = do
|
||||||
|
describe "getCustomPkgDbStack" $ do
|
||||||
|
it "works" $ do
|
||||||
|
let tdir = "test/data/custom-cradle"
|
||||||
|
Just stack <- runD' tdir $ getCustomPkgDbStack
|
||||||
|
stack `shouldBe` [ GlobalDb
|
||||||
|
, UserDb
|
||||||
|
, PackageDb "package-db-a"
|
||||||
|
, PackageDb "package-db-b"
|
||||||
|
, PackageDb "package-db-c"
|
||||||
|
]
|
||||||
|
|
||||||
|
describe "getPackageDbStack'" $ do
|
||||||
|
it "fixes out of sync custom pkg-db stack" $ do
|
||||||
|
withDirectory_ "test/data/custom-cradle" $ do
|
||||||
|
_ <- system "cabal configure"
|
||||||
|
(s, s') <- runD $ do
|
||||||
|
Just stack <- getCustomPkgDbStack
|
||||||
|
withCabal $ do
|
||||||
|
stack' <- getCabalPackageDbStack
|
||||||
|
return (stack, stack')
|
||||||
|
s' `shouldBe` s
|
@ -2,6 +2,7 @@ module GhcPkgSpec where
|
|||||||
|
|
||||||
import Language.Haskell.GhcMod.GhcPkg
|
import Language.Haskell.GhcMod.GhcPkg
|
||||||
import Language.Haskell.GhcMod.CabalHelper
|
import Language.Haskell.GhcMod.CabalHelper
|
||||||
|
import Language.Haskell.GhcMod.CustomPackageDb
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import System.Process (system)
|
import System.Process (system)
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ module PathsAndFilesSpec where
|
|||||||
|
|
||||||
import Language.Haskell.GhcMod.PathsAndFiles
|
import Language.Haskell.GhcMod.PathsAndFiles
|
||||||
import Language.Haskell.GhcMod.Cradle
|
import Language.Haskell.GhcMod.Cradle
|
||||||
|
import qualified Language.Haskell.GhcMod.Utils as U
|
||||||
|
|
||||||
import Control.Monad.Trans.Maybe
|
import Control.Monad.Trans.Maybe
|
||||||
import System.Directory
|
import System.Directory
|
||||||
@ -25,10 +26,12 @@ spec = do
|
|||||||
|
|
||||||
describe "findCabalFile" $ do
|
describe "findCabalFile" $ do
|
||||||
it "works" $ do
|
it "works" $ do
|
||||||
findCabalFile "test/data/cabal-project" `shouldReturn` Just "test/data/cabal-project/cabalapi.cabal"
|
p <- U.makeAbsolute' "test/data/cabal-project/cabalapi.cabal"
|
||||||
|
findCabalFile "test/data/cabal-project" `shouldReturn` Just p
|
||||||
|
|
||||||
it "finds cabal files in parent directories" $ do
|
it "finds cabal files in parent directories" $ do
|
||||||
findCabalFile "test/data/cabal-project/subdir1/subdir2" `shouldReturn` Just "test/data/cabal-project/cabalapi.cabal"
|
p <- U.makeAbsolute' "test/data/cabal-project/cabalapi.cabal"
|
||||||
|
findCabalFile "test/data/cabal-project/subdir1/subdir2" `shouldReturn` Just p
|
||||||
|
|
||||||
describe "findStackConfigFile" $ do
|
describe "findStackConfigFile" $ do
|
||||||
it "works" $ do
|
it "works" $ do
|
||||||
@ -36,7 +39,9 @@ spec = do
|
|||||||
|
|
||||||
describe "findCabalSandboxDir" $ do
|
describe "findCabalSandboxDir" $ do
|
||||||
it "works" $ do
|
it "works" $ do
|
||||||
findCabalSandboxDir "test/data/cabal-project" `shouldReturn` Just "test/data/cabal-project"
|
p <- U.makeAbsolute' "test/data/cabal-project/cabalapi.cabal"
|
||||||
|
findCabalSandboxDir "test/data/cabal-project" `shouldReturn` Just p
|
||||||
|
|
||||||
it "finds sandboxes in parent directories" $ do
|
it "finds sandboxes in parent directories" $ do
|
||||||
findCabalSandboxDir "test/data/cabal-project/subdir1/subdir2" `shouldReturn` Just "test/data/cabal-project"
|
p <- U.makeAbsolute' "test/data/cabal-project/"
|
||||||
|
findCabalSandboxDir "test/data/cabal-project/subdir1/subdir2" `shouldReturn` Just p
|
||||||
|
Loading…
Reference in New Issue
Block a user