Skip to content

Commit

Permalink
Convert all shell tests to starlark (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
keith authored Aug 21, 2023
1 parent fa9fad0 commit a928c55
Show file tree
Hide file tree
Showing 15 changed files with 208 additions and 477 deletions.
2 changes: 0 additions & 2 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ tasks:
test_targets:
- '@apple_support//test/...'
- '--'
- '-@apple_support//test/shell:apple_test'
- '-@apple_support//test/shell:objc_test'
# Needs the new toolchain
- '-@apple_support//test:linking_disable_objc_apple_link_test'
70 changes: 70 additions & 0 deletions test/binary_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ def binary_test_suite(name):
target_under_test = "//test/test_data:macos_binary",
)

apple_verification_test(
name = "{}_macos_binary_with_spaces_test".format(name),
tags = [name],
build_type = "device",
cpus = {"macos_cpus": "x86_64"},
expected_platform_type = "macos",
generate_dsym = True,
verifier_script = "//test/shell:verify_binary.sh",
target_under_test = "//test/test_data:macos_binary_with_spaces",
)

apple_verification_test(
name = "{}_visionos_device_test".format(name),
tags = [name],
Expand Down Expand Up @@ -73,3 +84,62 @@ def binary_test_suite(name):
target_under_test = "//test/test_data:ios_app_with_unused_symbol",
tags = [name],
)

apple_verification_test(
name = "{}_archive_timestamps".format(name),
build_type = "simulator",
cpus = {"ios_multi_cpus": "x86_64"},
verifier_script = "//test:verify_archive_timestamps.sh",
target_under_test = "//test/test_data:static_lib",
tags = [name],
)

apple_verification_test(
name = "{}_fat_static_lib".format(name),
build_type = "simulator",
cpus = {"ios_multi_cpus": "x86_64,sim_arm64"},
expected_platform_type = "ios",
verifier_script = "//test/shell:verify_binary.sh",
target_under_test = "//test/test_data:static_lib",
tags = [name],
)

apple_verification_test(
name = "{}_watchos_device_test".format(name),
tags = [name],
build_type = "device",
cpus = {"watchos_cpus": "x86_64"},
expected_platform_type = "watchos",
verifier_script = "//test/shell:verify_binary.sh",
target_under_test = "//test/test_data:watch_binary",
)

apple_verification_test(
name = "{}_watchos_simulator_test".format(name),
tags = [name],
build_type = "device",
cpus = {"watchos_cpus": "arm64"},
expected_platform_type = "watchos",
verifier_script = "//test/shell:verify_binary.sh",
target_under_test = "//test/test_data:watch_binary",
)

apple_verification_test(
name = "{}_ios_device_test".format(name),
tags = [name],
build_type = "device",
cpus = {"ios_multi_cpus": "x86_64,sim_arm64"},
expected_platform_type = "ios",
verifier_script = "//test/shell:verify_binary.sh",
target_under_test = "//test/test_data:ios_binary",
)

apple_verification_test(
name = "{}_ios_simulator_test".format(name),
tags = [name],
build_type = "device",
cpus = {"ios_multi_cpus": "arm64,arm64e"},
expected_platform_type = "ios",
verifier_script = "//test/shell:verify_binary.sh",
target_under_test = "//test/test_data:ios_binary",
)
21 changes: 21 additions & 0 deletions test/linking_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ disable_objc_test = make_action_command_line_test_rule(
},
)

dsym_test = make_action_command_line_test_rule(
config_settings = {
"//command_line_option:apple_generate_dsym": True,
},
)

def linking_test_suite(name):
default_test(
name = "{}_default_apple_link_test".format(name),
Expand All @@ -26,6 +32,10 @@ def linking_test_suite(name):
"2",
"-ObjC",
],
not_expected_argv = [
"-g",
"DSYM_HINT_LINKED_BINARY",
],
mnemonic = "ObjcLink",
target_under_test = "//test/test_data:macos_binary",
)
Expand All @@ -43,3 +53,14 @@ def linking_test_suite(name):
mnemonic = "ObjcLink",
target_under_test = "//test/test_data:macos_binary",
)

dsym_test(
name = "{}_generate_dsym_test".format(name),
tags = [name],
expected_argv = [
"-g",
"DSYM_HINT_LINKED_BINARY",
],
mnemonic = "ObjcLink",
target_under_test = "//test/test_data:macos_binary",
)
8 changes: 8 additions & 0 deletions test/rules/apple_verification_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ _supports_visionos = hasattr(apple_common.platform_type, "visionos")

def _transition_impl(_, attr):
output_dictionary = {
"//command_line_option:apple_generate_dsym": attr.generate_dsym,
"//command_line_option:compilation_mode": attr.compilation_mode,
"//command_line_option:cpu": "darwin_x86_64",
"//command_line_option:ios_signing_cert_name": "-",
Expand Down Expand Up @@ -56,6 +57,7 @@ _transition = transition(
implementation = _transition_impl,
inputs = [],
outputs = [
"//command_line_option:apple_generate_dsym",
"//command_line_option:compilation_mode",
"//command_line_option:cpu",
"//command_line_option:ios_multi_cpus",
Expand Down Expand Up @@ -110,6 +112,12 @@ def _apple_verification_test_impl(ctx):
apple_verification_test = rule(
implementation = _apple_verification_test_impl,
attrs = {
"generate_dsym": attr.bool(
default = False,
doc = """
Whether to generate a dSYM file for the binary under test.
""",
),
"build_type": attr.string(
mandatory = True,
values = ["simulator", "device"],
Expand Down
20 changes: 0 additions & 20 deletions test/shell/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,6 @@ sh_library(
],
)

sh_test(
name = "objc_test",
size = "large",
srcs = ["objc_test.sh"],
data = [":for_bazel_tests"],
deps = [
":bashunit",
],
)

sh_test(
name = "apple_test",
srcs = ["apple_test.sh"],
data = [":for_bazel_tests"],
shard_count = 3,
deps = [
":bashunit",
],
)

sh_test(
name = "wrapped_clang_test",
size = "small",
Expand Down
Loading

0 comments on commit a928c55

Please sign in to comment.