【发布时间】:2026-01-10 14:50:02
【问题描述】:
所以 - 我正在编写一个脚本来根据项目的变化运行 iOS 测试(可能对主题并不重要)。
在脚本中,有一个命令将运行测试:
cmd = "xcodebuild -workspace xxx.xcworkspace -scheme xxx -destination 'platform=iOS Simulator,name={0},OS=latest' -configuration Debug -derivedDataPath {1} test-without-building {2} -parallel-testing-enabled NO -enableCodeCoverage YES | xcpretty".format(os.environ['TEST_SIMULATOR_NAME'], os.environ['PWD'], result)
并像这样执行:
do(cmd)
do() 方法定义为 (source):
def do(command):
return_code = call([ '/bin/bash', '-c', 'set -o pipefail; ' + command ])
Gitlab 作业设置:
manualUiTestsBasedOnChanges:
stage: uiTests
only: ...some conditions...
before_script:
- set -o pipefail
script:
- ../scripts/ci/run_UI_tests_based_on_changes.py
这样做的问题是,如果在此脚本中发生故障,它不会使作业失败,即使在脚本之前和 do() 方法中设置了set -o pipefail。在下图中可见。
你知道为什么会这样吗?
【问题讨论】:
标签: python ios continuous-integration gitlab