[commit: ghc] master: check-ppr: Make --dump the default behavior (9331e33)

git at git.haskell.org git at git.haskell.org
Mon Dec 26 15:04:00 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/9331e338a7a8f78c05ef89684ab1a5bb7c79d37d/ghc

>---------------------------------------------------------------

commit 9331e338a7a8f78c05ef89684ab1a5bb7c79d37d
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Mon Dec 26 10:02:43 2016 -0500

    check-ppr: Make --dump the default behavior


>---------------------------------------------------------------

9331e338a7a8f78c05ef89684ab1a5bb7c79d37d
 utils/check-ppr/Main.hs | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/utils/check-ppr/Main.hs b/utils/check-ppr/Main.hs
index c9fac7d..ef39831 100644
--- a/utils/check-ppr/Main.hs
+++ b/utils/check-ppr/Main.hs
@@ -23,25 +23,21 @@ import qualified Data.Map        as Map
 
 usage :: String
 usage = unlines
-    [ "usage: check-ppr [--dump] (libdir) (file)"
+    [ "usage: check-ppr (libdir) (file)"
     , ""
     , "where libdir is the GHC library directory (e.g. the output of"
     , "ghc --print-libdir) and file is the file to parse."
-    , "The --dump flag causes check-ppr to produce .new and .old files"
-    , "containing dumps of the new and old ASTs in the event of a match"
-    , "failure."
     ]
 
 main :: IO()
 main = do
   args <- getArgs
   case args of
-   [libdir,fileName] -> testOneFile libdir fileName False
-   ["--dump", libdir,fileName] -> testOneFile libdir fileName True
+   [libdir,fileName] -> testOneFile libdir fileName
    _ -> putStrLn usage
 
-testOneFile :: FilePath -> String -> Bool -> IO ()
-testOneFile libdir fileName dumpOldNew = do
+testOneFile :: FilePath -> String -> IO ()
+testOneFile libdir fileName = do
        p <- parseOneFile libdir fileName
        let
          origAst = showAstData 0 (pm_parsed_source p)
@@ -51,6 +47,7 @@ testOneFile libdir fileName dumpOldNew = do
 
          newFile = dropExtension fileName <.> "ppr" <.> takeExtension fileName
          astFile = fileName <.> "ast"
+         newAstFile = fileName <.> "ast.new"
 
        writeFile astFile origAst
        writeFile newFile pped
@@ -58,6 +55,7 @@ testOneFile libdir fileName dumpOldNew = do
        p' <- parseOneFile libdir newFile
 
        let newAstStr = showAstData 0 (pm_parsed_source p')
+       writeFile newAstFile newAstStr
 
        if origAst == newAstStr
          then do
@@ -69,9 +67,6 @@ testOneFile libdir fileName dumpOldNew = do
            putStrLn origAst
            putStrLn "\n===================================\nNew\n\n"
            putStrLn newAstStr
-           when dumpOldNew $ do
-               writeFile (fileName <.> "old") origAst
-               writeFile (fileName <.> "new") newAstStr
            exitFailure
 
 



More information about the ghc-commits mailing list