From 1f4ce8034892aa490269aacf2fd4c74122d72920 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Mon, 4 May 2015 15:07:29 +0000 Subject: Add ios_test.sh.bazel_template -- MOS_MIGRATED_REVID=92725547 --- tools/objc/BUILD | 4 +++ tools/objc/ios_test.sh.bazel_template | 54 +++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 tools/objc/ios_test.sh.bazel_template (limited to 'tools/objc') diff --git a/tools/objc/BUILD b/tools/objc/BUILD index 4beb7254c1..ebdc32d5d8 100644 --- a/tools/objc/BUILD +++ b/tools/objc/BUILD @@ -43,3 +43,7 @@ filegroup( name = "srcs", srcs = glob(["**"]), ) + +filegroup( + name = "testrunner", +) diff --git a/tools/objc/ios_test.sh.bazel_template b/tools/objc/ios_test.sh.bazel_template new file mode 100644 index 0000000000..3a955493f3 --- /dev/null +++ b/tools/objc/ios_test.sh.bazel_template @@ -0,0 +1,54 @@ +#!/bin/bash + +# Copyright 2015 Google Inc. 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. + +set -eu + +TEST_APP_DIR="$(mktemp -d -t test_app_dir)" +unzip -qq -d "${TEST_APP_DIR}" "%(test_app_ipa)s" +TEST_APP_DIR="${TEST_APP_DIR}/Payload/%(test_app_name)s.app" + +XCTEST_APP_DIR="$(mktemp -d -t xctest_app_dir)" +unzip -qq -d "${XCTEST_APP_DIR}" "%(xctest_app_ipa)s" +XCTEST_APP_DIR="${XCTEST_APP_DIR}/Payload/%(xctest_app_name)s.app" + +killall "iOS Simulator" >/dev/null 2>/dev/null || : + +SIMHOME="$(mktemp -d -t simhome)" + +LOGFILE="$(mktemp -t logfile)" + +"%(iossim_path)s" \ + -u "${SIMHOME}" \ + -d "%(device_type)s" \ + -s "%(simulator_sdk)s" \ + -t 60 \ + -e DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection \ + -e "XCInjectBundle=${TEST_APP_DIR}" \ + -e "XCInjectBundleInto=${XCTEST_APP_DIR}" \ + -e DYLD_FALLBACK_FRAMEWORK_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks \ + "${XCTEST_APP_DIR}" \ + -NSTreatUnknownArgumentsAsOpen NO \ + -ApplePersistenceIgnoreState YES \ + -XCTest All \ + "${TEST_APP_DIR}" \ + 2>&1 | tee "${LOGFILE}" + +killall "iOS Simulator" >/dev/null 2>/dev/null || : + +# TODO(danielwh): Much better support for detecting failures. Actually parse the log. +if grep -q "with [1-9].* failure" "${LOGFILE}"; then + exit 1 +fi -- cgit v1.2.3