aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java
diff options
context:
space:
mode:
authorGravatar cparsons <cparsons@google.com>2017-08-27 19:28:32 +0200
committerGravatar Vladimir Moskva <vladmos@google.com>2017-08-28 16:09:37 +0200
commit81ce9e3f2817389532d752cb325e1f0d14b69cfc (patch)
tree4e44cc265a99ed1bdb14bd9ff0966a9fd8ae4ab8 /src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java
parent89b314c9b486ac03006af2eaeb9809e94b1c7508 (diff)
Open source some objc tests. Most notably, proto and j2objc tests still remain, but will follow.
RELNOTES: None. PiperOrigin-RevId: 166635306
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java94
1 files changed, 56 insertions, 38 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java b/src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java
index 4cbf95a631..73f9e9b491 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java
@@ -37,6 +37,11 @@ public final class MockObjcSupport {
private static final String DEFAULT_OSX_CROSSTOOL_DIR = "tools/osx/crosstool";
private static final String MOCK_OSX_CROSSTOOL_FILE =
"com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL";
+
+ /** The label of the {@code xcode_config} target used in test to enumerate available xcodes. */
+ public static final String XCODE_VERSION_CONFIG =
+ TestConstants.TOOLS_REPOSITORY + "//tools/objc:host_xcodes";
+
/**
* The build label for the mock OSX crosstool configuration.
*/
@@ -69,10 +74,10 @@ public final class MockObjcSupport {
"xcrunwrapper",
"mcov",
"libtool")) {
- config.create("tools/objc/" + tool);
+ config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/" + tool);
}
config.create(
- "tools/objc/BUILD",
+ TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/BUILD",
"package(default_visibility=['//visibility:public'])",
"exports_files(glob(['**']))",
"filegroup(name = 'default_provisioning_profile', srcs = ['foo.mobileprovision'])",
@@ -89,7 +94,8 @@ public final class MockObjcSupport {
"objc_binary(name = 'xctest_appbin', srcs = ['objc_dummy.mm'])",
"filegroup(",
" name = 'protobuf_well_known_types',",
- " srcs = ['//objcproto:well_known_type.proto'],",
+ String.format(
+ " srcs = ['%s//objcproto:well_known_type.proto'],", TestConstants.TOOLS_REPOSITORY),
")",
"xcode_config(name = 'host_xcodes', default = ':version7_3_1')",
"xcode_version(",
@@ -98,24 +104,42 @@ public final class MockObjcSupport {
" default_ios_sdk_version = \"" + DEFAULT_IOS_SDK_VERSION + "\",",
")",
"objc_library(name = 'dummy_lib', srcs = ['objc_dummy.mm'])");
- config.create("tools/objc/foo.mobileprovision", "No such luck");
- config.create("tools/objc/compile_protos.py");
- config.create("tools/objc/xctest.plist");
- config.create("tools/objc/proto_support");
- config.create("tools/objc/ios_runner.sh.mac_template");
- config.create("tools/objc/j2objc_dead_code_pruner.py");
- config.create("tools/objc/header_scanner");
+ // If the bazel tools repository is not in the workspace, also create a workspace tools/objc
+ // package with a few lingering dependencies.
+ // TODO(b/64537078): Move these dependencies underneath the tools workspace.
+ if (TestConstants.TOOLS_REPOSITORY_SCRATCH.length() > 0) {
+ config.create(
+ "tools/objc/BUILD",
+ "package(default_visibility=['//visibility:public'])",
+ "exports_files(glob(['**']))",
+ "ios_application(name = 'xctest_app', binary = ':xctest_appbin')",
+ "objc_binary(name = 'xctest_appbin', srcs = ['objc_dummy.mm'])",
+ "filegroup(name = 'default_provisioning_profile', srcs = ['foo.mobileprovision'])",
+ "filegroup(name = 'xctest_infoplist', srcs = ['xctest.plist'])");
+ }
+ config.create(
+ TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/foo.mobileprovision", "No such luck");
+ config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/compile_protos.py");
+ config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/xctest.plist");
+ config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/proto_support");
+ config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/ios_runner.sh.mac_template");
+ config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/j2objc_dead_code_pruner.py");
+ config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/header_scanner");
createCrosstoolPackage(config, partialToolchainLines);
+ setupIosSimDevice(config);
+ setupIosTest(config);
+ setupObjcProto(config);
}
/**
* Sets up mock IOS test support.
*/
public static void setupIosTest(MockToolsConfig config) throws IOException {
- config.create("tools/objc/precomp_testrunner_deploy.jar");
- config.create("tools/objc/StdRedirect.dylib");
+ config.create(
+ TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/precomp_testrunner_deploy.jar");
+ config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/StdRedirect.dylib");
createMemleaksSim(config);
- config.create("tools/objc/ios_test.sh.bazel_template");
+ config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/ios_test.sh.bazel_template");
}
/**
@@ -123,7 +147,7 @@ public final class MockObjcSupport {
*/
public static void setupIosSimDevice(MockToolsConfig config) throws IOException {
config.create(
- "tools/objc/sim_devices/BUILD",
+ TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/sim_devices/BUILD",
"ios_device(",
" name = 'default',",
" ios_version = '9.8',",
@@ -132,34 +156,22 @@ public final class MockObjcSupport {
}
private static void createMemleaksSim(MockToolsConfig config) throws IOException {
- config.create("tools/objc/memleaks/BUILD",
- "package(default_visibility=['//visibility:public'])",
+ config.create(
+ TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/memleaks/BUILD",
+ "package(default_visibility=['//visibility:public'])",
"objc_library(",
" name = 'memleaks',",
" srcs = ['memleaks.m'],",
")");
- config.create("tools/objc/memleaks/libmemleaks.a");
- config.create("tools/objc/memleaks_plugin");
+ config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/memleaks/libmemleaks.a");
+ config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/memleaks_plugin");
}
- /**
- * Sets up the support for building protocol buffers for ObjC.
- */
- public static void setupObjcProto(MockToolsConfig config) throws IOException {
- config.overwrite(
- "WORKSPACE",
- TestConstants.WORKSPACE_CONTENT + "bind(",
- " name = 'objc_proto_lib',",
- " actual = '//objcproto:ProtocolBuffers_lib',",
- ")",
- "bind(",
- " name = 'objc_protobuf_lib',",
- " actual = '//objcproto:protobuf_lib',",
- ")");
-
+ /** Sets up the support for building protocol buffers for ObjC. */
+ private static void setupObjcProto(MockToolsConfig config) throws IOException {
config.create(
- "objcproto/BUILD",
+ TestConstants.TOOLS_REPOSITORY_SCRATCH + "objcproto/BUILD",
"package(default_visibility=['//visibility:public'])",
"objc_library(",
" name = 'ProtocolBuffers_lib',",
@@ -176,9 +188,9 @@ public final class MockObjcSupport {
" name = 'well_known_type_proto',",
" srcs = ['well_known_type.proto'],",
")");
- config.create("objcproto/empty.m");
- config.create("objcproto/empty.cc");
- config.create("objcproto/well_known_type.proto");
+ config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "objcproto/empty.m");
+ config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "objcproto/empty.cc");
+ config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "objcproto/well_known_type.proto");
}
/**
@@ -250,12 +262,18 @@ public final class MockObjcSupport {
" srcs = [",
" 'ar',",
" 'libempty.a',",
- " '//tools/objc:libtool'",
+ String.format(" '%s//tools/objc:libtool'", TestConstants.TOOLS_REPOSITORY),
" ],",
")");
for (String arch :
ImmutableList.of(
+ // TODO(b/64492583): Remove 'darwin', as this is legacy and redundant with
+ // darwin_x86_64.
+ "darwin",
+ // TODO(b/36471772): Remove 'k8' once unit tests do not require a host configuration
+ // transition from the apple crosstool configuration.
+ "x64_windows",
"ios_x86_64",
"ios_i386",
"ios_armv7",