Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass -enable-testing when compiling the sources in a swift_test in discovery mode #1274

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions swift/swift_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,13 @@ def _swift_test_impl(ctx):
# In test discovery mode (whether manual or by the Obj-C runtime),
# compile the code with `-parse-as-library` to avoid the case where
# a single file with no top-level code still produces an empty
# `main`.
additional_copts = ["-parse-as-library"] if discover_tests else _maybe_parse_as_library_copts(srcs),
# `main`. Also compile with `-enable-testing`, because the generated
# sources will `@testable import` this module, and this allows that
# to work even when building in `-c opt` mode.
additional_copts = [
"-parse-as-library",
"-enable-testing",
] if discover_tests else _maybe_parse_as_library_copts(srcs),
cc_infos = deps_cc_infos,
feature_configuration = feature_configuration,
include_dev_srch_paths = include_dev_srch_paths,
Expand Down