Skip to content

Commit

Permalink
Fix darwin YAML tests to use config variables more correctly. (#15199)
Browse files Browse the repository at this point in the history
Still does not allow specifying an override value, but should not at
least use the config defaults properly.

Fixes #15192
  • Loading branch information
bzbarsky-apple authored Feb 15, 2022
1 parent 6ea126d commit b9536c8
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 126 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{! If the defined value is the name of a config variable, just
substitute the value of the variable instead. }}
{{#if (chip_tests_config_has definedValue)~}}
{{chip_tests_config_get_default_value definedValue}}
{{~else~}}
{{definedValue}}
{{~/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ResponseHandler {{> subscribeDataCallback}} = nil;

{{#if (isTestOnlyCluster cluster)}}
dispatch_queue_t queue = dispatch_get_main_queue();
{{command}}(expectation, queue{{#chip_tests_item_parameters}}, {{#if (isString type)}}@"{{/if}}{{definedValue}}{{#if (isString type)}}"{{/if}}{{/chip_tests_item_parameters}});
{{command}}(expectation, queue{{#chip_tests_item_parameters}}, {{#if (isString type)}}@"{{/if}}{{> defined_value}}{{#if (isString type)}}"{{/if}}{{/chip_tests_item_parameters}});
{{else}}
CHIPDevice * device = GetConnectedDevice();
dispatch_queue_t queue = dispatch_get_main_queue();
Expand Down Expand Up @@ -217,7 +217,7 @@ ResponseHandler {{> subscribeDataCallback}} = nil;
{{#*inline "minCommandTimeout"~}}
{{#if (isTestOnlyCluster cluster)~}}
{{#if (isStrEqual command "WaitForMs")~}}
{{#chip_tests_item_parameters}}{{#if (isStrEqual name "ms")}}({{definedValue}} / 1000) + {{/if}}{{/chip_tests_item_parameters}}
{{#chip_tests_item_parameters}}{{#if (isStrEqual name "ms")}}({{> defined_value}} / 1000) + {{/if}}{{/chip_tests_item_parameters}}
{{~/if}}
{{~/if}}
{{~/inline}}
Expand Down
5 changes: 4 additions & 1 deletion src/darwin/Framework/CHIP/templates/partials/test_value.zapt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{{#if isOptional}}
{{#if (chip_tests_config_has definedValue)}}
{{! Just replace the value's name with the actual value in the rest of the processing~}}
{{>test_value target=target definedValue=(chip_tests_config_get_default_value definedValue) cluster=cluster depth=depth}}
{{else if isOptional}}
{{! Just go ahead and assign to the value, stripping the optionality bit off. }}
{{>test_value target=target definedValue=definedValue cluster=cluster isOptional=false depth=(incrementDepth depth)}}
{{else if isNullable}}
Expand Down
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP/templates/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
{
"name": "attribute_data_callback_name",
"path": "partials/attribute_data_callback_name.zapt"
},
{
"name": "defined_value",
"path": "partials/defined_value.zapt"
}
],
"templates": [
Expand Down
Loading

0 comments on commit b9536c8

Please sign in to comment.