Skip to content

Commit

Permalink
Convert backslash characters in the generated error messages to forwa…
Browse files Browse the repository at this point in the history
…rdslashes
  • Loading branch information
ozgurakgun committed Oct 20, 2016
1 parent 034e581 commit 8c3bcfe
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/test/Conjure/ParsePrint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import Conjure.UI ( OutputFormat(..) )
import Conjure.UI.IO ( readModelFromFile, writeModel )
import Conjure.UI.TypeCheck ( typeCheckModel_StandAlone )

-- base
import System.Info ( os )

-- tasty
import Test.Tasty ( TestTree, testGroup )
import Test.Tasty.HUnit ( testCaseSteps, assertFailure )
Expand Down Expand Up @@ -75,17 +78,23 @@ testSingleDir TestDirFiles{..} = testCaseSteps name $ \ step -> do
removeFileIfExists (tBaseDir </> "stderr")

let

fixWindowsPaths :: String -> String
fixWindowsPaths
| os `elem` ["mingw32"] = map (\ ch -> if ch == '\\' then '/' else ch )
| otherwise = id

readIfExists :: FilePath -> IO String
readIfExists f = fromMaybe "" <$> readFileIfExists f

step "Checking stdout"
stdoutG <- readIfExists (tBaseDir </> "stdout")
stdoutG <- fixWindowsPaths <$> readIfExists (tBaseDir </> "stdout")
stdoutE <- readIfExists (tBaseDir </> "stdout.expected")
unless (stdoutE == stdoutG) $
assertFailure $ renderNormal $ vcat [ "unexpected stdout:" <++> pretty stdoutG
, "was expecting: " <++> pretty stdoutE ]
step "Checking stderr"
stderrG <- readIfExists (tBaseDir </> "stderr")
stderrG <- fixWindowsPaths <$> readIfExists (tBaseDir </> "stderr")
stderrE <- readIfExists (tBaseDir </> "stderr.expected")
unless (stderrE == stderrG) $
assertFailure $ renderNormal $ vcat [ "unexpected stderr:" <++> pretty stderrG
Expand Down

0 comments on commit 8c3bcfe

Please sign in to comment.