我有以下appveyor.yml
文件:
test_script:
- forfiles /m *.mqh /c "mql /s @path"
build: off
platform: x86
旨在检查当前目录中找到的所有源代码文件的语法(/s
)。
然而,尽管存在编译器错误,但最终结果报告为:构建成功。
如何使用上述方法使测试脚本失败?
我在Linux上看起来与set -e
类似。编译器在退出时会按预期返回1错误,因为它在Linux上使用wine
时工作正常。但整个构建脚本并没有像预期的那样失败。
答案 0 :(得分:1)
AppVeyor很高兴,因为整个命令返回代码为0.我认为它的返回代码为0,因为上一次迭代很开心。我不知道如果使用forfiles
至少一次迭代失败,如何使其返回错误,但是使用PowerShell这应该有效:
test_script:
- ps: $mqlScriptSuccess = $true
- ps: Get-ChildItem | ForEach-Object {if ($_.Name.EndsWith(".mqh")){.\mql /s /mql$env:ver $_.FullName; if(!$?){$mqlScriptSuccess = $?; Write-Warning "mlq error"}}}
- ps: if (!$mqlScriptSuccess) {throw "At least one mql test failed"}
请注意,您也可以将Get-ChildItem
更改为Get-ChildItem -Recurse
以获得更深入的报道。