buildtools icon indicating copy to clipboard operation
buildtools copied to clipboard

buildozer dict_set does not support selects?

Open jmacnak opened this issue 1 month ago • 0 comments

Adding the following to buildozer/buildozer_test.sh:

function test_dict_set_with_select() {
  in='cc_library(
    name = "lib",
    a_dictionary_attribute = {
        "key1": "val1",
    } | select({
        "@platforms//cpu:arm64": {
            "key2": "val2",
        },
        "//conditions:default": {},
    }),
)'
  run "$in" 'dict_set a_dictionary_attribute "key3":"val3"' //pkg:lib
  assert_equals 'cc_library(
    name = "lib",
    a_dictionary_attribute = {
        "key1": "val1",
        "key3": "val3",
    } | select({
        "@platforms//cpu:arm64": {
            "key2": "val2",
        },
        "//conditions:default": {},
    }),
)'
}

and running bazel test buildozer:buildozer_test --test_output=streamed shows

 cc_library(
     name = "lib",
-    a_dictionary_attribute = {
-        "key1": "val1",
-        "key3": "val3",
-    } | select({
-        "@platforms//cpu:arm64": {
-            "key2": "val2",
-        },
-        "//conditions:default": {},
-    }),
+    a_dictionary_attribute = {"\"key3\"": "val3"},
 )

jmacnak avatar Dec 02 '25 23:12 jmacnak