diff options
-rwxr-xr-x | src/test/shell/bazel/bazel_objc_test.sh | 42 | ||||
-rwxr-xr-x | src/test/shell/bazel/test-setup.sh | 22 | ||||
-rw-r--r-- | tools/objc/BUILD | 3 | ||||
-rw-r--r-- | tools/objc/sim_devices/BUILD | 7 | ||||
-rw-r--r-- | tools/objc/testrunner_stub | 8 |
5 files changed, 72 insertions, 10 deletions
diff --git a/src/test/shell/bazel/bazel_objc_test.sh b/src/test/shell/bazel/bazel_objc_test.sh index 94004b3580..7b0ceeb5b8 100755 --- a/src/test/shell/bazel/bazel_objc_test.sh +++ b/src/test/shell/bazel/bazel_objc_test.sh @@ -61,12 +61,42 @@ EOF </plist> EOF + cat >ios/PassTest-Info.plist <<EOF +<plist version="1.0"> +<dict> + <key>CFBundleExecutable</key> + <string>PassingXcTest</string> +</dict> +</plist> +EOF + + cat >ios/passtest.m <<EOF +#import <XCTest/XCTest.h> + +@interface PassingXcTest : XCTestCase + +@end + +@implementation PassingXcTest + +- (void)testPass { + XCTAssertEqual(1, 1, @"should pass"); +} + +@end +EOF + cat >ios/BUILD <<EOF objc_binary(name = "bin", non_arc_srcs = ['app.m']) ios_application(name = "app", binary = ':bin', infoplist = 'App-Info.plist') +ios_test(name = 'PassingXcTest', + srcs = ['passtest.m'], + infoplist = "PassTest-Info.plist", + xctest = True, + xctest_app = ':app') EOF } @@ -80,4 +110,16 @@ function test_build_app() { ls bazel-bin/ios/app.ipa || fail "should generate app.ipa" } +function test_ios_test() { + setup_objc_test_support + make_app + + bazel build --test_output=all //ios:PassingXcTest >$TEST_log 2>&1 \ + || fail "should pass" + ls bazel-bin/ios/PassingXcTest.xcodeproj \ + || fail "should generate PassingXcTest.xcodeproj" + ls bazel-bin/ios/PassingXcTest.ipa \ + || fail "should generate PassingXcTest.ipa" +} + run_suite "objc/ios test suite" diff --git a/src/test/shell/bazel/test-setup.sh b/src/test/shell/bazel/test-setup.sh index 204a4fb419..cddaf9c90e 100755 --- a/src/test/shell/bazel/test-setup.sh +++ b/src/test/shell/bazel/test-setup.sh @@ -308,6 +308,18 @@ filegroup( EOF } +function setup_iossim() { + mkdir -p third_party/iossim + ln -sv ${iossim_path} third_party/iossim/iossim + + cat <<EOF >>third_party/iossim/BUILD +licenses(["unencumbered"]) +package(default_visibility = ["//visibility:public"]) + +exports_files(["iossim"]) +EOF +} + # Sets up Objective-C tools. Mac only. function setup_objc_test_support() { mkdir -p tools/objc @@ -322,15 +334,7 @@ function setup_objc_test_support() { [ -e tools/objc/realpath ] || ln -sv ${realpath_path} tools/objc/realpath [ -e tools/objc/environment_plist.sh ] || ln -sv ${environment_plist_path} tools/objc/environment_plist.sh - mkdir -p third_party/iossim - [ -e third_party/iossim/iossim ] || ln -sv ${iossim_path} third_party/iossim/iossim - - cat <<EOF >>third_party/iossim/BUILD -licenses(["unencumbered"]) -package(default_visibility = ["//visibility:public"]) - -exports_files(["iossim"]) -EOF + [ -e third_party/iossim/iossim ] || setup_iossim } workspaces=() diff --git a/tools/objc/BUILD b/tools/objc/BUILD index 7f8713779f..1e2875c813 100644 --- a/tools/objc/BUILD +++ b/tools/objc/BUILD @@ -47,11 +47,12 @@ java_binary( filegroup( name = "srcs", - srcs = glob(["**"]), + srcs = glob(["**"]) + ["//tools/objc/sim_devices:BUILD"], ) filegroup( name = "testrunner", + srcs = [":testrunner_stub"], ) sh_binary( diff --git a/tools/objc/sim_devices/BUILD b/tools/objc/sim_devices/BUILD new file mode 100644 index 0000000000..5d81e1bdd3 --- /dev/null +++ b/tools/objc/sim_devices/BUILD @@ -0,0 +1,7 @@ +package(default_visibility = ["//visibility:public"]) + +ios_device( + name = "default", + ios_version = "8.4", + type = "IPHONE", +) diff --git a/tools/objc/testrunner_stub b/tools/objc/testrunner_stub new file mode 100644 index 0000000000..5c7a546658 --- /dev/null +++ b/tools/objc/testrunner_stub @@ -0,0 +1,8 @@ +#!/bin/bash + +( + printf 'Bazel does not support running ios_tests directly.\n' + printf 'Use "bazel build (TARGET) to generate an .xcodeproj."\n' +) >&2 + +exit 1 |