From 6c77c29ad420780a97946d1eba2b75972860ff0b Mon Sep 17 00:00:00 2001 From: Edmund Kohlwey Date: Thu, 10 Oct 2024 08:09:30 -0400 Subject: [PATCH] Add swift-testing support to the xctest runner --- .../ios_xctestrun_runner.template.sh | 11 +- test/BUILD | 10 ++ ...est_swift_testing_runner_unit_test_17.x.sh | 170 ++++++++++++++++++ 3 files changed, 189 insertions(+), 2 deletions(-) create mode 100755 test/ios_xctest_swift_testing_runner_unit_test_17.x.sh diff --git a/apple/testing/default_runner/ios_xctestrun_runner.template.sh b/apple/testing/default_runner/ios_xctestrun_runner.template.sh index 7fab19c25b..d10cd7adf6 100755 --- a/apple/testing/default_runner/ios_xctestrun_runner.template.sh +++ b/apple/testing/default_runner/ios_xctestrun_runner.template.sh @@ -544,8 +544,15 @@ if [[ $parallel_testing_enabled == true ]]; then else # Assume the final 'Executed N tests' or 'Executed 1 test' is the # total execution count for the test bundle. - test_target_execution_count=$(grep -e "Executed [[:digit:]]\{1,\} tests*," "$testlog" | tail -n1) - if echo "$test_target_execution_count" | grep -q -e "Executed 0 tests, with 0 failures"; then + xctest_target_execution_count=$(grep -e "Executed [[:digit:]]\{1,\} tests*," "$testlog" | tail -n1) + swift_testing_target_execution_count=$(grep -e "Test run with [[:digit:]]\{1,\} test" "$testlog" | tail -n1 || true) + if echo "$xctest_target_execution_count" | grep -q -e "Executed 0 tests, with 0 failures" && \ + [ -z "$swift_testing_target_execution_count" ] ; then + no_tests_ran=true + fi + + if echo "$xctest_target_execution_count" | grep -q -e "Executed 0 tests, with 0 failures" && \ + echo "$swift_testing_target_execution_count" | grep -q -e "Test run with 0 tests" ; then no_tests_ran=true fi fi diff --git a/test/BUILD b/test/BUILD index 6f51113a61..9a565c6cfd 100644 --- a/test/BUILD +++ b/test/BUILD @@ -241,6 +241,16 @@ apple_shell_test( tags = common.skip_ci_tags, ) +apple_shell_test( + name = "ios_xctest_swift_testing_runner_unit_test_17.x", + size = "large", + src = "ios_xctest_swift_testing_runner_unit_test_17.x.sh", + args = [ + "--ios_multi_cpus=sim_arm64,x86_64", + ], + tags = common.skip_ci_tags, +) + apple_shell_test( name = "ios_test_runner_ui_test", size = "large", diff --git a/test/ios_xctest_swift_testing_runner_unit_test_17.x.sh b/test/ios_xctest_swift_testing_runner_unit_test_17.x.sh new file mode 100755 index 0000000000..ca2beb00f9 --- /dev/null +++ b/test/ios_xctest_swift_testing_runner_unit_test_17.x.sh @@ -0,0 +1,170 @@ +#!/bin/bash + +# Copyright 2018 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Integration tests for iOS test runner. + +MIN_OS_IOS="17.0.0" + +function set_up() { + mkdir -p ios +} + +function tear_down() { + rm -rf ios +} + +function create_sim_runners() { + cat > ios/BUILD < ios/passing_swift_testing_test.swift < ios/failing_swift_testing_test.swift < ios/empty_swift_testing_test.swift <> ios/BUILD <