-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(builtin): preserve lone $ in templated_args for legacy support (#…
…1772) This preservation may be removed in a future version so that templated_args behaves the same as the built-in *_binary and *_test args
- Loading branch information
1 parent
5c9878f
commit 72c14d8
Showing
6 changed files
with
60 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
internal/common/test/preserve_legacy_templated_args_test.bzl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"Unit tests for //internal/common:preserve_legacy_templated_args.bzl" | ||
|
||
load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest") | ||
load("//internal/common:preserve_legacy_templated_args.bzl", "preserve_legacy_templated_args") | ||
|
||
def _impl(ctx): | ||
env = unittest.begin(ctx) | ||
|
||
conversions = { | ||
"$": "$$", | ||
"$$": "$$", | ||
"$$$$(BAR)": "$$$$(BAR)", | ||
"$$(": "$$(", | ||
"$$(BAR)": "$$(BAR)", | ||
"$$(rlocation foobar)": "$$(rlocation foobar)", | ||
"$$(rlocation foobar)$$(rlocation foobar)": "$$(rlocation foobar)$$(rlocation foobar)", | ||
"$(": "$(", | ||
"$(BAR)": "$(BAR)", | ||
"$(rlocation foobar)": "$$(rlocation foobar)", | ||
"$(rlocation foobar)$(rlocation foobar)": "$$(rlocation foobar)$$(rlocation foobar)", | ||
"$(rlocation! foobar)": "$(rlocation! foobar)", | ||
"$(rlocation! foobar)$(rlocation! foobar)": "$(rlocation! foobar)$(rlocation! foobar)", | ||
} | ||
|
||
for key in conversions: | ||
asserts.equals(env, "%s" % conversions[key], preserve_legacy_templated_args("%s" % key)) | ||
asserts.equals(env, " %s " % conversions[key], preserve_legacy_templated_args(" %s " % key)) | ||
asserts.equals(env, "%s %s" % (conversions[key], conversions[key]), preserve_legacy_templated_args("%s %s" % (key, key))) | ||
asserts.equals(env, " %s %s " % (conversions[key], conversions[key]), preserve_legacy_templated_args(" %s %s " % (key, key))) | ||
asserts.equals(env, "a%sb%sc" % (conversions[key], conversions[key]), preserve_legacy_templated_args("a%sb%sc" % (key, key))) | ||
|
||
return unittest.end(env) | ||
|
||
preserve_legacy_templated_args_test = unittest.make( | ||
impl = _impl, | ||
attrs = {}, | ||
) | ||
|
||
def preserve_legacy_templated_args_test_suite(): | ||
unittest.suite("preserve_legacy_templated_args_tests", preserve_legacy_templated_args_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters