如何抑制`stack test`命令底部的错误摘要输出?
解决Stack Test重复输出冗余摘要的问题
你可以通过以下几种方法抑制底部的重复错误摘要:
调整Stack日志级别
在命令里添加--verbosity warning参数,减少Stack自身的冗余输出,只保留测试框架的失败详情和关键错误:stack test --file-watch --verbosity warning这个参数会过滤掉那些重复的测试失败提示和构建计划错误摘要,让你直接看到测试框架输出的具体失败原因。
管道过滤冗余行
如果上面的方法还不够彻底,用grep精准过滤掉不需要的行:stack test --file-watch | grep -v -E "^aoc2024> Test suite.*failed$|^Completed [0-9]+ action\(s\)\.$|^Error: \[S-[0-9]+\]$|^Stack failed to execute the build plan\.|^While executing the build plan, Stack encountered the error:$|^Test suite failure for package.*$|^ exited with: ExitFailure 1$|^Logs printed to console$"这个命令会把你提到的那些重复摘要行全部屏蔽,只保留测试失败的具体信息。
全局配置修改
要是不想每次都加参数,可以在项目的stack.yaml或者全局的~/.stack/config.yaml里添加以下配置:verbosity: warning注意:这个设置会全局生效,可能会影响其他Stack命令的输出信息量,按需使用。
内容的提问来源于stack exchange,提问作者Quinn Wilson
相关产品推荐
相关产品推荐

