【发布时间】:2021-11-04 04:45:16
【问题描述】:
我正在使用 XcodeCoverageConverter 按照 README 文件中提供的说明将 XCResult 转换为 Cobertura XML。
当只有一项作为--exclude-packages 的值传递时,它按预期工作。
但是,当我尝试按如下方式传递数组时,
xcc generate coverage.json TargetDirectory cobertura-xml --exclude-packages Tests AnotherPackageName --verbose
我收到以下错误,
Error: The value 'AnotherPackageName' is invalid for '<output-formats>'
Usage: xcc generate <json-file> <output-path> [<output-formats> ...] [--exclude-targets <exclude-targets> ...] [--exclude-packages <exclude-packages> ...] [--verbose]
我正在从我的 Bash 脚本中尝试同样的事情,如果我为 --exclude-packages 传递数组,我会得到同样的错误。
示例 1
jsonPath="coverage.json"
coberturaTargetPath="Cobertura"
xcc generate $jsonPath \
$coberturaTargetPath cobertura-xml \
--exclude-packages Tests AnotherPackageName \
--verbose
示例 2
jsonPath="coverage.json"
coberturaTargetPath="Cobertura"
excludePackages=(Tests AnotherPackageName)
xcc generate $jsonPath \
$coberturaTargetPath cobertura-xml \
--exclude-packages ${excludePackages[@]} \
--verbose
示例 3
jsonPath="coverage.json"
coberturaTargetPath="Cobertura"
excludePackages=(Tests AnotherPackageName)
xcc generate $jsonPath \
$coberturaTargetPath cobertura-xml \
--exclude-packages=${excludePackages[@]} \
--verbose
示例 4
jsonPath="coverage.json"
coberturaTargetPath="Cobertura"
outputFormats=(cobertura-xml)
excludePackages=(Tests AnotherPackageName)
xcc generate $jsonPath \
$coberturaTargetPath ${outputFormats[@]} \
--exclude-packages=${excludePackages[@]} \
--verbose
示例 5
jsonPath="coverage.json"
coberturaTargetPath="Cobertura"
outputFormats=(cobertura-xml)
excludePackages=(Tests AnotherPackageName)
xcc generate $jsonPath \
$coberturaTargetPath ${outputFormats[@]} \
--exclude-packages="${excludePackages[@]} " \
--verbose
在上述所有尝试中,我都遇到了同样的错误。 我为 --exclude-packages 传递的项目(不包括第一项)被考虑用于输出格式。 如何解决这个问题?
更新:
xcc 实用程序确实支持--exclude-packages 的多个参数。 Reference
【问题讨论】:
-
根据您的建议,我尝试了
--exclude-packages="${excludePackages[@]} ",但我得到了同样的错误。当我尝试使用--exclude-packages "Tests AnotherPackageName"时,它会将其视为具有 1 个元素“Tests AnotherPackageName”的数组 -
不使用数组如何运行它?你会
--exclude-packages something --exclude-packages somethingelse吗?换句话说,当用户想要将多个参数传递给exclude-packages并且xcc实用程序是否支持这样的用例时,xcc实用程序期望拥有什么? -
是的
xcc实用程序支持多个参数,这里是参考link
标签: arrays bash arguments code-coverage xcodebuild