Skip to content

Commit 584dd61

Browse files
committed
Check through hackage roundtrip GHC_CPP tests
TL;DR: fixed directives in pragmas (in GHC) identified tests as benign, so deleted migrated error reporting requirement for missing #if to GHC test GhcCpp02
1 parent 7c53c8a commit 584dd61

File tree

18 files changed

+32
-1679
lines changed

18 files changed

+32
-1679
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,8 @@ packages
6565
/failures.txt
6666
/tests/examples/transform/AddArgFromWhereComments.hs.expected
6767
/tests/examples/ghc912-copied/
68+
/hackage-version-macros.txt
69+
/hie.yaml.1
70+
/hie.yaml.bak
71+
/javascript-ffi-files.txt
72+
/roundtrip-config/knownfailures.txt.2025-05-26

configure.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,4 @@ rm -fr dist*
271271
# cabal configure -fdev --with-compiler=/opt/ghc/9.13.20250316/bin/ghc --allow-newer
272272
# cabal configure -fdev -froundtrip --enable-tests --with-compiler=/opt/ghc/9.13.20250316/bin/ghc --allow-newer
273273
# cabal configure -fdev -froundtrip --enable-tests --with-compiler=/opt/ghc/9.13.20250331/bin/ghc --allow-newer
274-
cabal configure -fdev -froundtrip --enable-tests --with-compiler=/opt/ghc/9.13.20250604/bin/ghc --allow-newer
274+
cabal configure -fdev -froundtrip --enable-tests --with-compiler=/opt/ghc/9.13.20250606/bin/ghc --allow-newer

src/Language/Haskell/GHC/ExactPrint/Preprocess.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import Language.Haskell.GHC.ExactPrint.Utils
4444
import qualified Data.Set as Set
4545
import qualified GHC.Data.Strict as Strict
4646

47-
4847
-- ---------------------------------------------------------------------
4948

5049
data CppOptions = CppOptions

tests/Test.hs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
module Main where
77

88
-- import Language.Haskell.GHC.ExactPrint.Utils ( showGhc )
9-
import Language.Haskell.GHC.ExactPrint.Preprocess (defaultCppOptions)
9+
-- import Language.Haskell.GHC.ExactPrint.Preprocess (defaultCppOptions)
1010
import Language.Haskell.GHC.ExactPrint.Parsers
1111
import qualified GHC.Paths
1212
import Control.Monad
@@ -46,8 +46,8 @@ testDirs :: [FilePath]
4646
testDirs =
4747
case ghcVersion of
4848
GHC910 -> ["pre-ghc910", "ghc910"]
49-
GHC912 -> ["pre-ghc910", "ghc910", "ghc912"]
50-
-- GHC912 -> ["ghc-cpp"]
49+
-- GHC912 -> ["pre-ghc910", "ghc910", "ghc912"]
50+
GHC912 -> ["ghc-cpp"]
5151
-- GHC912 -> ["ghc912"]
5252
-- GHC912 -> ["ghc912-copied"]
5353
-- GHC912 -> ["ghc912", "ghc912-copied"]
@@ -138,20 +138,21 @@ mkTests :: IO Test
138138
mkTests = do
139139
-- listTests
140140
let libdir = GHC.Paths.libdir
141+
when useGhcCpp $ presetHackageVersionMacros libdir
141142
roundTripTests <- findTests libdir
142143
roundTripBalanceCommentsTests <- findTestsBC libdir
143144
roundTripMakeDeltaTests <- findTestsMD libdir
144145
return $ TestList [
145146
internalTests,
146147
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
155156
]
156157

157158
failingTests :: LibDir -> Test
@@ -196,7 +197,7 @@ tr = hSilence [stderr] $ do
196197
tt' :: IO (Counts,Int)
197198
tt' = do
198199
let libdir = GHC.Paths.libdir
199-
-- presetHackageVersionMacros libdir
200+
when useGhcCpp $ presetHackageVersionMacros libdir
200201
runTestText (putTextToHandle stdout True) $ TestList [
201202

202203
-- mkParserTest libdir "ghc98" "ModuleComments1.hs"
@@ -230,15 +231,15 @@ tt' = do
230231
-- mkParserTest libdir "pre-ghc910" "ExperimIOP.hs"
231232
-- mkParserTest libdir "pre-ghc910" "RandomPGC1.hs"
232233
-- mkParserTest libdir "pre-ghc910" "Utils.hs"
233-
mkParserTest libdir "pre-ghc910" "A.hs"
234+
-- mkParserTest libdir "pre-ghc910" "A.hs"
234235
-- mkParserTest libdir "failing" "CppComment.hs"
235236
-- mkParserTest libdir "ghc-cpp" "Scan.hs"
236237
-- mkParserTest libdir "ghc-cpp" "Test1.hs"
237238
-- mkParserTest libdir "ghc-cpp" "WithoutSomeFixpoints.hs"
238239

239240
-- mkParserTest libdir "ghc-cpp" "Promise.hs"
240241
-- mkParserTest libdir "ghc-cpp" "Set1.hs"
241-
-- mkParserTest libdir "ghc-cpp" "Compat.hs"
242+
mkParserTest libdir "ghc-cpp" "Compat.hs"
242243

243244
]
244245

@@ -295,16 +296,20 @@ pwd = getCurrentDirectory
295296
cd :: FilePath -> IO ()
296297
cd = setCurrentDirectory
297298

298-
parseOnly :: String -> IO (Either String ())
299+
parseOnly :: FilePath -> IO (Either String ())
299300
parseOnly file = do
300301
presetHackageVersionMacros GHC.Paths.libdir
301302
wd <- getCurrentDirectory
302303
let file2 = wd ++ "/" ++ file
303304
res <- parseModuleEpAnnsWithCpp GHC.Paths.libdir useGhcCpp defaultCppOptions file2
304305
case res of
305306
Left m -> return . Left $ (showErrorMessages m)
306-
Right (injectedComments, dflags, pmod) -> do
307+
Right (_injectedComments, _dflags, _pmod) -> do
307308
putStrLn "ok"
308309
return $ Right ()
309310

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 ())
310315
po = parseOnly

tests/Test/Common.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ import System.FilePath
7070
import qualified GHC.Paths
7171

7272
useGhcCpp :: Bool
73-
-- useGhcCpp = True
74-
useGhcCpp = False
73+
useGhcCpp = True
74+
-- useGhcCpp = False
7575

7676
testPrefix :: FilePath
7777
testPrefix = "." </> "tests" </> "examples"

tests/examples/ghc-cpp/Base.hs

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/examples/ghc-cpp/Base2.hs

Lines changed: 0 additions & 149 deletions
This file was deleted.

tests/examples/ghc-cpp/Compat.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
-- Originally ./hackage-roundtrip-work/base-compat-0.14.1/src/Type/Reflection/Compat.hs
2+
23
{-# LANGUAGE CPP, NoImplicitPrelude #-}
34
{-# LANGUAGE Trustworthy #-}
45
#if MIN_VERSION_base(4,10,0)

tests/examples/ghc-cpp/Decl.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-- | Type checking declarations
22
{-# LANGUAGE QuasiQuotes #-}
33
{-# LANGUAGE UnicodeSyntax #-}
4+
{-# LANGUAGE TemplateHaskell #-}
45
module Statics.Decl (
56
tcProg, tcDecls, tcDecl, tcSigExp,
67
) where

tests/examples/ghc-cpp/FFI.hs

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)