MCPcopy Index your code
hub / github.com/nodejs/node / cleanup

Method cleanup

lib/internal/test_runner/coverage.js:358–390  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

356 }
357
358 cleanup() {
359 // Restore the original value of process.env.NODE_V8_COVERAGE. Then, copy
360 // all of the created coverage files to the original coverage directory.
361 internalBinding('profiler').endCoverage();
362
363 if (this.originalCoverageDirectory === undefined) {
364 delete process.env.NODE_V8_COVERAGE;
365 } else {
366 process.env.NODE_V8_COVERAGE = this.originalCoverageDirectory;
367 let dir;
368
369 try {
370 mkdirSync(this.originalCoverageDirectory, { __proto__: null, recursive: true });
371 dir = opendirSync(this.coverageDirectory);
372
373 for (let entry; (entry = dir.readSync()) !== null;) {
374 const src = join(this.coverageDirectory, entry.name);
375 const dst = join(this.originalCoverageDirectory, entry.name);
376 copyFileSync(src, dst);
377 }
378 } finally {
379 if (dir) {
380 dir.closeSync();
381 }
382 }
383 }
384
385 try {
386 rmSync(this.coverageDirectory, { __proto__: null, recursive: true });
387 } catch {
388 // Ignore cleanup errors.
389 }
390 }
391
392 getCoverageFromDirectory() {
393 const result = new SafeMap();

Callers 5

collectCoverageFunction · 0.45
onSessionFunction · 0.45
testharness.jsFile · 0.45
tearDownMethod · 0.45
testharness.jsFile · 0.45

Calls 7

opendirSyncFunction · 0.85
mkdirSyncFunction · 0.50
joinFunction · 0.50
copyFileSyncFunction · 0.50
rmSyncFunction · 0.50
readSyncMethod · 0.45
closeSyncMethod · 0.45

Tested by 1

tearDownMethod · 0.36