test: relax check in verify-graph

Relax the check regarding presence of async resources in graph to
allow extra events. Before this change events not mentioned in
reference graph were allowed but that one specified must match
exactly in count. Now it's allowed to have more events of this
type.

Refs: https://github.com/nodejs/node/pull/27477
Fixes: https://github.com/nodejs/node/issues/27617

PR-URL: https://github.com/nodejs/node/pull/27742
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Gerhard Stoebich 2019-05-17 00:59:57 +02:00 committed by Anna Henningsen
parent bd895af1f8
commit ee59763ab3
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -99,7 +99,7 @@ module.exports = function verifyGraph(hooks, graph) {
}
assert.strictEqual(errors.length, 0);
// Verify that all expected types are present
// Verify that all expected types are present (but more/others are allowed)
const expTypes = Object.create(null);
for (let i = 0; i < graph.length; i++) {
if (expTypes[graph[i].type] == null) expTypes[graph[i].type] = 0;
@ -107,9 +107,9 @@ module.exports = function verifyGraph(hooks, graph) {
}
for (const type in expTypes) {
assert.strictEqual(typeSeen[type], expTypes[type],
`Type '${type}': expecting: ${expTypes[type]} ` +
`found ${typeSeen[type]}`);
assert.ok(typeSeen[type] >= expTypes[type],
`Type '${type}': expecting: ${expTypes[type]} ` +
`found: ${typeSeen[type]}`);
}
};