我正在使用抖动作为测试套件。我有多个独立测试表示为一组Rule
. 如果这些规则中的任何一个失败,则测试失败。最后,我生成一份包含所有测试状态的报告。
我的问题是:
a) 我需要检测哪些测试运行或失败。实际上我在使用 作弊actionOnException
,但是每个规则中的每个命令都有很多样板,这很复杂(我必须编写状态文件或使用IORef
来存储失败状态)。
b) 我想写 Shake 报告作为我最终报告的一部分,但是shakeReport
不写文件以防出错,我唯一的解决方案是再次运行构建使用--no-build --report out.html
这不方便。
编辑:实际上测试正在运行并构建它们的依赖项。构建大致如下:
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
谢谢你。