MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / updateTestCountLabels

Method updateTestCountLabels

src/shared/test/test_model.ts:398–428  ·  view source on GitHub ↗

Recomputes the test counts and labels for a node and its parent/children (based on `direction`).

(node: RunnableTreeNode, forceUpdate: boolean, direction: "UP" | "DOWN")

Source from the content-addressed store, hash-verified

396
397 /** Recomputes the test counts and labels for a node and its parent/children (based on `direction`). */
398 private updateTestCountLabels(node: RunnableTreeNode, forceUpdate: boolean, direction: "UP" | "DOWN"): void {
399 if (direction === "DOWN") {
400 for (const child of node.children) {
401 this.updateTestCountLabels(child, forceUpdate, direction);
402 }
403 }
404
405 // Update the cached counts on this node.
406 if (node instanceof TestNode && !node.children.length) {
407 node.testCount = 1;
408 node.testCountPass = node.status === TestStatus.Passed ? 1 : 0;
409 node.testCountSkip = node.status === TestStatus.Skipped ? 1 : 0;
410 } else {
411 node.testCount = node.children.map((c) => c.testCount).reduce((total, value) => total + value, 0);
412 node.testCountPass = node.children.map((c) => c.testCountPass).reduce((total, value) => total + value, 0);
413 node.testCountSkip = node.children.map((c) => c.testCountSkip).reduce((total, value) => total + value, 0);
414 }
415 const totalTests = this.config.showSkippedTests ? node.testCount : node.testCount - node.testCountSkip;
416
417 // Update the label.
418 const previousDescription = node.description;
419 node.description = node.children.length && totalTests !== 0 ? `${node.testCountPass}/${totalTests} passed` : "";
420 if (forceUpdate || node.description !== previousDescription)
421 this.updateNode({ node });
422
423 if (direction === "UP") {
424 const parent = node.parent;
425 if (parent instanceof RunnableTreeNode)
426 this.updateTestCountLabels(parent, false, direction);
427 }
428 }
429
430 public suiteDiscoveredConditional(dartCodeDebugSessionID: string | undefined, suitePath: string): SuiteData {
431 return this.suites.getForPath(suitePath) ?? this.suiteDiscovered(dartCodeDebugSessionID, suitePath);

Callers 2

testDoneMethod · 0.95

Calls 1

updateNodeMethod · 0.95

Tested by

no test coverage detected