Skip to content

Commit

Permalink
test: workaround label resolving with bzlmod (#263)
Browse files Browse the repository at this point in the history
workaround label resolving with bzlmod
restrict canonical label resolving only when bzlmod is enabled
  • Loading branch information
cloudhan authored Aug 7, 2024
1 parent d29a88a commit 07bd546
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/flag/flag_validation_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ def _create_cuda_library_flag_test(*config_settings):
merged_config_settings = {}
for cs in config_settings:
for k, v in cs.items():
merged_config_settings[k] = v
# https://github.com/bazelbuild/bazel/issues/19286#issuecomment-1684325913
# Wrapping all keys into str(Label(...)) should be a workaround with Bazel 6 and later.
# NOTE: //command_line_option will resolve to @@//command_line_option which is not correct.
# Only apply to cuda related labels when bzlmod is enabled
is_bzlmod_enabled = str(Label("//:invalid")).startswith("@@")
if is_bzlmod_enabled and "cuda" in k:
merged_config_settings[str(Label(k))] = v
else:
merged_config_settings[k] = v
return analysistest.make(
cuda_library_flag_test_impl,
config_settings = merged_config_settings,
Expand Down

0 comments on commit 07bd546

Please sign in to comment.