summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/TestDocs.hs24
-rw-r--r--tests/TestPscPublish.hs26
2 files changed, 33 insertions, 17 deletions
diff --git a/tests/TestDocs.hs b/tests/TestDocs.hs
index 5fdb416..91bdf52 100644
--- a/tests/TestDocs.hs
+++ b/tests/TestDocs.hs
@@ -18,6 +18,7 @@ import System.Exit
import qualified Language.PureScript as P
import qualified Language.PureScript.Docs as Docs
import qualified Language.PureScript.Publish as Publish
+import qualified Language.PureScript.Publish.ErrorsWarnings as Publish
import TestUtils
@@ -29,16 +30,19 @@ publishOpts = Publish.defaultPublishOptions
where testVersion = ("v999.0.0", Version [999,0,0] [])
main :: IO ()
-main = do
- pushd "examples/docs" $ do
- Docs.Package{..} <- Publish.preparePackage publishOpts
- forM_ testCases $ \(P.moduleNameFromString -> mn, pragmas) ->
- let mdl = takeJust ("module not found in docs: " ++ P.runModuleName mn)
- (find ((==) mn . Docs.modName) pkgModules)
- in forM_ pragmas (flip runAssertionIO mdl)
+main = pushd "examples/docs" $ do
+ res <- Publish.preparePackage publishOpts
+ case res of
+ Left e -> Publish.printErrorToStdout e >> exitFailure
+ Right Docs.Package{..} ->
+ forM_ testCases $ \(P.moduleNameFromString -> mn, pragmas) ->
+ let mdl = takeJust ("module not found in docs: " ++ P.runModuleName mn)
+ (find ((==) mn . Docs.modName) pkgModules)
+ in forM_ pragmas (`runAssertionIO` mdl)
+
takeJust :: String -> Maybe a -> a
-takeJust msg = maybe (error msg) id
+takeJust msg = fromMaybe (error msg)
data Assertion
-- | Assert that a particular declaration is documented with the given
@@ -254,8 +258,8 @@ testCases =
, ("ExplicitTypeSignatures",
[ ValueShouldHaveTypeSignature (n "ExplicitTypeSignatures") "explicit" (ShowFn (hasTypeVar "something"))
- , ValueShouldHaveTypeSignature (n "ExplicitTypeSignatures") "anInt" (ShowFn ((==) P.tyInt))
- , ValueShouldHaveTypeSignature (n "ExplicitTypeSignatures") "aNumber" (ShowFn ((==) P.tyNumber))
+ , ValueShouldHaveTypeSignature (n "ExplicitTypeSignatures") "anInt" (ShowFn (P.tyInt ==))
+ , ValueShouldHaveTypeSignature (n "ExplicitTypeSignatures") "aNumber" (ShowFn (P.tyNumber ==))
])
]
diff --git a/tests/TestPscPublish.hs b/tests/TestPscPublish.hs
index 49321ed..af84c96 100644
--- a/tests/TestPscPublish.hs
+++ b/tests/TestPscPublish.hs
@@ -19,12 +19,12 @@ import Data.Version
import Language.PureScript.Docs
import Language.PureScript.Publish
+import Language.PureScript.Publish.ErrorsWarnings as Publish
import TestUtils
main :: IO ()
-main = do
- testPackage "tests/support/prelude"
+main = testPackage "tests/support/prelude"
data TestResult
= ParseFailed String
@@ -53,14 +53,26 @@ testRunOptions = defaultPublishOptions
-- | Given a directory which contains a package, produce JSON from it, and then
-- | attempt to parse it again, and ensure that it doesn't change.
testPackage :: String -> IO ()
-testPackage dir = do
- pushd dir $ do
- r <- roundTrip <$> preparePackage testRunOptions
- case r of
+testPackage dir = pushd dir $ do
+ res <- preparePackage testRunOptions
+ case res of
+ Left e -> preparePackageError e
+ Right package -> case roundTrip package of
Pass _ -> do
putStrLn ("psc-publish test passed for: " ++ dir)
pure ()
other -> do
putStrLn ("psc-publish tests failed on " ++ dir ++ ":")
- putStrLn (show other)
+ print other
exitFailure
+ where
+ preparePackageError e@(UserError BowerJSONNotFound) = do
+ Publish.printErrorToStdout e
+ putStrLn ""
+ putStrLn "=========================================="
+ putStrLn "Did you forget to update the submodules?"
+ putStrLn "$ git submodule sync; git submodule update"
+ putStrLn "=========================================="
+ putStrLn ""
+ exitFailure
+ preparePackageError e = Publish.printErrorToStdout e >> exitFailure