on master help sign in
Merge pull request #3293 from melted/fix_testing

Fix testsuite regression on Windows.

commitaa2d977742f71c5b0b70e30f6b1fbebd6c3fa0cc authorNiklas Larsson <metaniklas@gmail.com> dateSat 30 Jul 2016, 00:35 (10 years ago) parent6dffa49c2c4165
1 file changed+12−10
test/TestRun.hs+12−10
test/TestRun.hs+12−10
@@ -63,28 +63,31 @@ ingredients = [rerunningTests [consoleTestReporter],
6363-- A ripoff of goldenVsFile from Tasty.Golden
6464test :: String -> String -> IO () -> TestTree
6565test name path act =
66− goldenTest name (BS.readFile ref) (act >> BS.readFile new) cmp upd
66+ goldenTest name (readFile ref) (act >> readFile new) cmp upd
6767 where
6868 ref = path </> "expected"
6969 new = path </> "output"
70− cmp x y = return $ if x == y then Nothing
70+ cmp x y = return $ if normalize x == normalize y then Nothing
7171 else Just $ printDiff (ref, x) (new, y)
72− upd = BS.writeFile ref
72+ upd = writeFile ref
73+ normalize [] = []
74+ normalize ('\\':'\\':xs) = '/':normalize xs
75+ normalize ('\\':xs) = '/':normalize xs
76+ normalize (x:xs) = x:normalize xs
77+
7378
7479-- Takes the filepath and content of `expected` and `output`
7580-- and formats an error message stating their difference
76−printDiff :: (String, BS.ByteString) -> (String, BS.ByteString) -> String
81+printDiff :: (String, String) -> (String, String) -> String
7782printDiff (ref, x) (new, y) =
78− let refcnt = BSC.unpack x
79− newcnt = BSC.unpack y
80− printContent cnt =
83+ let printContent cnt =
8184 if Data.List.null cnt
8285 then " is empty...\n"
8386 else " is: \n" ++ unlines (fmap ((++) " ") (lines cnt))
8487 in
8588 "Test mismatch!\n" ++
86− "Golden file " ++ ref ++ printContent refcnt ++
87− "However, " ++ new ++ printContent newcnt
89+ "Golden file " ++ ref ++ printContent x ++
90+ "However, " ++ new ++ printContent y
8891
8992-- Should always output a 3-charater string from a postive Int
9093indexToString :: Int -> String
@@ -125,4 +128,3 @@ main = do
125128 in
126129 mkGoldenTests (testFamiliesForCodegen codegen)
127130 (flags ++ idrisFlags)
128−