When a test fails, print a suggestion how to make the output gold.

This commit is contained in:
Iavor Diatchki 2017-12-21 10:14:44 -08:00
parent 32fb511ced
commit 01b72ce0f9

View File

@ -200,16 +200,24 @@ generateAssertion opts dir file = testCase file $ do
Left (X.SomeException {})
| Just prog <- optDiff opts ->
do goldFile' <- canonicalizePath goldFile
assertFailure (unwords [ prog, goldFile', "\\\n ", resultOut ])
assertFailure $ unlines
[ unwords [ prog, goldFile', "\\\n ", resultOut ]
, makeGold resultOut goldFile
]
| otherwise ->
do goldFile' <- canonicalizePath goldFile
(_,diffOut,_) <- readProcessWithExitCode "diff" [ goldFile', resultOut ] ""
assertFailure diffOut
assertFailure $ unlines [ diffOut, makeGold resultOut goldFile ]
Right fail_msg | optIgnoreExpected opts -> return ()
| otherwise -> assertFailure fail_msg
makeGold out gold =
unlines [ "# If output is OK:"
, unwords [ "cp", out, "\\\n ", gold ]
]
-- Test Discovery --------------------------------------------------------------
findTests :: [FilePath] -> IO TestFiles