The test runner's code coverage leaves old coverage data in the
temp directory. This commit updates the cleanup logic to:
- Stop code collection. Otherwise V8 would write collection data
again when the process exits.
- Remove the temp directory containing the coverage data.
- Attempt to clean up the coverage data even if parsing the
data resulted in an error.
With this change, I no longer see any coverage data left behind
in the system temp directory.
Refs: https://github.com/nodejs/build/issues/3864
Refs: https://github.com/nodejs/build/issues/3887
PR-URL: https://github.com/nodejs/node/pull/54856
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit updates the source mapping logic in the test runner
to account for newline characters that are not included in line
length calculations.
Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
Fixes: https://github.com/nodejs/node/issues/54240
PR-URL: https://github.com/nodejs/node/pull/54444
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This commit consolidates all option parsing for the test runner
in the parseCommandLine() internal helper function. The exception
is a couple of temporary flags used for feature gating which
will eventually become no-ops. This consolidation is prep work
for supporting running test files in the test runner process.
PR-URL: https://github.com/nodejs/node/pull/53849
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
PR-URL: https://github.com/nodejs/node/pull/53553
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This is a breaking change for the format of test:coverage events. But
the test coverage is still experimental, so I don't believe it requires
a semver-major bump.
Fixes https://github.com/nodejs/node/issues/49303
PR-URL: https://github.com/nodejs/node/pull/49320
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
The code coverage reporting logic already filters out URLs that
don't start with 'file:', so there is no need to also filter
out URLs that start with 'node:'.
PR-URL: https://github.com/nodejs/node/pull/48070
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
If V8 generates code coverage for a file that is later
inaccessible to the test runner, then omit that file from the
coverage report.
PR-URL: https://github.com/nodejs/node/pull/47850
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Beth Griggs <bethanyngriggs@gmail.com>
This commit adds support for combining code coverage reports
in the test runner. This allows coverage to be collected for
child processes, and by extension, the test runner CLI.
PR-URL: https://github.com/nodejs/node/pull/47686
Fixes: https://github.com/nodejs/node/issues/47669
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
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 adds code coverage functionality to the node:test
module. When node:test is used in conjunction with the new
--test-coverage CLI flag, a coverage report is created when
the test runner finishes. The coverage summary is forwarded to
any test runner reporters so that the display can be customized
as desired. This new functionality is compatible with the
existing NODE_V8_COVERAGE environment variable as well.
There are still several limitations, which will be addressed in
subsequent pull requests:
- Coverage is only reported for a single process. It is possible
to merge coverage reports together. Once this is done, the
--test flag will be supported as well.
- Source maps are not currently supported.
- Excluding specific files or directories from the coverage
report is not currently supported. Node core modules and
node_modules/ are excluded though.
PR-URL: https://github.com/nodejs/node/pull/46017
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>