Permalink
Browse files

[Author: agrieve]

-Add logic to RunIPhoneUnitTest.sh to allow skipping tests based on the TEST_AFTER_BUILD variable
-Add a script to GTM for running the active target using xcodebuild, and enabling TEST_AFTER_BUILD.

R=thomasvl
APPROVED=thomasvl
DELTA=52  (51 added, 0 deleted, 1 changed)

git-svn-id: http://google-toolbox-for-mac.googlecode.com/svn/trunk@531 7dc7ac4e-7543-0410-b95c-c1676fc8e2a3
  • Loading branch information...
1 parent 6b2fd89 commit 46d38f0cd2158b38d6b7ff3f0976bb36f6f540c5 gtm.daemon committed Apr 12, 2012
Showing with 52 additions and 1 deletion.
  1. +43 −0 UnitTesting/BuildUsingXCodeBuild.sh
  2. +9 −1 UnitTesting/RunIPhoneUnitTest.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+# BuildUsingXCodeBuild.sh
+
+# Copyright 2012 Google Inc.
+#
+# 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.
+
+# Run this in a custom build phase in order to force compilation of the target
+# to occur using xcodebuild. This is useful if you have a "Test All" target
+# that depends on multiple unit test targets, each of which disable automatic
+# running of unit tests when build from the IDE.
+
+if [[ $TEST_AFTER_BUILD == YES ]]; then
+ # Already being built with xcodebuild.
+ exit 0
+fi
+
+# RUN_CLANG_STATIC_ANALYZER is set to NO since the build done in the IDE would
+# have already analyzed the files.
+# TEST_AFTER_BUILD is explicitly set to YES to ensure that when we build
+# through xcodebuild we will not hit this point again. xcodebuild used to
+# set this to YES itself, but starting with 4.3, it no longer sets it.
+exec $DEVELOPER_BIN_DIR/xcodebuild \
+ -project "${PROJECT_FILE_PATH}" \
+ -target "${TARGET_NAME}" \
+ -sdk "${SDKROOT}" \
+ -configuration "$CONFIGURATION" \
+ SDKROOT="${SDKROOT}" \
+ ONLY_ACTIVE_ARCH="${ONLY_ACTIVE_ARCH}" \
+ ARCHS="${ARCHS}" \
+ RUN_CLANG_STATIC_ANALYZER=NO \
+ TEST_AFTER_BUILD=YES \
+ "$@"
@@ -66,6 +66,12 @@ GTM_DISABLE_USERDIR_SETUP=${GTM_DISABLE_USERDIR_SETUP:=0}
# to turn it on.
GTM_DISABLE_IPHONE_LAUNCH_DAEMONS=${GTM_DISABLE_IPHONE_LAUNCH_DAEMONS:=1}
+# GTM_TEST_AFTER_BUILD
+# When set to 1, tests are run only when TEST_AFTER_BUILD is set to "YES".
+# This can be used to have tests run as an after build step when running
+# from the command line, but not when running from within XCode.
+GTM_USE_TEST_AFTER_BUILD=${GTM_USE_TEST_AFTER_BUILD:=0}
+
ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
ScriptName=$(basename "$0")
ThisScript="${ScriptDir}/${ScriptName}"
@@ -94,7 +100,9 @@ GTMCreateLaunchDaemonPlist() {
-c "Add :MachServices:com.apple.securityd bool YES" "$plist_file" > /dev/null
}
-if [ "$PLATFORM_NAME" == "iphonesimulator" ]; then
+if [[ "$GTM_USE_TEST_AFTER_BUILD" == 1 && "$TEST_AFTER_BUILD" == "NO" ]]; then
+ GTMXcodeNote ${LINENO} "Skipping running of unittests since TEST_AFTER_BUILD=NO."
+elif [ "$PLATFORM_NAME" == "iphonesimulator" ]; then
# We kill the iPhone simulator because otherwise we run into issues where
# the unittests fail becuase the simulator is currently running, and
# at this time the iPhone SDK won't allow two simulators running at the same

0 comments on commit 46d38f0

Please sign in to comment.