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 2023-04-23 03:17:49 -04:00 committed by GitHub
parent ecb023be8a
commit 53e3c0ebf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

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) {

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) {