Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Commit

Permalink
Skip tests when no package index available (fixes commercialhaskell/s…
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Feb 8, 2016
1 parent 8a3a4dd commit f11ff15
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions stackage-curator.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ test-suite spec
, containers
, http-client
, http-client-tls
, directory

source-repository head
type: git
Expand Down
14 changes: 12 additions & 2 deletions test/Stackage/PackageIndexSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import Stackage.PackageIndex
import Stackage.Prelude
import Test.Hspec
import Distribution.Package (packageId)
import System.Directory (doesFileExist, getAppUserDataDirectory)

spec :: Spec
spec = do
it "works" $ (runResourceT $ sourcePackageIndex $$ sinkNull :: IO ())
it "getLatestDescriptions gives reasonable results" $ do
it "works" $ ifIndexExists $ (runResourceT $ sourcePackageIndex $$ sinkNull :: IO ())
it "getLatestDescriptions gives reasonable results" $ ifIndexExists $ do
let f x y = (display x, display y) `member` asSet (setFromList
[ (asText "base", asText "4.5.0.0")
, ("does-not-exist", "9999999999999999999")
Expand All @@ -19,3 +20,12 @@ spec = do
p <- simpleParse $ asText "base"
v <- simpleParse $ asText "4.5.0.0"
(spdVersion <$> m) `shouldBe` singletonMap p v

ifIndexExists :: IO () -> IO ()
ifIndexExists inner = do
stack <- getAppUserDataDirectory "stack"
let fp = stack </> "indices" </> "Hackage" </> "00-index.tar"
exists <- doesFileExist fp
if exists
then inner
else pendingWith "00-index.tar not available, skipping test"

0 comments on commit f11ff15

Please sign in to comment.