diff options
author | 2015-10-05 15:13:41 +0000 | |
---|---|---|
committer | 2015-10-06 07:02:59 +0000 | |
commit | 6716ec32d329213d39b9831792ac40b65a3849cc (patch) | |
tree | 1d11ceabf2ba137f6aac4727c806ecdc3b04fec8 /src | |
parent | d3ec8ff875f8ac591c8c814b75f156cc077c2709 (diff) |
Add basic integration tests for Objective-C / iOS.
--
MOS_MIGRATED_REVID=104658547
Diffstat (limited to 'src')
-rw-r--r-- | src/test/shell/bazel/BUILD | 6 | ||||
-rwxr-xr-x | src/test/shell/bazel/bazel_objc_test.sh | 83 |
2 files changed, 89 insertions, 0 deletions
diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD index 63aed03a48..d502705d17 100644 --- a/src/test/shell/bazel/BUILD +++ b/src/test/shell/bazel/BUILD @@ -92,6 +92,12 @@ sh_test( ) sh_test( + name = "bazel_objc_test", + srcs = ["bazel_objc_test.sh"], + data = [":test-deps"], +) + +sh_test( name = "bazel_execute_testlog", srcs = ["bazel_execute_testlog.sh"], data = [":test-deps"], diff --git a/src/test/shell/bazel/bazel_objc_test.sh b/src/test/shell/bazel/bazel_objc_test.sh new file mode 100755 index 0000000000..94004b3580 --- /dev/null +++ b/src/test/shell/bazel/bazel_objc_test.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# +# Copyright 2015 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. + +# Load test environment +source $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/test-setup.sh \ + || { echo "test-setup.sh not found!" >&2; exit 1; } + +if [ "${PLATFORM}" != "darwin" ]; then + echo "This test suite requires running on OS X" >&2 + exit 0 +fi + +function make_app() { + rm -rf ios + mkdir -p ios + + cat >ios/app.m <<EOF +#import <UIKit/UIKit.h> + +int main(int argc, char *argv[]) { + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + int retVal = UIApplicationMain(argc, argv, nil, nil); + [pool release]; + return retVal; +} +EOF + + cat >ios/App-Info.plist <<EOF +<plist version="1.0"> +<dict> + <key>CFBundleExecutable</key> + <string>app</string> + <key>CFBundleName</key> + <string>app</string> + <key>CFBundleDisplayName</key> + <string>app</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleIdentifier</key> + <string>com.google.app</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>LSRequiresIPhoneOS</key> + <true/> +</dict> +</plist> +EOF + + cat >ios/BUILD <<EOF +objc_binary(name = "bin", + non_arc_srcs = ['app.m']) +ios_application(name = "app", + binary = ':bin', + infoplist = 'App-Info.plist') +EOF +} + +function test_build_app() { + setup_objc_test_support + make_app + + bazel build --verbose_failures \ + //ios:app >$TEST_log 2>&1 || fail "should pass" + ls bazel-bin/ios/app.xcodeproj || fail "should generate app.xcodeproj" + ls bazel-bin/ios/app.ipa || fail "should generate app.ipa" +} + +run_suite "objc/ios test suite" |