@@ -54,7 +54,8 @@ instance IsOption NodeOpt where
5454 optionCLParser = fmap NodeOpt $ switch (long nodeArg <> help nodeHelp)
5555
5656ingredients :: [Ingredient]
57−ingredients = [rerunningTests [consoleTestReporter],
57+ingredients = defaultIngredients ++
58+ [rerunningTests [consoleTestReporter],
5859 includingOptions [Option (Proxy :: Proxy NodeOpt)] ]
5960
6061----------------------------------------------------------------------- [ Core ]
@@ -63,28 +64,37 @@ ingredients = [rerunningTests [consoleTestReporter],
6364-- A ripoff of goldenVsFile from Tasty.Golden
6465test :: String -> String -> IO () -> TestTree
6566test name path act =
66− goldenTest name (BS.readFile ref) (act >> BS.readFile new) cmp upd
67+ goldenTest name (readFile ref) (act >> readFile new) cmp upd
6768 where
6869 ref = path </> "expected"
6970 new = path </> "output"
70− cmp x y = return $ if x == y then Nothing
71+ cmp x y = return $ if normalize x == normalize y then Nothing
7172 else Just $ printDiff (ref, x) (new, y)
72− upd = BS.writeFile ref
73+ upd = writeFile ref
74+ -- just pretend that backslashes are slashes for comparison
75+ -- purposes to avoid path problems, so don't write any tests
76+ -- that depend on that distinction in other contexts.
77+ -- Also compare CRLF and LF as equal, fixes a weird corner case
78+ -- on Mac where basic010 and reg039 produces CRLF
79+ normalize [] = []
80+ normalize ('\r':'\n':xs) = '\n' : normalize xs
81+ normalize ('\\':'\\':xs) = '/' : normalize xs
82+ normalize ('\\':xs) = '/' : normalize xs
83+ normalize (x : xs) = x : normalize xs
84+
7385
7486-- Takes the filepath and content of `expected` and `output`
7587-- and formats an error message stating their difference
76−printDiff :: (String, BS.ByteString) -> (String, BS.ByteString) -> String
88+printDiff :: (String, String) -> (String, String) -> String
7789printDiff (ref, x) (new, y) =
78− let refcnt = BSC.unpack x
79− newcnt = BSC.unpack y
80− printContent cnt =
90+ let printContent cnt =
8191 if Data.List.null cnt
8292 then " is empty...\n"
8393 else " is: \n" ++ unlines (fmap ((++) " ") (lines cnt))
8494 in
8595 "Test mismatch!\n" ++
86− "Golden file " ++ ref ++ printContent refcnt ++
87− "However, " ++ new ++ printContent newcnt
96+ "Golden file " ++ ref ++ printContent x ++
97+ "However, " ++ new ++ printContent y
8898
8999-- Should always output a 3-charater string from a postive Int
90100indexToString :: Int -> String
@@ -112,9 +122,11 @@ mkGoldenTests testFamilies flags =
112122runTest :: String -> Flags -> IO ()
113123runTest path flags = do
114124 let run = (proc "bash" ("run" : flags)) {cwd = Just path,
115− std_out = CreatePipe}
116− (_, output, _) <- readCreateProcessWithExitCode run ""
125+ std_out = CreatePipe,
126+ std_err = CreatePipe}
127+ (_, output, error_out) <- readCreateProcessWithExitCode run ""
117128 writeFile (path </> "output") output
129+ hPutStrLn stderr error_out
118130
119131main :: IO ()
120132main = do
@@ -125,4 +137,3 @@ main = do
125137 in
126138 mkGoldenTests (testFamiliesForCodegen codegen)
127139 (flags ++ idrisFlags)
128−