test_runner: support coverage of unnamed functions

This commit updates the code coverage logic to skip the first
function in a file (which does not correspond to an actual
function) instead of skipping all functions without a name.

PR-URL: https://github.com/nodejs/node/pull/47652
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
cjihrig authored and Michaël Zasso committed 2023-05-02 09:34:03 +02:00
1 parent 1f120a396f
commit b6fb7914ca
2 files changed
+3 -3

No files matched your search

+2 -2
View File
@@ -155,7 +155,7 @@ class TestCoverage {
});
for (let j = 0; j < functions.length; ++j) {
const { functionName, isBlockCoverage, ranges } = functions[j];
const { isBlockCoverage, ranges } = functions[j];
for (let k = 0; k < ranges.length; ++k) {
const range = ranges[k];
@@ -172,7 +172,7 @@ class TestCoverage {
}
}
if (functionName.length > 0 && ranges.length > 0) {
if (j > 0 && ranges.length > 0) {
const range = ranges[0];
if (range.count !== 0 || range.ignoredLines === range.lines.length) {
+1 -1
View File
@@ -29,7 +29,7 @@ if (false) {
require('./invalid-tap.js');
}
test('a test', function testHandler() {
test('a test', () => {
const uncalled = () => {};
function fnWithControlFlow(val) {