Skip to content

Commit

Permalink
Allow select in test_host parameter (#820)
Browse files Browse the repository at this point in the history
Co-authored-by: Cody Vandermyn <cody.vandermyn@capitalone.com>
  • Loading branch information
codeman9 and Cody Vandermyn authored Jan 2, 2024
1 parent ba1fea7 commit 38facbd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
9 changes: 0 additions & 9 deletions rules/internal/framework_middleman.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,6 @@ def _dep_middleman(ctx):
for lib_dep in dep[AvoidDepsInfo].libraries:
_collect_providers(lib_dep)

# Pull AvoidDeps from test deps
for dep in (ctx.attr.test_deps if ctx.attr.test_deps else []):
if AvoidDepsInfo in dep:
_process_avoid_deps(dep[AvoidDepsInfo].libraries)

# Merge the entire provider here
objc_provider_fields = objc_provider_utils.merge_objc_providers_dict(providers = objc_providers, merge_keys = [
"force_load_library",
Expand Down Expand Up @@ -271,10 +266,6 @@ dep_middleman = rule(
"""Deps that may contain frameworks
""",
),
"test_deps": attr.label_list(
cfg = transition_support.split_transition,
allow_empty = True,
),
"platform_type": attr.string(
mandatory = False,
doc =
Expand Down
6 changes: 0 additions & 6 deletions rules/test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ def _ios_test(name, bundle_rule, test_rule, test_factory, apple_library, infopli
if split_name_to_kwargs:
ios_test_kwargs["split_name_to_kwargs"] = split_name_to_kwargs

# Deduplicate against the test deps
if ios_test_kwargs.get("test_host", None):
host_args = [ios_test_kwargs["test_host"]]
else:
host_args = []
library = apple_library(name = name, namespace_is_module_name = False, platforms = {"ios": ios_test_kwargs.get("minimum_os_version")}, testonly = testonly, **kwargs)

# Setup framework middlemen - need to process deps and libs
Expand All @@ -209,7 +204,6 @@ def _ios_test(name, bundle_rule, test_rule, test_factory, apple_library, infopli
deps = kwargs.get("deps", []) + library.lib_names,
testonly = testonly,
tags = ["manual"],
test_deps = host_args,
platform_type = "ios",
minimum_os_version = ios_test_kwargs.get("minimum_os_version"),
)
Expand Down
28 changes: 28 additions & 0 deletions tests/ios/unit-test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("//rules:test.bzl", "ios_unit_test")

ios_unit_test(
Expand Down Expand Up @@ -35,6 +36,33 @@ ios_unit_test(
visibility = ["//visibility:public"],
)

bool_flag(
name = "other_test_host",
build_setting_default = False,
)

config_setting(
name = "use_other_test_host",
flag_values = {
"//tests/ios/unit-test:other_test_host": "True",
},
)

ios_unit_test(
name = "ExplicitHostedWithSelect",
srcs = [
"empty.m",
"empty.swift",
],
minimum_os_version = "12.0",
test_host = select({
"//tests/ios/unit-test:use_other_test_host": "//rules/test_host_app:iOS-9.3-AppHost",
"//conditions:default": "//rules/test_host_app:iOS-14.0-AppHost",
}),
# Adding visibility so the xcodeproject tests can depend on this target
visibility = ["//visibility:public"],
)

ios_unit_test(
name = "ExplicitHostedWithAppExtensions",
srcs = [
Expand Down

0 comments on commit 38facbd

Please sign in to comment.