2019-06-20 00:25:37 +03:00
|
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
|
|
|
2019-06-16 03:04:11 +03:00
|
|
|
|
module DoctestSpec where
|
|
|
|
|
|
|
|
|
|
import Test.Hspec
|
2019-06-20 00:25:37 +03:00
|
|
|
|
import Test.DocTest
|
2019-06-16 03:04:11 +03:00
|
|
|
|
|
2019-10-28 19:13:44 +03:00
|
|
|
|
import Build_doctests (flags, pkgs, module_sources)
|
2019-07-24 16:50:56 +03:00
|
|
|
|
|
2019-10-28 19:13:44 +03:00
|
|
|
|
spec :: Spec
|
|
|
|
|
spec = parallel $ describe "Error messages" $ it "should pass the doctest" $ doctest $
|
|
|
|
|
[ "--fast"
|
2019-06-20 00:25:37 +03:00
|
|
|
|
#if __GLASGOW_HASKELL__ < 806
|
|
|
|
|
, "-XMonadFailDesugaring"
|
|
|
|
|
, "-XTypeInType"
|
|
|
|
|
#endif
|
2019-06-18 19:36:38 +03:00
|
|
|
|
, "test/TypeErrors.hs"
|
2019-06-16 03:04:11 +03:00
|
|
|
|
]
|
2019-10-28 19:13:44 +03:00
|
|
|
|
<> pkgs
|
|
|
|
|
<> removeFlagSearchPathSrc flags
|
|
|
|
|
|
|
|
|
|
-- | Designed to remove flags that add the "polysemy-plugin/src" directory. For
|
|
|
|
|
-- example, it will remove the following flag:
|
|
|
|
|
-- "-i/Users/bob/code/polysemy/polysemy-plugin/src".
|
|
|
|
|
--
|
|
|
|
|
-- This was done because the presence of this flag causes the following error:
|
|
|
|
|
-- test/TypeErrors.hs:9: failure in expression `:set -fplugin=Polysemy.Plugin'
|
|
|
|
|
-- expected:
|
|
|
|
|
-- but got: attempting to use module ‘main:Polysemy.Plugin’
|
|
|
|
|
-- (.../polysemy/polysemy-plugin/src/Polysemy/Plugin.hs) which is not loaded.
|
|
|
|
|
--
|
|
|
|
|
-- Without this flag, the tests pass as expected. My understanding of GHC isn't
|
|
|
|
|
-- great, so feel free to remove this function if you know of some way of making
|
|
|
|
|
-- this flag a non-issue.
|
|
|
|
|
removeFlagSearchPathSrc :: [String] -> [String]
|
|
|
|
|
removeFlagSearchPathSrc = filter (not . isSrcSearchPath)
|
|
|
|
|
where
|
|
|
|
|
isSrcSearchPath flag = isSearchPathFlag flag && isSrcDir flag
|
|
|
|
|
|
|
|
|
|
isSearchPathFlag ('-':'i':_) = True
|
|
|
|
|
isSearchPathFlag _ = False
|
|
|
|
|
|
|
|
|
|
isSrcDir ('s':'r':c':[]) = True
|
|
|
|
|
isSrcDir (x:xs) = isSrcDir xs
|
|
|
|
|
isSrcDir [] = False
|