on master help sign in
Add a damlc doctest command and test the standard library (#2157)

There is lots of room for improvements here but I think this is a good first step. The 3 main things that could be improved imho are: - Rewrite source locations to point to the original file rather than the generated module - Provide some way to declare things like imports or more general, setup code that is added to the generated module. - Prettier/more helpful output during a run, e.g., print the list of successful tests.

commit3c64f5564e3790e4dabe853373d1cd13804543c3 authorMoritz Kiefer <moritz.kiefer@purelyfunctional.org> dateTue 16 Jul 2019, 15:51 (7 years ago) parent2d637aa
2 files changed+16−14
src/Development/IDE/Core/Compile.hs−13 src/Development/IDE/GHC/Util.hs+16−1
src/Development/IDE/Core/Compile.hs−13
@@ -137,19 +137,6 @@ addRelativeImport :: ParsedModule -> DynFlags -> DynFlags
137137addRelativeImport modu dflags = dflags
138138 {importPaths = nubOrd $ maybeToList (moduleImportPaths modu) ++ importPaths dflags}
139139
140−moduleImportPaths :: GHC.ParsedModule -> Maybe FilePath
141−moduleImportPaths pm
142− | rootModDir == "." = Just rootPathDir
143− | otherwise =
144− dropTrailingPathSeparator <$> stripSuffix (normalise rootModDir) (normalise rootPathDir)
145− where
146− ms = GHC.pm_mod_summary pm
147− file = GHC.ms_hspp_file ms
148− mod' = GHC.ms_mod ms
149− rootPathDir = takeDirectory file
150− rootModDir = takeDirectory . moduleNameSlashes . GHC.moduleName $ mod'
151−
152−
153140mkTcModuleResult
154141 :: GhcMonad m
155142 => InterfaceDirectory
src/Development/IDE/GHC/Util.hs+16−1
@@ -14,10 +14,12 @@ module Development.IDE.GHC.Util(
1414 fakeDynFlags,
1515 prettyPrint,
1616 runGhcEnv,
17− textToStringBuffer
17+ textToStringBuffer,
18+ moduleImportPaths
1819 ) where
1920
2021import Config
22+import Data.List.Extra
2123import Fingerprint
2224import GHC
2325import GhcMonad
@@ -28,6 +30,7 @@ import FileCleanup
2830import Platform
2931import qualified Data.Text as T
3032import StringBuffer
33+import System.FilePath
3134
3235
3336----------------------------------------------------------------------
@@ -90,3 +93,15 @@ fakeDynFlags = defaultDynFlags settings ([], [])
9093 { pc_DYNAMIC_BY_DEFAULT=False
9194 , pc_WORD_SIZE=8
9295 }
96+
97+moduleImportPaths :: GHC.ParsedModule -> Maybe FilePath
98+moduleImportPaths pm
99+ | rootModDir == "." = Just rootPathDir
100+ | otherwise =
101+ dropTrailingPathSeparator <$> stripSuffix (normalise rootModDir) (normalise rootPathDir)
102+ where
103+ ms = GHC.pm_mod_summary pm
104+ file = GHC.ms_hspp_file ms
105+ mod' = GHC.ms_mod ms
106+ rootPathDir = takeDirectory file
107+ rootModDir = takeDirectory . moduleNameSlashes . GHC.moduleName $ mod'