Skip to content

Commit

Permalink
Fix YAML tests using value and constraints together. (#13658)
Browse files Browse the repository at this point in the history
This used to not work because setDefaultResponse would add two entries
with the same name to the response.values list and then
chip_tests_item_response_parameters would just look for the first
entry in the list with the matching name and look for both value and
constraints on it.

The fix is to make setDefaultResponse produce the data structure that
chip_tests_item_response_parameters is expecting.
  • Loading branch information
bzbarsky-apple authored Jan 19, 2022
1 parent 7f766c6 commit 332f97c
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 39 deletions.
18 changes: 6 additions & 12 deletions src/app/zap-templates/common/ClusterTestGeneration.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,13 @@ function setDefaultResponse(test)
throwError(test, errorStr);
}

const name = test.isAttribute ? test.attribute : test.event;
const response = test[kResponseName];
if (hasResponseValue) {
const value = { name, value : response.value, saveAs : response.saveAs };
response.values.push(value);
}
if (hasResponseValueOrConstraints) {
const name = test.isAttribute ? test.attribute : test.event;
const response = test[kResponseName];
const responseValue = hasResponseValue ? { value : response.value } : null;
const constraintsValue = hasResponseConstraints ? { constraints : response.constraints } : null;

if (hasResponseConstraints) {
let constraints = { name : name, constraints : response.constraints };
if ('saveAs' in response && !hasResponseValue) {
constraints.saveAs = response.saveAs;
}
response.values.push(constraints);
response.values.push({ name, saveAs : response.saveAs, ...responseValue, ...constraintsValue });
}

delete test[kResponseName].value;
Expand Down
108 changes: 108 additions & 0 deletions src/darwin/Framework/CHIPTests/CHIPClustersTests.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 332f97c

Please sign in to comment.