From d88efb7048160c3031eadb4f3b729e9fe406414d Mon Sep 17 00:00:00 2001 From: Tamar Christina Date: Sat, 17 Dec 2016 16:40:11 +0000 Subject: Fix Pretty printer tests on Windows Summary: D2752 added some tests which escapes string literals. This means newlines are converted before they get normalized by the IO functions. So on Windows \r\n would be in the output while \n was expected. Test Plan: make test -C testsuite/tests/printer Reviewers: austin, bgamari, alanz Reviewed By: alanz Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2873 GHC Trac Issues: #3384 --- utils/check-ppr/Main.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'utils') diff --git a/utils/check-ppr/Main.hs b/utils/check-ppr/Main.hs index 8c937695cc..c9fac7dc33 100644 --- a/utils/check-ppr/Main.hs +++ b/utils/check-ppr/Main.hs @@ -132,10 +132,10 @@ showAstData n = space "" = "" space s = ' ':s indent i = "\n" ++ replicate i ' ' - string = show :: String -> String - fastString = ("{FastString: "++) . (++"}") . show + string = normalize_newlines . show :: String -> String + fastString = ("{FastString: "++) . (++"}") . normalize_newlines . show :: FastString -> String - bytestring = show :: B.ByteString -> String + bytestring = normalize_newlines . show :: B.ByteString -> String list l = indent n ++ "[" ++ intercalate "," (map (showAstData (n+1)) l) ++ "]" @@ -179,11 +179,16 @@ showAstData n = ++ showAstData (n+1) a ++ ")" +normalize_newlines :: String -> String +normalize_newlines ('\\':'r':'\\':'n':xs) = '\\':'n':normalize_newlines xs +normalize_newlines (x:xs) = x:normalize_newlines xs +normalize_newlines [] = [] + showSDoc_ :: SDoc -> String -showSDoc_ = showSDoc unsafeGlobalDynFlags +showSDoc_ = normalize_newlines . showSDoc unsafeGlobalDynFlags showSDocDebug_ :: SDoc -> String -showSDocDebug_ = showSDocDebug unsafeGlobalDynFlags +showSDocDebug_ = normalize_newlines . showSDocDebug unsafeGlobalDynFlags -- --------------------------------------------------------------------- -- cgit v1.2.1