Skip to content

Commit

Permalink
Add basic integration tests for Objective-C / iOS.
Browse files Browse the repository at this point in the history
--
MOS_MIGRATED_REVID=104658547
  • Loading branch information
c-parsons authored and laszlocsomor committed Oct 6, 2015
1 parent d3ec8ff commit 6716ec3
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/test/shell/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ sh_test(
data = [":test-deps"],
)

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"],
Expand Down
83 changes: 83 additions & 0 deletions src/test/shell/bazel/bazel_objc_test.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 6716ec3

Please sign in to comment.