Skip to content

Commit 070854a

Browse files
Stop relying on the input .zap file in Matter test codegen. (#1035)
To keep backwards compat with old Matter revisions, we require explicit includeAllClusters=true in the templates to get the new behavior.
1 parent 4e0ae8c commit 070854a

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

src-electron/generator/matter/app/zap-templates/common/ClusterTestGeneration.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,12 @@ async function chip_tests(listOrJson, options) {
640640
let global = this.global;
641641
let items;
642642

643+
if (options.hash.includeAllClusters) {
644+
// Trigger fetch of the cluster bits before some of the iterators inside us
645+
// try to do it and fail to pass includeAllClusters=true.
646+
getClusters(this, /* includeAllClusters = */ true)
647+
}
648+
643649
if (Array.isArray(listOrJson)) {
644650
items = listOrJson;
645651
} else {
@@ -1036,7 +1042,7 @@ function checkIsInsideTestOnlyClusterBlock(conditions, name) {
10361042
* @param {*} options
10371043
*/
10381044
async function chip_tests_only_clusters(options) {
1039-
const clusters = await getClusters(this);
1045+
const clusters = await getClusters(this, options.hash.includeAllClusters);
10401046
const testOnlyClusters = clusters.filter((cluster) =>
10411047
isTestOnlyCluster(cluster.name)
10421048
);

src-electron/generator/matter/app/zap-templates/common/ClustersHelper.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ Clusters._computeUsedStructureNames = async function (structs) {
789789
* If includeAll is true, all events/commands/attributes will be included, not
790790
* just the ones enabled in the ZAP configuration.
791791
*/
792-
Clusters.init = async function (context, includeAll) {
792+
Clusters.init = async function (context, includeAllClusterConstructs, includeAllClusters) {
793793
try {
794794
if (this.ready.running) {
795795
return this.ready;
@@ -813,17 +813,17 @@ Clusters.init = async function (context, includeAll) {
813813
const promises = [
814814
Promise.all(loadTypes),
815815
loadEndpoints.call(context),
816-
// For now just always use loadClusters, because we have a bunch of things
817-
// defined in our XML that are not actually part of Matter.
818-
loadClusters.call(context),
819-
includeAll
816+
includeAllClusters
817+
? loadAllClusters.call(context, packageIds)
818+
: loadClusters.call(context),
819+
includeAllClusterConstructs
820820
? loadAllCommands.call(context, packageIds)
821821
: loadCommands.call(context, packageIds),
822-
includeAll
822+
includeAllClusterConstructs
823823
? loadAllAttributes.call(context, packageIds)
824824
: loadAttributes.call(context),
825825
loadGlobalAttributes.call(context, packageIds),
826-
(includeAll ? loadAllEvents : loadEvents).call(context, packageIds),
826+
(includeAllClusterConstructs ? loadAllEvents : loadEvents).call(context, packageIds),
827827
];
828828

829829
let [
@@ -865,12 +865,12 @@ function asBlocks(promise, options) {
865865
);
866866
}
867867

868-
function ensureClusters(context, includeAll = false) {
868+
function ensureClusters(context, includeAllClusterConstructs = false, includeAllClusters = false) {
869869
// Kick off Clusters initialization. This is async, but that's fine: all the
870870
// getters on Clusters wait on that initialziation to complete.
871871
ensureState(context, "Don't have a context");
872872

873-
Clusters.init(context, includeAll);
873+
Clusters.init(context, includeAllClusterConstructs, includeAllClusters);
874874
return Clusters;
875875
}
876876

src-electron/generator/matter/app/zap-templates/common/simulated-clusters/SimulatedClusters.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ function getSimulatedCluster(clusterName) {
6363
return SimulatedClusters.find((cluster) => cluster.name == clusterName);
6464
}
6565

66-
function getClusters(context) {
67-
return ensureClusters(context, true)
66+
function getClusters(context, includeAllClusters = false) {
67+
return ensureClusters(context, true, includeAllClusters)
6868
.getClusters()
6969
.then((clusters) => clusters.concat(SimulatedClusters).flat(1));
7070
}

0 commit comments

Comments
 (0)