in src/common/tools/checklist.ts [61:111]
function checkForUnmatchedSubtreesAndDoneness(
tree: TestTree,
matchQueries: QueriesInSuite
): number {
let subtreeCount = 0;
const unmatchedSubtrees: TestQuery[] = [];
const overbroadMatches: [TestQuery, TestQuery][] = [];
const donenessMismatches: QueryInSuite[] = [];
const alwaysExpandThroughLevel = 1; // expand to, at minimum, every file.
for (const subtree of tree.iterateCollapsedNodes({
includeIntermediateNodes: true,
includeEmptySubtrees: true,
alwaysExpandThroughLevel,
})) {
subtreeCount++;
const subtreeDone = !subtree.subtreeCounts?.nodesWithTODO;
let subtreeMatched = false;
for (const q of matchQueries) {
const comparison = compareQueries(q.query, subtree.query);
if (comparison !== Ordering.Unordered) subtreeMatched = true;
if (comparison === Ordering.StrictSubset) continue;
if (comparison === Ordering.StrictSuperset) overbroadMatches.push([q.query, subtree.query]);
if (comparison === Ordering.Equal && q.done !== subtreeDone) donenessMismatches.push(q);
}
if (!subtreeMatched) unmatchedSubtrees.push(subtree.query);
}
if (overbroadMatches.length) {
// (note, this doesn't show ALL multi-test queries - just ones that actually match any .spec.ts)
console.log(` FYI, the following checklist items were broader than one file:`);
for (const [q, collapsedSubtree] of overbroadMatches) {
console.log(` ${q} > ${collapsedSubtree}`);
}
}
if (unmatchedSubtrees.length) {
throw new StacklessError(`Found unmatched tests:\n ${unmatchedSubtrees.join('\n ')}`);
}
if (donenessMismatches.length) {
throw new StacklessError(
'Found done/todo mismatches:\n ' +
donenessMismatches
.map(q => `marked ${q.done ? 'DONE, but is TODO' : 'TODO, but is DONE'}: ${q.query}`)
.join('\n ')
);
}
return subtreeCount;
}