Skip to content

Commit 724e402

Browse files
authored
Fix bugs with macOS test runner (#2754)
Fixes two major issues with the `macos_unit_test` runner - Tests were always passing because: ``` xcodebuild <...> 2>&1 | tee -i "$testlog" \ || test_exit_code=$? ``` Without `pipefail` means the exit code of the `xcodebuild` command is dropped. This meant as of #2649 all `macos_unit_test` were always passing even when tests failed 🙈 - Warning when running `xcodebuild`: ``` --- xcodebuild: WARNING: Using the first of multiple matching destinations: { platform:macOS, arch:arm64e, id:00006031-001851843684001C, name:My Mac } { platform:macOS, arch:arm64, id:00006031-001851843684001C, name:My Mac } { platform:macOS, arch:x86_64, id:00006031-001851843684001C, name:My Mac } { platform:macOS, arch:arm64e, variant:Mac Catalyst, id:00006031-001851843684001C, name:My Mac } { platform:macOS, arch:arm64, variant:Mac Catalyst, id:00006031-001851843684001C, name:My Mac } { platform:macOS, arch:x86_64, variant:Mac Catalyst, id:00006031-001851843684001C, name:My Mac } { platform:macOS, arch:arm64e, variant:DriverKit, id:00006031-001851843684001C, name:My Mac } { platform:macOS, arch:arm64, variant:DriverKit, id:00006031-001851843684001C, name:My Mac } { platform:macOS, arch:arm64e, variant:Designed for [iPad,iPhone], id:00006031-001851843684001C, name:My Mac } { platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:00006031-001851843684001C, name:My Mac } ``` The fix here is to specify `variant=macos` and `arch` so that xcodebuild always picks the right destination.
1 parent 9b2f083 commit 724e402

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

apple/testing/default_runner/macos_test_runner.template.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#!/bin/bash -eu
1+
#!/bin/bash
2+
3+
set -euo pipefail
24

35
# Copyright 2017 The Bazel Authors. All rights reserved.
46
#
@@ -149,11 +151,12 @@ rm -rf "$result_bundle_path"
149151

150152
test_exit_code=0
151153
readonly testlog="$TEST_TMP_DIR/test.log"
154+
152155
# Run xcodebuild with the xctestrun file just created. If the test failed, this
153156
# command will return non-zero, which is enough to tell bazel that the test
154157
# failed.
155158
xcodebuild test-without-building \
156-
-destination "platform=macOS" \
159+
-destination "platform=macOS,variant=macos,arch=$(uname -m)" \
157160
-resultBundlePath "$result_bundle_path" \
158161
-xctestrun "$XCTESTRUN" \
159162
2>&1 | tee -i "$testlog" \

0 commit comments

Comments
 (0)