Skip to content

Commit

Permalink
test: updated non-atomic test to clean up beforehand to work when run…
Browse files Browse the repository at this point in the history
…ning across different test iterations within the same process
  • Loading branch information
bizob2828 committed May 24, 2023
1 parent 028120e commit 5b65511
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 193 deletions.
10 changes: 10 additions & 0 deletions lib/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ class Report {
return mergeProcessCovs(v8ProcessCovs)
}

/**
* Returns the merged V8 process coverage.
*
* It asynchronously and incrementally reads and merges individual process coverages
* generated by Node. This can be used via the `--merge-async` CLI arg. It's intended
* to be used across a large multi-process test run.
*
* @return {ProcessCov} Merged V8 process coverage.
* @private
*/
async _getMergedProcessCovAsync () {
const { mergeProcessCovs } = require('@bcoe/v8-coverage')
const fileIndex = new Set() // Set<string>
Expand Down
2 changes: 1 addition & 1 deletion test/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ beforeEach(function () {
const { output } = spawnSync(nodePath, [
c8Path,
'--exclude="test/*.js"',
'--clean=false',
'--clean=true',
`--merge-async=${mergeAsync}`,
nodePath,
require.resolve('./fixtures/normal')
Expand Down
33 changes: 11 additions & 22 deletions test/integration.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ hey
---------------------------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------------------------------|---------|----------|---------|---------|-------------------
All files | 1.82 | 12.24 | 6.38 | 1.82 |
All files | 1.81 | 12.24 | 6.38 | 1.81 |
c8 | 0 | 0 | 0 | 0 |
index.js | 0 | 0 | 0 | 0 | 1
c8/bin | 0 | 0 | 0 | 0 |
Expand All @@ -168,7 +168,7 @@ All files | 1.82 | 12.24 | 6.38 | 1.82
c8/lib | 0 | 0 | 0 | 0 |
is-cjs-esm-bridge.js | 0 | 0 | 0 | 0 | 1-10
parse-args.js | 0 | 0 | 0 | 0 | 1-224
report.js | 0 | 0 | 0 | 0 | 1-407
report.js | 0 | 0 | 0 | 0 | 1-417
source-map-from-file.js | 0 | 0 | 0 | 0 | 1-100
c8/lib/commands | 0 | 0 | 0 | 0 |
check-coverage.js | 0 | 0 | 0 | 0 | 1-70
Expand Down Expand Up @@ -522,7 +522,7 @@ hey
---------------------------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------------------------------|---------|----------|---------|---------|-------------------
All files | 1.82 | 12.24 | 6.38 | 1.82 |
All files | 1.81 | 12.24 | 6.38 | 1.81 |
c8 | 0 | 0 | 0 | 0 |
index.js | 0 | 0 | 0 | 0 | 1
c8/bin | 0 | 0 | 0 | 0 |
Expand All @@ -534,7 +534,7 @@ All files | 1.82 | 12.24 | 6.38 | 1.82
c8/lib | 0 | 0 | 0 | 0 |
is-cjs-esm-bridge.js | 0 | 0 | 0 | 0 | 1-10
parse-args.js | 0 | 0 | 0 | 0 | 1-224
report.js | 0 | 0 | 0 | 0 | 1-407
report.js | 0 | 0 | 0 | 0 | 1-417
source-map-from-file.js | 0 | 0 | 0 | 0 | 1-100
c8/lib/commands | 0 | 0 | 0 | 0 |
check-coverage.js | 0 | 0 | 0 | 0 | 1-70
Expand Down Expand Up @@ -994,24 +994,13 @@ what
hey
what
hey
--------------------------|---------|----------|---------|---------|--------------------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------------------|---------|----------|---------|---------|--------------------------------
All files | 71.51 | 54.66 | 61.11 | 71.51 |
bin | 78.84 | 42.85 | 100 | 78.84 |
c8.js | 78.84 | 42.85 | 100 | 78.84 | 22,27-29,32-33,41-43,50-51
lib | 74.89 | 52.72 | 70.83 | 74.89 |
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
parse-args.js | 97.32 | 63.63 | 100 | 97.32 | 165-166,187-188,201-202
report.js | 69.53 | 54.28 | 78.57 | 69.53 | ...323,357-359,380-385,396-397
source-map-from-file.js | 45 | 100 | 0 | 45 | 39-50,52-67,69-77,81-98
lib/commands | 41.96 | 50 | 16.66 | 41.96 |
check-coverage.js | 18.57 | 100 | 0 | 18.57 | 9-11,14-36,39-53,55-70
report.js | 80.95 | 40 | 50 | 80.95 | 9-10,15-20
test/fixtures | 83.33 | 85.71 | 60 | 83.33 |
async.js | 100 | 100 | 100 | 100 |
normal.js | 75 | 66.66 | 33.33 | 75 | 14-16,18-20
--------------------------|---------|----------|---------|---------|--------------------------------
-----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------|---------|----------|---------|---------|-------------------
All files | 83.33 | 85.71 | 60 | 83.33 |
async.js | 100 | 100 | 100 | 100 |
normal.js | 75 | 66.66 | 33.33 | 75 | 14-16,18-20
-----------|---------|----------|---------|---------|-------------------
,"
`;
Expand Down
Loading

0 comments on commit 5b65511

Please sign in to comment.