Files
SwiftLint/Tests/test_macros.bzl
JP Simard 3c2f4e31c9 Shard GeneratedTests into parallel targets and refactor code generation (#6102)
Split the monolithic GeneratedTests target (242 test classes) into 10
sharded targets with ~25 tests each to enable parallel test execution.
Reduces test time from 85.4s to 36.7s (57% improvement) by running
shards concurrently. Most shards finish in 2-8s with 2 outliers at
30-37s.

The implementation automatically scales with new rules and provides
parallel test execution with improved code maintainability.
2025-06-19 22:20:17 +00:00

28 lines
1005 B
Python

load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library", "swift_test")
def generated_test_shard(shard_number, copts, strict_concurrency_copts):
"""Creates a single generated test shard with library and test targets.
Args:
shard_number: The shard number as a string
copts: Common compiler options
strict_concurrency_copts: Strict concurrency compiler options
"""
swift_library(
name = "GeneratedTests_{}.library".format(shard_number),
testonly = True,
srcs = ["GeneratedTests/GeneratedTests_{}.swift".format(shard_number)],
module_name = "GeneratedTests_{}".format(shard_number),
package_name = "SwiftLint",
deps = [
":TestHelpers",
],
copts = copts + strict_concurrency_copts,
)
swift_test(
name = "GeneratedTests_{}".format(shard_number),
visibility = ["//visibility:public"],
deps = [":GeneratedTests_{}.library".format(shard_number)],
)