aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/objc
diff options
context:
space:
mode:
authorGravatar Daniel Wagner-Hall <danielwh@google.com>2015-05-04 15:07:29 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2015-05-04 17:52:07 +0000
commit1f4ce8034892aa490269aacf2fd4c74122d72920 (patch)
tree39d354277e2ad63fd304480c548529f951391a9e /tools/objc
parent497d35e06119c560cbf1198bf68ae11824094240 (diff)
Add ios_test.sh.bazel_template
-- MOS_MIGRATED_REVID=92725547
Diffstat (limited to 'tools/objc')
-rw-r--r--tools/objc/BUILD4
-rw-r--r--tools/objc/ios_test.sh.bazel_template54
2 files changed, 58 insertions, 0 deletions
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