From c69b252e3c80a6e2f2b3243d01168583d27be2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Mon, 11 Aug 2014 23:42:16 +0200 Subject: [PATCH] Add failing test for runGhcModT --- test/MonadSpec.hs | 8 ++++++ .../.cabal-sandbox/packages/00-index.cache | 0 .../.cabal-sandbox/packages/00-index.tar | Bin 0 -> 10240 bytes .../data/broken-cabal/cabal.sandbox.config.in | 25 ++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 test/data/broken-cabal/.cabal-sandbox/packages/00-index.cache create mode 100644 test/data/broken-cabal/.cabal-sandbox/packages/00-index.tar create mode 100644 test/data/broken-cabal/cabal.sandbox.config.in diff --git a/test/MonadSpec.hs b/test/MonadSpec.hs index 7594e88..74404f1 100644 --- a/test/MonadSpec.hs +++ b/test/MonadSpec.hs @@ -1,6 +1,9 @@ +{-# LANGUAGE ScopedTypeVariables #-} module MonadSpec where import Test.Hspec +import Dir +import Control.Applicative import Control.Monad.Error.Class import Language.Haskell.GhcMod.Types import Language.Haskell.GhcMod.Monad @@ -17,3 +20,8 @@ spec = do return "hello" `catchError` (const $ fail "oh noes") a `shouldBe` (Left $ GMEString "oh noes") + + describe "runGhcModT" $ + it "complains if the cabal file fails to parse while a sandbox is present" $ withDirectory_ "test/data/broken-cabal" $ do + (a,_) <- runGhcModT defaultOptions (gmCradle <$> ask) + a `shouldSatisfy` (\(Left _) -> True) diff --git a/test/data/broken-cabal/.cabal-sandbox/packages/00-index.cache b/test/data/broken-cabal/.cabal-sandbox/packages/00-index.cache new file mode 100644 index 0000000..e69de29 diff --git a/test/data/broken-cabal/.cabal-sandbox/packages/00-index.tar b/test/data/broken-cabal/.cabal-sandbox/packages/00-index.tar new file mode 100644 index 0000000000000000000000000000000000000000..9df64990f7be3c1f7194a0c22852a1ab3a09f3c5 GIT binary patch literal 10240 zcmeIu0Sy2E0K%a6Pi+o2h(KY$fB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM P7%*VKfB^#r47?2tC;$Kf literal 0 HcmV?d00001 diff --git a/test/data/broken-cabal/cabal.sandbox.config.in b/test/data/broken-cabal/cabal.sandbox.config.in new file mode 100644 index 0000000..43e48ce --- /dev/null +++ b/test/data/broken-cabal/cabal.sandbox.config.in @@ -0,0 +1,25 @@ +-- This is a Cabal package environment file. +-- THIS FILE IS AUTO-GENERATED. DO NOT EDIT DIRECTLY. +-- Please create a 'cabal.config' file in the same directory +-- if you want to change the default settings for this sandbox. + + +local-repo: @CWD@/test/data/broken-cabal/.cabal-sandbox/packages +logs-dir: @CWD@/test/data/broken-cabal/.cabal-sandbox/logs +world-file: @CWD@/test/data/broken-cabal/.cabal-sandbox/world +user-install: False +package-db: @CWD@/test/data/broken-cabal/.cabal-sandbox/x86_64-linux-ghc-7.8.3-packages.conf.d +build-summary: @CWD@/test/data/broken-cabal/.cabal-sandbox/logs/build.log + +install-dirs + prefix: @CWD@/test/data/broken-cabal/.cabal-sandbox + bindir: $prefix/bin + libdir: $prefix/lib + libsubdir: $arch-$os-$compiler/$pkgid + libexecdir: $prefix/libexec + datadir: $prefix/share + datasubdir: $arch-$os-$compiler/$pkgid + docdir: $datadir/doc/$arch-$os-$compiler/$pkgid + htmldir: $docdir/html + haddockdir: $htmldir + sysconfdir: $prefix/etc