Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1915)

Unified Diff: testing/gtest_ios/run-unittest.sh

Issue 10832030: Add a helper script to run unit test targets for iOS (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Switch to 5.1 Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « testing/gtest.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/gtest_ios/run-unittest.sh
diff --git a/testing/gtest_ios/run-unittest.sh b/testing/gtest_ios/run-unittest.sh
new file mode 100755
index 0000000000000000000000000000000000000000..b1d28fca4e0bdb6557fa2dcfd53583a5c412f467
--- /dev/null
+++ b/testing/gtest_ios/run-unittest.sh
@@ -0,0 +1,87 @@
+#!/bin/bash -p
+
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+set -eu
+
+# Environment sanitization. Set a known-safe PATH. Clear environment variables
+# that might impact the interpreter's operation. The |bash -p| invocation
+# on the #! line takes the bite out of BASH_ENV, ENV, and SHELLOPTS (among
+# other features), but clearing them here ensures that they won't impact any
+# shell scripts used as utility programs. SHELLOPTS is read-only and can't be
+# unset, only unexported.
+export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
+unset BASH_ENV CDPATH ENV GLOBIGNORE IFS POSIXLY_CORRECT
+export -n SHELLOPTS
+
+readonly ScriptDir=$(dirname "$(echo ${0} | sed -e "s,^\([^/]\),$(pwd)/\1,")")
+readonly ScriptName=$(basename "${0}")
+readonly ThisScript="${ScriptDir}/${ScriptName}"
+readonly SimExecutable="${BUILD_DIR}/${CONFIGURATION}/iossim"
+
+# Helper to print a line formatted for Xcodes build output parser.
+XcodeNote() {
+ echo "${ThisScript}:${1}: note: ${2}"
+}
+
+# Helper to print a divider to make things stick out in a busy output window.
+XcodeHeader() {
+ echo "note: _________________________________________________________________"
+ echo "note: _________________________________________________________________"
+ echo "note: _________________________________________________________________"
+ XcodeNote "$1" ">>>>> $2"
+ echo "note: _________________________________________________________________"
+ echo "note: _________________________________________________________________"
+ echo "note: _________________________________________________________________"
+}
+
+# Kills the iPhone Simulator if it is running.
+KillSimulator() {
+ /usr/bin/killall "iPhone Simulator" 2> /dev/null || true
+}
+
+# Runs tests via the iPhone Simulator for multiple devices.
+RunTests() {
+ local -r appPath="${TARGET_BUILD_DIR}/${PRODUCT_NAME}.app"
+
+ if [[ ! -x "${SimExecutable}" ]]; then
+ echo "Unable to run tests: ${SimExecutable} was not found/executable."
+ exit 1
+ fi
+
+ for device in 'iPhone' 'iPad'; do
+ iosVersion="5.1"
+ KillSimulator
+ local command=(
+ "${SimExecutable}" "-d${device}" "-s${iosVersion}" "${appPath}"
+ )
+ # Pass along any command line flags
+ if [[ "$#" -gt 0 ]]; then
+ command+=( "--" "${@}" )
+ fi
+ XcodeHeader ${LINENO} "Launching tests for ${device} (iOS ${iosVersion})"
+ "${command[@]}"
+
+ # If the command didn't exit successfully, abort.
+ if [[ $? -ne 0 ]]; then
+ exit $?;
+ fi
+ done
+}
+
+# Time to get to work.
+
+if [[ "${PLATFORM_NAME}" != "iphonesimulator" ]]; then
+ XcodeNote ${LINENO} "Skipping running of unittests for device build."
+else
+ if [[ "$#" -gt 0 ]]; then
+ RunTests "${@}"
+ else
+ RunTests
+ fi
+ KillSimulator
+fi
+
+exit 0
« no previous file with comments | « testing/gtest.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698