I'm using shake for a test suite. I have multiples independent tests represented as a set of Rule
. If any of theses rules fails, the test fails. Finally, I produce a report containing all the tests status.
My issues are :
a) I need to detect which test runs or fails. Actually I'm cheating using actionOnException
, but that's lot of boilerplate in each command in each rules and that's complicated (I must write status file or play with IORef
to store the failing status).
b) I want to write the Shake report as part of my final report, however shakeReport
does not write the file in case of error, my only solution is to run again the build using --no-build --report out.html
which is not convenient.
Edit: Actually the tests are in action and build their dependencies. The build roughly looks like :
main = do
-- when this fails, `dumpTests` is called,
-- but the shake report is not written
_ <- (try shakeMain) :: IO (Either SomeException ())
-- This write my test report from the success informations it can gather
-- in the directory hierarchy
dumpTests
smakeMain = shakeArgs {shakeStaunch=True, shakeReport=["report.html"]} $ do
"tests" ~> need ["test1/done", "test2/done", ...]
-- this rules completly runs a test
"*/done" %> \done -> do
let test = takeDirectory done
-- clear all the leftover to be sure that there is nothing useless left. This is important because I use theses outputs to know which command succeeds or fails.
liftIO $ removeFiles test ["stdout.log", "*/image/*.exr", "*/image/*.png", "done"]
need [test </> "stdout.log"]
results <- getDirectoryFiles (test </> "image") ["*.exr"]
need (map (-<.> "png") results)
writeFile' done "done"
"*/stdout.log" %> \log -> do
let path = takeDirectory log </> "test"
need [path]
aCmd path -- this builds stdout.log and all exrs
"*/image/*.png" %> \png -> do
need [(png -<.> "exr")]
toExr png
Thank you.