|
6 | 6 | module Main where |
7 | 7 |
|
8 | 8 | -- import Language.Haskell.GHC.ExactPrint.Utils ( showGhc ) |
9 | | -import Language.Haskell.GHC.ExactPrint.Preprocess (defaultCppOptions) |
| 9 | +-- import Language.Haskell.GHC.ExactPrint.Preprocess (defaultCppOptions) |
10 | 10 | import Language.Haskell.GHC.ExactPrint.Parsers |
11 | 11 | import qualified GHC.Paths |
12 | 12 | import Control.Monad |
@@ -46,8 +46,8 @@ testDirs :: [FilePath] |
46 | 46 | testDirs = |
47 | 47 | case ghcVersion of |
48 | 48 | GHC910 -> ["pre-ghc910", "ghc910"] |
49 | | - GHC912 -> ["pre-ghc910", "ghc910", "ghc912"] |
50 | | - -- GHC912 -> ["ghc-cpp"] |
| 49 | + -- GHC912 -> ["pre-ghc910", "ghc910", "ghc912"] |
| 50 | + GHC912 -> ["ghc-cpp"] |
51 | 51 | -- GHC912 -> ["ghc912"] |
52 | 52 | -- GHC912 -> ["ghc912-copied"] |
53 | 53 | -- GHC912 -> ["ghc912", "ghc912-copied"] |
@@ -138,20 +138,21 @@ mkTests :: IO Test |
138 | 138 | mkTests = do |
139 | 139 | -- listTests |
140 | 140 | let libdir = GHC.Paths.libdir |
| 141 | + when useGhcCpp $ presetHackageVersionMacros libdir |
141 | 142 | roundTripTests <- findTests libdir |
142 | 143 | roundTripBalanceCommentsTests <- findTestsBC libdir |
143 | 144 | roundTripMakeDeltaTests <- findTestsMD libdir |
144 | 145 | return $ TestList [ |
145 | 146 | internalTests, |
146 | 147 | roundTripTests |
147 | | - -- , |
148 | | - -- (transformTests libdir) |
149 | | - -- , |
150 | | - -- (failingTests libdir) |
151 | | - -- , |
152 | | - -- roundTripBalanceCommentsTests |
153 | | - -- , |
154 | | - -- roundTripMakeDeltaTests |
| 148 | + , |
| 149 | + (transformTests libdir) |
| 150 | + , |
| 151 | + (failingTests libdir) |
| 152 | + , |
| 153 | + roundTripBalanceCommentsTests |
| 154 | + , |
| 155 | + roundTripMakeDeltaTests |
155 | 156 | ] |
156 | 157 |
|
157 | 158 | failingTests :: LibDir -> Test |
@@ -196,7 +197,7 @@ tr = hSilence [stderr] $ do |
196 | 197 | tt' :: IO (Counts,Int) |
197 | 198 | tt' = do |
198 | 199 | let libdir = GHC.Paths.libdir |
199 | | - -- presetHackageVersionMacros libdir |
| 200 | + when useGhcCpp $ presetHackageVersionMacros libdir |
200 | 201 | runTestText (putTextToHandle stdout True) $ TestList [ |
201 | 202 |
|
202 | 203 | -- mkParserTest libdir "ghc98" "ModuleComments1.hs" |
@@ -230,15 +231,15 @@ tt' = do |
230 | 231 | -- mkParserTest libdir "pre-ghc910" "ExperimIOP.hs" |
231 | 232 | -- mkParserTest libdir "pre-ghc910" "RandomPGC1.hs" |
232 | 233 | -- mkParserTest libdir "pre-ghc910" "Utils.hs" |
233 | | - mkParserTest libdir "pre-ghc910" "A.hs" |
| 234 | + -- mkParserTest libdir "pre-ghc910" "A.hs" |
234 | 235 | -- mkParserTest libdir "failing" "CppComment.hs" |
235 | 236 | -- mkParserTest libdir "ghc-cpp" "Scan.hs" |
236 | 237 | -- mkParserTest libdir "ghc-cpp" "Test1.hs" |
237 | 238 | -- mkParserTest libdir "ghc-cpp" "WithoutSomeFixpoints.hs" |
238 | 239 |
|
239 | 240 | -- mkParserTest libdir "ghc-cpp" "Promise.hs" |
240 | 241 | -- mkParserTest libdir "ghc-cpp" "Set1.hs" |
241 | | - -- mkParserTest libdir "ghc-cpp" "Compat.hs" |
| 242 | + mkParserTest libdir "ghc-cpp" "Compat.hs" |
242 | 243 |
|
243 | 244 | ] |
244 | 245 |
|
@@ -295,16 +296,20 @@ pwd = getCurrentDirectory |
295 | 296 | cd :: FilePath -> IO () |
296 | 297 | cd = setCurrentDirectory |
297 | 298 |
|
298 | | -parseOnly :: String -> IO (Either String ()) |
| 299 | +parseOnly :: FilePath -> IO (Either String ()) |
299 | 300 | parseOnly file = do |
300 | 301 | presetHackageVersionMacros GHC.Paths.libdir |
301 | 302 | wd <- getCurrentDirectory |
302 | 303 | let file2 = wd ++ "/" ++ file |
303 | 304 | res <- parseModuleEpAnnsWithCpp GHC.Paths.libdir useGhcCpp defaultCppOptions file2 |
304 | 305 | case res of |
305 | 306 | Left m -> return . Left $ (showErrorMessages m) |
306 | | - Right (injectedComments, dflags, pmod) -> do |
| 307 | + Right (_injectedComments, _dflags, _pmod) -> do |
307 | 308 | putStrLn "ok" |
308 | 309 | return $ Right () |
309 | 310 |
|
| 311 | +-- | Intended for use in ghci, parse a file using GHC_CPP, including |
| 312 | +-- the preset macros. Can be used on the contents of roundtrip failure |
| 313 | +-- files (cpp.txt, pfail.txt). |
| 314 | +po :: FilePath -> IO (Either String ()) |
310 | 315 | po = parseOnly |
0 commit comments