From 1050ea3c6368ad9d1e62acf6ed5d5f0e14f0665b Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Sat, 21 Sep 2013 15:32:22 +0900 Subject: [PATCH] more tests. --- ghc-mod.cabal | 13 ++++++++----- test/CradleSpec.hs | 11 ++++++++++- test/data/broken-sandbox/cabal.sandbox.config | 1 + test/data/broken-sandbox/dummy.cabal | 1 + 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 test/data/broken-sandbox/cabal.sandbox.config create mode 100644 test/data/broken-sandbox/dummy.cabal diff --git a/ghc-mod.cabal b/ghc-mod.cabal index 5882db5..06dca2f 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -28,14 +28,17 @@ Extra-Source-Files: ChangeLog test/data/*.hs test/data/cabal.sandbox.config test/data/.cabal-sandbox/i386-osx-ghc-7.6.3-packages.conf.d/dummy - test/data/ghc-mod-check/*.hs - test/data/ghc-mod-check/*.cabal - test/data/ghc-mod-check/Data/*.hs - test/data/subdir1/subdir2/dummy + test/data/broken-cabal/*.cabal + test/data/broken-sandbox/*.cabal + test/data/broken-sandbox/cabal.sandbox.config test/data/check-test-subdir/*.cabal + test/data/check-test-subdir/src/Check/Test/*.hs test/data/check-test-subdir/test/*.hs test/data/check-test-subdir/test/Bar/*.hs - test/data/check-test-subdir/src/Check/Test/*.hs + test/data/ghc-mod-check/*.cabal + test/data/ghc-mod-check/*.hs + test/data/ghc-mod-check/Data/*.hs + test/data/subdir1/subdir2/dummy Library Default-Language: Haskell2010 diff --git a/test/CradleSpec.hs b/test/CradleSpec.hs index 2c6d12e..bba4199 100644 --- a/test/CradleSpec.hs +++ b/test/CradleSpec.hs @@ -22,7 +22,6 @@ spec = do , cradleCabalFile = Nothing , cradlePackageDbOpts = [] } - it "finds a cabal file and a sandbox" $ do withDirectory "test/data/subdir1/subdir2" $ \dir -> do res <- relativeCradle dir <$> findCradle @@ -32,6 +31,16 @@ spec = do , cradleCabalFile = Just ("test" "data" "cabalapi.cabal") , cradlePackageDbOpts = ["-no-user-package-db", "-package-db", "test" "data" ".cabal-sandbox" "i386-osx-ghc-7.6.3-packages.conf.d"] } + it "works even if a sandbox config file is broken" $ do + withDirectory "test/data/broken-sandbox" $ \dir -> do + res <- relativeCradle dir <$> findCradle + res `shouldBe` Cradle { + cradleCurrentDir = "test" "data" "broken-sandbox" + , cradleCabalDir = Just ("test" "data" "broken-sandbox") + , cradleCabalFile = Just ("test" "data" "broken-sandbox" "dummy.cabal") + , cradlePackageDbOpts = [] + } + describe "getPackageDbDir" $ do it "parses a config file and extracts package db" $ do pkgDb <- getPackageDbDir "test/data/cabal.sandbox.config" diff --git a/test/data/broken-sandbox/cabal.sandbox.config b/test/data/broken-sandbox/cabal.sandbox.config new file mode 100644 index 0000000..57f89ed --- /dev/null +++ b/test/data/broken-sandbox/cabal.sandbox.config @@ -0,0 +1 @@ +broken diff --git a/test/data/broken-sandbox/dummy.cabal b/test/data/broken-sandbox/dummy.cabal new file mode 100644 index 0000000..421376d --- /dev/null +++ b/test/data/broken-sandbox/dummy.cabal @@ -0,0 +1 @@ +dummy