Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds --all functionality #158

Merged
merged 7 commits into from Nov 28, 2019
Merged

feat: adds --all functionality #158

merged 7 commits into from Nov 28, 2019

Conversation

j03m
Copy link
Collaborator

@j03m j03m commented Oct 29, 2019

Implements an --all flag for a src directory to consider
for coverage. If supplied, c8 will glob the directory respecting the
--include and --exclude parameters for src files. All source files
will be included in the final report. If a file is not found in the
v8 coverage output, it will be initialized with an empty record and
reported as 0 lines/branches/functions covered.

Checklist
  • npm test, tests passing
  • npm run test:snap (to update the snapshot)
  • tests and/or benchmarks are included
  • documentation is changed or added

@j03m
Copy link
Collaborator Author

j03m commented Oct 29, 2019

Status: This seems to be satisfying my usecase for all. I'm issuing this as a draft however, because there is still an open issue around the way html reports are generated. If a file is unloaded/empty the HTML report generator seems to fail when trying to generate src level page for the file with the exception below. I'm working out why now.

Cannot read property 'locations' of undefined
TypeError: Cannot read property 'locations' of undefined
    at D:\dev\c8\node_modules\istanbul-reports\lib\html\annotator.js:132:50
    at Array.forEach ()
    at annotateBranches (D:\dev\c8\node_modules\istanbul-reports\lib\html\annotator.js:128:30)
    at Object.annotateSourceCode (D:\dev\c8\node_modules\istanbul-reports\lib\html\annotator.js:238:9)
    at HtmlReport.onDetail (D:\dev\c8\node_modules\istanbul-reports\lib\html\index.js:265:27)
    at Visitor. [as onDetail] (D:\dev\c8\node_modules\istanbul-lib-report\lib\tree.js:34:30)
    at ReportNode.Node.visit (D:\dev\c8\node_modules\istanbul-lib-report\lib\tree.js:114:17)
    at D:\dev\c8\node_modules\istanbul-lib-report\lib\tree.js:118:15
    at Array.forEach ()
    at ReportNode.Node.visit (D:\dev\c8\node_modules\istanbul-lib-report\lib\tree.js:117:24)

@j03m j03m mentioned this pull request Oct 29, 2019
@j03m
Copy link
Collaborator Author

j03m commented Oct 29, 2019

Sample txt report (from snapshot):

--------------|----------|----------|----------|----------|-------------------|
File          |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
--------------|----------|----------|----------|----------|-------------------|
All files     |    64.29 |    66.67 |       50 |    64.29 |                   |
 vanilla      |    78.26 |       75 |      100 |    78.26 |                   |
  loaded.js   |    73.68 |    71.43 |      100 |    73.68 |      4,5,16,17,18 |
  main.js     |      100 |      100 |      100 |      100 |                   |
 vanilla/dir  |        0 |        0 |        0 |        0 |                   |
  unloaded.js |        0 |        0 |        0 |        0 |         1,2,3,4,5 |
--------------|----------|----------|----------|----------|-------------------|

@coveralls
Copy link

coveralls commented Oct 29, 2019

Pull Request Test Coverage Report for Build 499

  • 80 of 81 (98.77%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 94.083%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/source-map-from-file.js 24 25 96.0%
Totals Coverage Status
Change from base Build 491: 0.3%
Covered Lines: 556
Relevant Lines: 579

💛 - Coveralls

@j03m
Copy link
Collaborator Author

j03m commented Oct 30, 2019

Thought: Should --all also be allowed to be empty and then default to process.cwd to be more like nyc? Seems so. Will add.

Copy link
Owner

@bcoe bcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking like really solid, thanks for putting this work in 😄, and sorry for the slow review.

One thought I have, we might be able to avoid zeroing out the Istanbul format report, and be able to use existing functionality, if we tried to populate a dummy V8 format coverage report, rather than Istanbul see.

lib/parse-args.js Outdated Show resolved Hide resolved
lib/parse-args.js Outdated Show resolved Hide resolved
lib/report.js Outdated Show resolved Hide resolved
lib/report.js Outdated Show resolved Hide resolved
lib/report.js Outdated Show resolved Hide resolved
lib/report.js Outdated Show resolved Hide resolved
test/fixtures/all/vanilla/loaded.js Show resolved Hide resolved
@bcoe
Copy link
Owner

bcoe commented Nov 6, 2019

@j03m I did a little playing, I think you could potentially get away with something like this, and piggyback off the existing merge logic:

  /**
   * Returns the merged V8 process coverage.
   *
   * The result is computed from the individual process coverages generated
   * by Node. It represents the sum of their counts.
   *
   * @return {ProcessCov} Merged V8 process coverage.
   * @private
   */
   _getMergedProcessCov () {
    const { mergeProcessCovs } = require('@bcoe/v8-coverage')
    const v8ProcessCovs = []
    for (const v8ProcessCov of this._loadReports()) {
      if (this._isCoverageObject(v8ProcessCov)) {
        if (v8ProcessCov['source-map-cache']) {
          Object.assign(this.sourceMapCache, v8ProcessCov['source-map-cache'])
        }
        v8ProcessCovs.push(this._normalizeProcessCov(v8ProcessCov))
      }
    }
    
    if (this.all) {
      const emptyReports = []
      v8ProcessCovs.unshift({result: emptyReports})
      this.exclude.globSync(process.cwd()).forEach((f) => {
        const ext = extname(f)
        if (ext === '.js' || ext === '.ts' || ext === '.mjs') {
          const stat = statSync(f)
          emptyReports.push({
            scriptId: v4(),
            url: resolve(f),
            functions: [{
              functionName: '',
              ranges: [{
                startOffset: 0,
                endOffset: stat.size,
                count: 0
              }],
              isBlockCoverage: true
            }]
          })
        }
      })
    }
            
    return mergeProcessCovs(v8ProcessCovs)
  }

Perhaps we could then pull the brunt of this into a helper called, createCoverageObject, which takes size, and path.

Curious to know whether this approach works with the tests you've pulled together.

@j03m
Copy link
Collaborator Author

j03m commented Nov 6, 2019

Okay cool. Thank you for reviewing. I will take a look at this approach and circle back.

@j03m
Copy link
Collaborator Author

j03m commented Nov 8, 2019

Functions seem to report as 100% using the above method, ala:

--------------|----------|----------|----------|----------|-------------------|
File          |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
--------------|----------|----------|----------|----------|-------------------|
All files     |    64.29 |    66.67 |      100 |    64.29 |                   |
 vanilla      |    78.26 |       75 |      100 |    78.26 |                   |
  loaded.js   |    73.68 |    71.43 |      100 |    73.68 |      4,5,16,17,18 |
  main.js     |      100 |      100 |      100 |      100 |                   |
 vanilla/dir  |        0 |        0 |      100 |        0 |                   |
  unloaded.js |        0 |        0 |      100 |        0 |         1,2,3,4,5 |
--------------|----------|----------|----------|----------|-------------------|

I still think its a better approach though, I'm investigating how to handle this.

@bcoe
Copy link
Owner

bcoe commented Nov 8, 2019

thanks @j03m for digging into this 👍 if we get this feature right, it's a huge improvement 😄

@j03m
Copy link
Collaborator Author

j03m commented Nov 9, 2019

Just picked this up again. Another issue, seems to be that when dealing with typescript sourcemaps the converter seems to initialize statements to covered as well. This is the result of my unit test using ts-node:

**Edit: I'm not sure if its the converter. May just be how the reporter interprets it.

--------------------|----------|----------|----------|----------|-------------------|
File                |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
--------------------|----------|----------|----------|----------|-------------------|
All files           |    82.14 |    55.56 |      100 |    82.14 |                   |
 ts-source-maps     |    78.26 |     62.5 |      100 |    78.26 |                   |
  loaded.ts         |    73.68 |    71.43 |      100 |    73.68 |      4,5,16,17,18 |
  main.ts           |      100 |        0 |      100 |      100 |                 4 |
 ts-source-maps/dir |      100 |        0 |      100 |      100 |                   |
  unloaded.ts       |      100 |        0 |      100 |      100 |                 5 |
--------------------|----------|----------|----------|----------|-------------------|

Looking at a fix here as well. May require a change to the converter? Not sure yet.

@j03m
Copy link
Collaborator Author

j03m commented Nov 9, 2019

Okay for the functions being reported as 100%. This was pretty easy to track down. The issue comes down to this logic in istanbul-coverage: https://github.com/istanbuljs/istanbuljs/blob/master/packages/istanbul-lib-coverage/lib/percent.js#L9 where if I have 0 total of 0 covered, it sets the percentage to 100%.

In our converter, when it evaluates our "fake" function here: https://github.com/istanbuljs/v8-to-istanbul/blob/master/lib/v8-to-istanbul.js#L99 we don't create a function because the name is "" which evals to false, we skip that if block.

I don't have enough context to know if either of these should be changed. However, changing our fake coverage blocks to have a default function name of "c8-fake-function" does the trick. The converter believes we have 1 function which is uncovered so the percentage becomes 0.

Looking into the typescript issue next.

@j03m
Copy link
Collaborator Author

j03m commented Nov 10, 2019

I think the issue with typescript is that the fake entries don't have a sourcemap cache entry (because they were never loaded). That seems solvable by locating the sourcemap for the targeted file and also faking the sourcemap cache. I'm not 100% sure yet.

However, I wanted to reconsider, is this actually a better approach? It seems like we're required to do a lot more fakery vs simply creating the empty istanbul report entry. The fake bits are at a much higher level and have to survive being manipulated by many more paths of code. It seems like it may be more brittle now that I'm exploring what is involved.

Not sure, I will definitely defer to your expertise here and am happy to continue down this path, but I know originally I think you were concerned about how the empty istanbul records would merge. I'm not sure I fully understood that concern. Could you elaborate there?

In the interim I'll see if I can figure out this sourcemap issue.

@bcoe
Copy link
Owner

bcoe commented Nov 10, 2019

@j03m if you're finding it significantly more work to use the V8 output, vs., the Istanbul report, I'm open to your original approach, this would bring us back to the original review, mainly:

  1. let's try to isolate some of the --all functionality into a module, perhaps create-fake-report.js, in lib/?
  2. let's make sure we test a bunch of edge-cases tsnode, vs., pre-transpiled code (we should make sure we're appropriately picking up source-maps, and running exclude at the appropriate time, e.g., we don't want to exclude loading a .js file that remaps to a .ts file).
  3. let's use the same approach as nyc, where --all is just a boolean flag, and uses the current process.cwd().

I trust your opinion on which approach for creating an empty report is less ridiculous 😄

@j03m
Copy link
Collaborator Author

j03m commented Nov 12, 2019

I don't know if its more work specifically. I looked at this a bit more last night and I think my largest concern at this point might be performance.

I think (I'm not 100% sure as I haven't gotten it working yet) that the current approach will require the a good deal more IO so that soucemaps will work correctly. Currently we statSync to get the number of lines. But in addition I think we need to:

  • Read the body of compiled file and parse out the source map url
  • Read the body of the sourcemap to be included in the source-map-cache

I think that could add up for large projects? That said, I've written some of this and it looks like it will work and arguably we can write an optimization to only do this IO when we know we have an unloaded file which will help.

Anyhow, I feel like I should at least get it working as a POC so we can get a full look. We can always regress back to the previous approach.

@j03m
Copy link
Collaborator Author

j03m commented Nov 17, 2019

I think if we can make the change I referenced here: istanbuljs/v8-to-istanbul#75 that supply the v8 coverage will work fine.

@bcoe
Copy link
Owner

bcoe commented Nov 18, 2019

@j03m 👋 I put a bunch of hours in on the weekend working on --all and tested against some of Google's libraries 👍 I think I have a hybrid approach using some of my suggestions, and a bunch of your work, just haven't gotten it over the finish line yet.

@j03m j03m force-pushed the implement--all branch 2 times, most recently from 2062766 to ff17bed Compare November 19, 2019 13:12
@j03m
Copy link
Collaborator Author

j03m commented Nov 19, 2019

Okay cool - pulling in your PR branch for v8-to-istanbul solved the last issues I was grappling with. I pushed the current state of my work which seems to be functionally equivalent to the last PR in terms of results, but using the empty v8 blocks.

I didn't spend more time polishing it, but I figured I would share the state in case you want to compare notes and if this is of any use to your PR.

I'm going to pause here and work on this POC in our environment until you are done mostly to see if anything else might be missing from our use case. But, if there is anything I can do help pls let me know!

Implements an `--all` flag for a src directory to consider
for coverage. If supplied, c8 will glob the directory respecting the
`--include` and `--exclude` parameters for src files. All source files
will be included in the final report. If a file is not found in the
v8 coverage output, it will be initialized with an empty v8 record and
reported as 0 lines/branches/functions covered.

Note: This uses the empty v8 approach instead of the empty report approach

Fix html report

--all should be boolean

Update snapshot

fix async function

WIP - changing --all a bit to create a fake v8 coverage entry and additional args changes

WIP - read source maps for faked entries

WIP

WIP

Moved approach to empty v8 blocks
@bcoe
Copy link
Owner

bcoe commented Nov 19, 2019

@j03m thank you, I appreciate the hard work.

Copy link
Owner

@bcoe bcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incredible work thank you @j03m, my last couple nits:

  1. we should probably pull that source-map helper into a file, and make sure it has a license header if it's borrowed code.
  2. we should update the README.md with mention of --all.

🎉 thanks for working with me to reach an awesome implementation.

lib/report.js Outdated
@@ -127,6 +129,29 @@ class Report {
return sources
}

/**
* //TODO: use https://www.npmjs.com/package/convert-source-map
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm perfectly comfortable with us floating our own version of this method, since we're currently only using one bit of the library (I'd rather not add an additional library).

Did we get this code directly from convert-source-map, because I think we should pull this into a lib/ folder, carrying over the license header from that project.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is okay. The code isn't from covert-source-map, but after I wrote it I noticed we had convert-source-map in the dependency tree of v8-to-istanbul and were using it. So I thought we would be better served by using a function from there, but I don't feel strongly about it. I'll remove the TODO.

package.json Outdated Show resolved Hide resolved
@j03m
Copy link
Collaborator Author

j03m commented Nov 25, 2019

Oh woa, apologies for the long absence, I was under the impression you were going to use a different PR. I came to check if you had pushed that. I can make the changes asked for here?

@j03m
Copy link
Collaborator Author

j03m commented Nov 25, 2019

Looks like tests lint are failing though :/ looking.

**edit: Its the lint, will fix.

Copy link
Collaborator Author

@j03m j03m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few changes in bound.

lib/report.js Outdated
@@ -127,6 +129,29 @@ class Report {
return sources
}

/**
* //TODO: use https://www.npmjs.com/package/convert-source-map
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is okay. The code isn't from covert-source-map, but after I wrote it I noticed we had convert-source-map in the dependency tree of v8-to-istanbul and were using it. So I thought we would be better served by using a function from there, but I don't feel strongly about it. I'll remove the TODO.

lib/report.js Outdated
@@ -139,14 +142,50 @@ class Report {
_getMergedProcessCov () {
const { mergeProcessCovs } = require('@bcoe/v8-coverage')
const v8ProcessCovs = []
const fileIndex = new Map() // Map<string, bool>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scrutinizing this a bit now - this should be a Set

README.md Outdated
## Checking for "full" source coverage using `--all`

By default v8 will only give us coverage for files that were loaded by the engine. If there are source files in your
project that are flexed in production but not in your tests your coverage numbers will not reflect this. For example,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your tests,

Copy link
Collaborator Author

@j03m j03m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of minor things on my end.

README.md Outdated

By default v8 will only give us coverage for files that were loaded by the engine. If there are source files in your
project that are flexed in production but not in your tests your coverage numbers will not reflect this. For example,
if you your project's `main.js` loads `a.js` and `b.js` but your unit tests only load `a.js` your total coverage
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you

README.md Outdated
if you your project's `main.js` loads `a.js` and `b.js` but your unit tests only load `a.js` your total coverage
could show as `100%` for `a.js` when in fact both `main.js` and `b.js` are uncovered.

By supplying `--all` to c8 all files in `cwd` obeying the `--include` and `--exclude` flags will be loaded into the
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c8,

,obeying....flags,

@@ -56,8 +60,8 @@ class Report {
// use-case.
if (this._allCoverageFiles) return this._allCoverageFiles

const map = libCoverage.createCoverageMap()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lost the {} here. Not sure if that is an issue.

@j03m
Copy link
Collaborator Author

j03m commented Nov 27, 2019

Hmmm, hold on merge. Something is amiss here. Coveralls is reporting this line as uncovered: https://coveralls.io/builds/27279321/source?filename=lib/report.js#L169. That shouldn't be the case.

@j03m
Copy link
Collaborator Author

j03m commented Nov 28, 2019

Okay solved. If you look at the commit for 65a5453 I was including *.ts for the compiled tests. This works for ts-node but not for something like tsc where you need to run against your dist and map back to src. I fixed that test and fixed the snapshot.

@j03m
Copy link
Collaborator Author

j03m commented Nov 28, 2019

This should be g2g now!

@bcoe bcoe changed the title Implement --all functionality feat: adds --all functionality Nov 28, 2019
@bcoe bcoe merged commit 2eb631e into bcoe:master Nov 28, 2019
@bcoe
Copy link
Owner

bcoe commented Nov 28, 2019

@j03m awesome work 👌

@j03m
Copy link
Collaborator Author

j03m commented Nov 29, 2019

Thanks for all the advice/help!

github-actions bot pushed a commit to prantlf/c8 that referenced this pull request Apr 2, 2023
# 1.0.0 (2023-04-02)

### Bug Fixes

* `--all` now respects `--extension` flag. ([bcoe#357](https://github.com/prantlf/c8/issues/357)) ([a5deb27](a5deb27))
* add missing space in text ([bcoe#245](https://github.com/prantlf/c8/issues/245)) ([efe6d04](efe6d04))
* address bugs with source remapping on Windows ([bcoe#301](https://github.com/prantlf/c8/issues/301)) ([c817902](c817902))
* address file:// issue with CJS ([bcoe#39](https://github.com/prantlf/c8/issues/39)) ([d4f9cab](d4f9cab))
* all flag not propagated to check-coverage command ([bcoe#188](https://github.com/prantlf/c8/issues/188)) ([86eaf72](86eaf72))
* **config:** support configuration inheritance ([bcoe#343](https://github.com/prantlf/c8/issues/343)) ([e81ed5d](e81ed5d))
* **deps:** merging failed when the same script occurred multiple times in the same report ([bcoe#147](https://github.com/prantlf/c8/issues/147)) ([1ebcaf9](1ebcaf9))
* **deps:** update dependency find-up to v4 ([bcoe#119](https://github.com/prantlf/c8/issues/119)) ([c568d96](c568d96))
* **deps:** update dependency find-up to v5 ([bcoe#242](https://github.com/prantlf/c8/issues/242)) ([8a0cfd7](8a0cfd7))
* **deps:** update dependency furi to v2 ([bcoe#193](https://github.com/prantlf/c8/issues/193)) ([6b9af6e](6b9af6e))
* **deps:** update dependency rimraf to v3 ([bcoe#132](https://github.com/prantlf/c8/issues/132)) ([7601748](7601748))
* **deps:** update dependency v8-to-istanbul to v4 ([bcoe#167](https://github.com/prantlf/c8/issues/167)) ([97b9769](97b9769))
* **deps:** update dependency yargs to v14 ([bcoe#134](https://github.com/prantlf/c8/issues/134)) ([e49737f](e49737f))
* **deps:** update dependency yargs to v15 ([bcoe#164](https://github.com/prantlf/c8/issues/164)) ([e41a483](e41a483))
* **deps:** update dependency yargs to v16 ([bcoe#251](https://github.com/prantlf/c8/issues/251)) ([0436816](0436816))
* **deps:** update dependency yargs-parser to v13 ([bcoe#124](https://github.com/prantlf/c8/issues/124)) ([1eb3394](1eb3394))
* **deps:** update dependency yargs-parser to v14 ([bcoe#144](https://github.com/prantlf/c8/issues/144)) ([9b3d089](9b3d089))
* **deps:** update dependency yargs-parser to v15 ([bcoe#153](https://github.com/prantlf/c8/issues/153)) ([80153de](80153de))
* **deps:** update dependency yargs-parser to v16 ([bcoe#157](https://github.com/prantlf/c8/issues/157)) ([15746e5](15746e5))
* **deps:** update dependency yargs-parser to v17 ([bcoe#201](https://github.com/prantlf/c8/issues/201)) ([d730c63](d730c63))
* **deps:** update dependency yargs-parser to v18 ([bcoe#202](https://github.com/prantlf/c8/issues/202)) ([983de44](983de44))
* **deps:** update dependency yargs-parser to v19 ([bcoe#241](https://github.com/prantlf/c8/issues/241)) ([baa01df](baa01df))
* **deps:** update dependency yargs-parser to v20 ([bcoe#252](https://github.com/prantlf/c8/issues/252)) ([ae845f0](ae845f0))
* **deps:** update deps to address warning in cross-spawn ([bcoe#141](https://github.com/prantlf/c8/issues/141)) ([4b66221](4b66221))
* **deps:** update deps to latest ([bcoe#384](https://github.com/prantlf/c8/issues/384)) ([78eac8c](78eac8c)), closes [bcoe#375](https://github.com/prantlf/c8/issues/375)
* **deps:** v8-to-istanbul with fix for Windows paths ([bcoe#311](https://github.com/prantlf/c8/issues/311)) ([ef1b875](ef1b875))
* **deps:** v8-to-istanbul with patch for crasher ([bcoe#200](https://github.com/prantlf/c8/issues/200)) ([d4b7d80](d4b7d80))
* **deps:** v8-to-istnbul with fixes for Node 10/18 ([bcoe#392](https://github.com/prantlf/c8/issues/392)) ([d5f642a](d5f642a))
* do not override NODE_V8_COVERAGE if set ([bcoe#70](https://github.com/prantlf/c8/issues/70)) ([8bb67b0](8bb67b0))
* don't load JSON that does not look like coverage ([bcoe#146](https://github.com/prantlf/c8/issues/146)) ([a6481f1](a6481f1))
* escaping issue with cobertura reporter ([bcoe#203](https://github.com/prantlf/c8/issues/203)) ([e93747b](e93747b))
* exclude coverage of the CJS-ESM bridge from results ([bcoe#83](https://github.com/prantlf/c8/issues/83)) ([da2c945](da2c945))
* exit with code 1 when report output fails ([bcoe#92](https://github.com/prantlf/c8/issues/92)) ([a27b694](a27b694))
* file URL to system path conversion ([bcoe#46](https://github.com/prantlf/c8/issues/46)) ([e7f8cf2](e7f8cf2))
* fix package.json `test:snap` script to use cross-env ([bcoe#366](https://github.com/prantlf/c8/issues/366)) ([5d2981c](5d2981c))
* Fix usage of excludeAfterRemap not to set the coverage always to 100 ([9113449](9113449)), closes [bcoe#462](https://github.com/prantlf/c8/issues/462)
* float patch for branch/function coverage merge bug ([bcoe#56](https://github.com/prantlf/c8/issues/56)) ([1de0cca](1de0cca))
* HTML report now has correct source positions for Node >10.16.0 ([bcoe#125](https://github.com/prantlf/c8/issues/125)) ([c49fa7f](c49fa7f))
* ignore missing source maps in raw coverage output ([bcoe#233](https://github.com/prantlf/c8/issues/233)) ([eed98af](eed98af))
* make tests run on Windows ([bcoe#25](https://github.com/prantlf/c8/issues/25)) ([08e44d0](08e44d0))
* make tmp directory regardless of clean ([44d2185](44d2185))
* **perf:** cache `this.exclude.shouldInstrument` for improved performance ([bcoe#388](https://github.com/prantlf/c8/issues/388)) ([8b36f23](8b36f23))
* pin to functional version of spawn-wrap ([d1ced8c](d1ced8c))
* process coverage merging ([bcoe#37](https://github.com/prantlf/c8/issues/37)) ([67959b4](67959b4))
* regex flags in dependency were breaking Node 8 ([a9d9645](a9d9645))
* remove the unmaintained mkdirp dependency ([bcoe#91](https://github.com/prantlf/c8/issues/91)) ([a465b65](a465b65))
* snapshot ([7fd9e13](7fd9e13))
* support node@v15.x.x built-in modules ([bcoe#265](https://github.com/prantlf/c8/issues/265)) ([1b90a22](1b90a22))
* switch to mkdirp for Node 8 ([206b83f](206b83f))
* temporary files should be in tmp folder ([bcoe#106](https://github.com/prantlf/c8/issues/106)) ([64dd2e6](64dd2e6))
* tweak inspector event timing ([bcoe#6](https://github.com/prantlf/c8/issues/6)) ([01f654e](01f654e))
* **types:** add excludeAfterRemap and allowExternal  ([bcoe#297](https://github.com/prantlf/c8/issues/297)) ([e32a53f](e32a53f))
* Upgrade dependencies ([c288f5f](c288f5f))
* upgrade to @bcoe/v8-coverage with breaking regex dropped ([6c28e7f](6c28e7f))
* **v8-to-istanbul:** fixes shebang handling/ignore behavior ([bcoe#267](https://github.com/prantlf/c8/issues/267)) ([21cd41f](21cd41f))
* **v8-to-istanbul:** pull in fix for missing branches ([bcoe#258](https://github.com/prantlf/c8/issues/258)) ([eaffa78](eaffa78))
* **v8-to-istanbul:** revert off by one that broke TypeScript ([bcoe#262](https://github.com/prantlf/c8/issues/262)) ([81ab5b7](81ab5b7))
* we were not exiting with 1 if mkdir failed ([bcoe#89](https://github.com/prantlf/c8/issues/89)) ([fb02ed6](fb02ed6))

* feat!: use Node.js' source-map cache, to support tools like ts-node (bcoe#152) ([53bba15](53bba15)), closes [bcoe#152](https://github.com/prantlf/c8/issues/152)
* feat!: default temp directory to report directory (bcoe#102) ([8602f4a](8602f4a)), closes [bcoe#102](https://github.com/prantlf/c8/issues/102)

### Features

* `--100` ([bcoe#332](https://github.com/prantlf/c8/issues/332)) ([4205f2f](4205f2f))
* add --config option and documentation on options and configs ([bcoe#308](https://github.com/prantlf/c8/issues/308)) ([99436ef](99436ef))
* add --exclude-node-modules option ([bcoe#321](https://github.com/prantlf/c8/issues/321)) ([a4733c6](a4733c6))
* add --extension option ([bcoe#331](https://github.com/prantlf/c8/issues/331)) ([ff01cd8](ff01cd8))
* add --report-dir alias (for consistency with nyc) ([0dd1b04](0dd1b04))
* add --skip-full ([bcoe#287](https://github.com/prantlf/c8/issues/287)) ([8b01b63](8b01b63))
* add `skipFull` and `excludeNodeModules` to type definitions ([bcoe#417](https://github.com/prantlf/c8/issues/417)) ([b93b9c0](b93b9c0))
* add support for 1:1 source-maps ([bcoe#85](https://github.com/prantlf/c8/issues/85)) ([6ca4345](6ca4345))
* add support for ignoring lines, functions, and blocks ([bcoe#87](https://github.com/prantlf/c8/issues/87)) ([c66950e](c66950e))
* add thresholds for enforcing coverage percentage ([bcoe#59](https://github.com/prantlf/c8/issues/59)) ([70e8943](70e8943))
* adds --all functionality ([bcoe#158](https://github.com/prantlf/c8/issues/158)) ([2eb631e](2eb631e))
* adds support for 1:many source maps ([bcoe#238](https://github.com/prantlf/c8/issues/238)) ([dbf94a0](dbf94a0))
* adds TypeScript definitions ([d39801b](d39801b)), closes [bcoe#195](https://github.com/prantlf/c8/issues/195)
* **all:** handle base64 inline source maps ([bcoe#283](https://github.com/prantlf/c8/issues/283)) ([3f12dd4](3f12dd4))
* allow  --reports-dir to be configured ([bcoe#65](https://github.com/prantlf/c8/issues/65)) ([5ab31f5](5ab31f5))
* allow relative paths to be optionally included ([3806c79](3806c79))
* allow script wrapper length to be specified ([bcoe#51](https://github.com/prantlf/c8/issues/51)) ([a22c4e0](a22c4e0))
* first pass at functional prototype without subprocess support ([bcoe#5](https://github.com/prantlf/c8/issues/5)) ([9534f56](9534f56))
* foreground-child's done() method was not being called ([bcoe#82](https://github.com/prantlf/c8/issues/82)) ([fde596e](fde596e))
* implement Istanbul reporting ([bcoe#8](https://github.com/prantlf/c8/issues/8)) ([8e430bf](8e430bf))
* improve test assertions ([bcoe#28](https://github.com/prantlf/c8/issues/28)) ([522720e](522720e))
* introduce --exclude-after-remap flag ([bcoe#293](https://github.com/prantlf/c8/issues/293)) ([53c4234](53c4234)), closes [bcoe#224](https://github.com/prantlf/c8/issues/224)
* load .nycrc/.nycrc.json to simplify migration ([bcoe#100](https://github.com/prantlf/c8/issues/100)) ([bd7484f](bd7484f))
* playing around with initial implementation ([18f5471](18f5471))
* support --check-coverage for reports ([bcoe#60](https://github.com/prantlf/c8/issues/60)) ([b542930](b542930))
* support for instrumenting files outside of current working directory ([7e53a0e](7e53a0e))
* support ignore start/stop comment ([bcoe#273](https://github.com/prantlf/c8/issues/273)) ([90949fa](90949fa)), closes [bcoe#271](https://github.com/prantlf/c8/issues/271)
* support passing reporter options ([bcoe#423](https://github.com/prantlf/c8/issues/423)) ([bc347a9](bc347a9))
* switch to stderr and default port ([bcoe#7](https://github.com/prantlf/c8/issues/7)) ([bb117b7](bb117b7))
* switch to using Node's built in coverage ([bcoe#22](https://github.com/prantlf/c8/issues/22)) ([3c1b92b](3c1b92b))
* **types:** add typings for reporterOptions ([bcoe#446](https://github.com/prantlf/c8/issues/446)) ([3646e6e](3646e6e))
* use debuglog rather than console.warn ([bcoe#279](https://github.com/prantlf/c8/issues/279)) ([7c04a4d](7c04a4d))
* use process.stdout.columns for reporter maxCols ([bcoe#409](https://github.com/prantlf/c8/issues/409)) ([7731574](7731574))
* warn instead of throw on exception ([bcoe#29](https://github.com/prantlf/c8/issues/29)) ([a8620d4](a8620d4))

### BREAKING CHANGES

* Node.js' source-map and lineLength cache is now used to remap coverage output (this allows tools like ts-node to be supported, which transpile at runtime).
* temp directory now defaults to setting for report directory
* c8 will now load source-maps if possible and remap coverage accordingly
* switches to using NODE_V8_COVERAGE rather than inspector directly
* dropped subprocess support for the time being, while we march towards an initial implementation.
github-actions bot pushed a commit to prantlf/c8 that referenced this pull request Apr 2, 2023
# 1.0.0 (2023-04-02)

### Bug Fixes

* `--all` now respects `--extension` flag. ([bcoe#357](https://github.com/prantlf/c8/issues/357)) ([a5deb27](a5deb27))
* add missing space in text ([bcoe#245](https://github.com/prantlf/c8/issues/245)) ([efe6d04](efe6d04))
* address bugs with source remapping on Windows ([bcoe#301](https://github.com/prantlf/c8/issues/301)) ([c817902](c817902))
* address file:// issue with CJS ([bcoe#39](https://github.com/prantlf/c8/issues/39)) ([d4f9cab](d4f9cab))
* all flag not propagated to check-coverage command ([bcoe#188](https://github.com/prantlf/c8/issues/188)) ([86eaf72](86eaf72))
* **config:** support configuration inheritance ([bcoe#343](https://github.com/prantlf/c8/issues/343)) ([e81ed5d](e81ed5d))
* **deps:** merging failed when the same script occurred multiple times in the same report ([bcoe#147](https://github.com/prantlf/c8/issues/147)) ([1ebcaf9](1ebcaf9))
* **deps:** update dependency find-up to v4 ([bcoe#119](https://github.com/prantlf/c8/issues/119)) ([c568d96](c568d96))
* **deps:** update dependency find-up to v5 ([bcoe#242](https://github.com/prantlf/c8/issues/242)) ([8a0cfd7](8a0cfd7))
* **deps:** update dependency furi to v2 ([bcoe#193](https://github.com/prantlf/c8/issues/193)) ([6b9af6e](6b9af6e))
* **deps:** update dependency rimraf to v3 ([bcoe#132](https://github.com/prantlf/c8/issues/132)) ([7601748](7601748))
* **deps:** update dependency v8-to-istanbul to v4 ([bcoe#167](https://github.com/prantlf/c8/issues/167)) ([97b9769](97b9769))
* **deps:** update dependency yargs to v14 ([bcoe#134](https://github.com/prantlf/c8/issues/134)) ([e49737f](e49737f))
* **deps:** update dependency yargs to v15 ([bcoe#164](https://github.com/prantlf/c8/issues/164)) ([e41a483](e41a483))
* **deps:** update dependency yargs to v16 ([bcoe#251](https://github.com/prantlf/c8/issues/251)) ([0436816](0436816))
* **deps:** update dependency yargs-parser to v13 ([bcoe#124](https://github.com/prantlf/c8/issues/124)) ([1eb3394](1eb3394))
* **deps:** update dependency yargs-parser to v14 ([bcoe#144](https://github.com/prantlf/c8/issues/144)) ([9b3d089](9b3d089))
* **deps:** update dependency yargs-parser to v15 ([bcoe#153](https://github.com/prantlf/c8/issues/153)) ([80153de](80153de))
* **deps:** update dependency yargs-parser to v16 ([bcoe#157](https://github.com/prantlf/c8/issues/157)) ([15746e5](15746e5))
* **deps:** update dependency yargs-parser to v17 ([bcoe#201](https://github.com/prantlf/c8/issues/201)) ([d730c63](d730c63))
* **deps:** update dependency yargs-parser to v18 ([bcoe#202](https://github.com/prantlf/c8/issues/202)) ([983de44](983de44))
* **deps:** update dependency yargs-parser to v19 ([bcoe#241](https://github.com/prantlf/c8/issues/241)) ([baa01df](baa01df))
* **deps:** update dependency yargs-parser to v20 ([bcoe#252](https://github.com/prantlf/c8/issues/252)) ([ae845f0](ae845f0))
* **deps:** update deps to address warning in cross-spawn ([bcoe#141](https://github.com/prantlf/c8/issues/141)) ([4b66221](4b66221))
* **deps:** update deps to latest ([bcoe#384](https://github.com/prantlf/c8/issues/384)) ([78eac8c](78eac8c)), closes [bcoe#375](https://github.com/prantlf/c8/issues/375)
* **deps:** v8-to-istanbul with fix for Windows paths ([bcoe#311](https://github.com/prantlf/c8/issues/311)) ([ef1b875](ef1b875))
* **deps:** v8-to-istanbul with patch for crasher ([bcoe#200](https://github.com/prantlf/c8/issues/200)) ([d4b7d80](d4b7d80))
* **deps:** v8-to-istnbul with fixes for Node 10/18 ([bcoe#392](https://github.com/prantlf/c8/issues/392)) ([d5f642a](d5f642a))
* do not override NODE_V8_COVERAGE if set ([bcoe#70](https://github.com/prantlf/c8/issues/70)) ([8bb67b0](8bb67b0))
* don't load JSON that does not look like coverage ([bcoe#146](https://github.com/prantlf/c8/issues/146)) ([a6481f1](a6481f1))
* escaping issue with cobertura reporter ([bcoe#203](https://github.com/prantlf/c8/issues/203)) ([e93747b](e93747b))
* exclude coverage of the CJS-ESM bridge from results ([bcoe#83](https://github.com/prantlf/c8/issues/83)) ([da2c945](da2c945))
* exit with code 1 when report output fails ([bcoe#92](https://github.com/prantlf/c8/issues/92)) ([a27b694](a27b694))
* file URL to system path conversion ([bcoe#46](https://github.com/prantlf/c8/issues/46)) ([e7f8cf2](e7f8cf2))
* fix package.json `test:snap` script to use cross-env ([bcoe#366](https://github.com/prantlf/c8/issues/366)) ([5d2981c](5d2981c))
* Fix usage of excludeAfterRemap not to set the coverage always to 100 ([9113449](9113449)), closes [bcoe#462](https://github.com/prantlf/c8/issues/462)
* float patch for branch/function coverage merge bug ([bcoe#56](https://github.com/prantlf/c8/issues/56)) ([1de0cca](1de0cca))
* HTML report now has correct source positions for Node >10.16.0 ([bcoe#125](https://github.com/prantlf/c8/issues/125)) ([c49fa7f](c49fa7f))
* ignore missing source maps in raw coverage output ([bcoe#233](https://github.com/prantlf/c8/issues/233)) ([eed98af](eed98af))
* make tests run on Windows ([bcoe#25](https://github.com/prantlf/c8/issues/25)) ([08e44d0](08e44d0))
* make tmp directory regardless of clean ([44d2185](44d2185))
* **perf:** cache `this.exclude.shouldInstrument` for improved performance ([bcoe#388](https://github.com/prantlf/c8/issues/388)) ([8b36f23](8b36f23))
* pin to functional version of spawn-wrap ([d1ced8c](d1ced8c))
* process coverage merging ([bcoe#37](https://github.com/prantlf/c8/issues/37)) ([67959b4](67959b4))
* regex flags in dependency were breaking Node 8 ([a9d9645](a9d9645))
* remove the unmaintained mkdirp dependency ([bcoe#91](https://github.com/prantlf/c8/issues/91)) ([a465b65](a465b65))
* snapshot ([7fd9e13](7fd9e13))
* support node@v15.x.x built-in modules ([bcoe#265](https://github.com/prantlf/c8/issues/265)) ([1b90a22](1b90a22))
* switch to mkdirp for Node 8 ([206b83f](206b83f))
* temporary files should be in tmp folder ([bcoe#106](https://github.com/prantlf/c8/issues/106)) ([64dd2e6](64dd2e6))
* tweak inspector event timing ([bcoe#6](https://github.com/prantlf/c8/issues/6)) ([01f654e](01f654e))
* **types:** add excludeAfterRemap and allowExternal  ([bcoe#297](https://github.com/prantlf/c8/issues/297)) ([e32a53f](e32a53f))
* Upgrade dependencies ([985b219](985b219))
* upgrade to @bcoe/v8-coverage with breaking regex dropped ([6c28e7f](6c28e7f))
* **v8-to-istanbul:** fixes shebang handling/ignore behavior ([bcoe#267](https://github.com/prantlf/c8/issues/267)) ([21cd41f](21cd41f))
* **v8-to-istanbul:** pull in fix for missing branches ([bcoe#258](https://github.com/prantlf/c8/issues/258)) ([eaffa78](eaffa78))
* **v8-to-istanbul:** revert off by one that broke TypeScript ([bcoe#262](https://github.com/prantlf/c8/issues/262)) ([81ab5b7](81ab5b7))
* we were not exiting with 1 if mkdir failed ([bcoe#89](https://github.com/prantlf/c8/issues/89)) ([fb02ed6](fb02ed6))

* feat!: use Node.js' source-map cache, to support tools like ts-node (bcoe#152) ([53bba15](53bba15)), closes [bcoe#152](https://github.com/prantlf/c8/issues/152)
* feat!: default temp directory to report directory (bcoe#102) ([8602f4a](8602f4a)), closes [bcoe#102](https://github.com/prantlf/c8/issues/102)

### Features

* `--100` ([bcoe#332](https://github.com/prantlf/c8/issues/332)) ([4205f2f](4205f2f))
* add --config option and documentation on options and configs ([bcoe#308](https://github.com/prantlf/c8/issues/308)) ([99436ef](99436ef))
* add --exclude-node-modules option ([bcoe#321](https://github.com/prantlf/c8/issues/321)) ([a4733c6](a4733c6))
* add --extension option ([bcoe#331](https://github.com/prantlf/c8/issues/331)) ([ff01cd8](ff01cd8))
* add --report-dir alias (for consistency with nyc) ([0dd1b04](0dd1b04))
* add --skip-full ([bcoe#287](https://github.com/prantlf/c8/issues/287)) ([8b01b63](8b01b63))
* add `skipFull` and `excludeNodeModules` to type definitions ([bcoe#417](https://github.com/prantlf/c8/issues/417)) ([b93b9c0](b93b9c0))
* add support for 1:1 source-maps ([bcoe#85](https://github.com/prantlf/c8/issues/85)) ([6ca4345](6ca4345))
* add support for ignoring lines, functions, and blocks ([bcoe#87](https://github.com/prantlf/c8/issues/87)) ([c66950e](c66950e))
* add thresholds for enforcing coverage percentage ([bcoe#59](https://github.com/prantlf/c8/issues/59)) ([70e8943](70e8943))
* adds --all functionality ([bcoe#158](https://github.com/prantlf/c8/issues/158)) ([2eb631e](2eb631e))
* adds support for 1:many source maps ([bcoe#238](https://github.com/prantlf/c8/issues/238)) ([dbf94a0](dbf94a0))
* adds TypeScript definitions ([d39801b](d39801b)), closes [bcoe#195](https://github.com/prantlf/c8/issues/195)
* **all:** handle base64 inline source maps ([bcoe#283](https://github.com/prantlf/c8/issues/283)) ([3f12dd4](3f12dd4))
* allow  --reports-dir to be configured ([bcoe#65](https://github.com/prantlf/c8/issues/65)) ([5ab31f5](5ab31f5))
* allow relative paths to be optionally included ([3806c79](3806c79))
* allow script wrapper length to be specified ([bcoe#51](https://github.com/prantlf/c8/issues/51)) ([a22c4e0](a22c4e0))
* first pass at functional prototype without subprocess support ([bcoe#5](https://github.com/prantlf/c8/issues/5)) ([9534f56](9534f56))
* foreground-child's done() method was not being called ([bcoe#82](https://github.com/prantlf/c8/issues/82)) ([fde596e](fde596e))
* implement Istanbul reporting ([bcoe#8](https://github.com/prantlf/c8/issues/8)) ([8e430bf](8e430bf))
* improve test assertions ([bcoe#28](https://github.com/prantlf/c8/issues/28)) ([522720e](522720e))
* introduce --exclude-after-remap flag ([bcoe#293](https://github.com/prantlf/c8/issues/293)) ([53c4234](53c4234)), closes [bcoe#224](https://github.com/prantlf/c8/issues/224)
* load .nycrc/.nycrc.json to simplify migration ([bcoe#100](https://github.com/prantlf/c8/issues/100)) ([bd7484f](bd7484f))
* playing around with initial implementation ([18f5471](18f5471))
* support --check-coverage for reports ([bcoe#60](https://github.com/prantlf/c8/issues/60)) ([b542930](b542930))
* support for instrumenting files outside of current working directory ([7e53a0e](7e53a0e))
* support ignore start/stop comment ([bcoe#273](https://github.com/prantlf/c8/issues/273)) ([90949fa](90949fa)), closes [bcoe#271](https://github.com/prantlf/c8/issues/271)
* support passing reporter options ([bcoe#423](https://github.com/prantlf/c8/issues/423)) ([bc347a9](bc347a9))
* switch to stderr and default port ([bcoe#7](https://github.com/prantlf/c8/issues/7)) ([bb117b7](bb117b7))
* switch to using Node's built in coverage ([bcoe#22](https://github.com/prantlf/c8/issues/22)) ([3c1b92b](3c1b92b))
* **types:** add typings for reporterOptions ([bcoe#446](https://github.com/prantlf/c8/issues/446)) ([3646e6e](3646e6e))
* use debuglog rather than console.warn ([bcoe#279](https://github.com/prantlf/c8/issues/279)) ([7c04a4d](7c04a4d))
* use process.stdout.columns for reporter maxCols ([bcoe#409](https://github.com/prantlf/c8/issues/409)) ([7731574](7731574))
* warn instead of throw on exception ([bcoe#29](https://github.com/prantlf/c8/issues/29)) ([a8620d4](a8620d4))

### BREAKING CHANGES

* Node.js' source-map and lineLength cache is now used to remap coverage output (this allows tools like ts-node to be supported, which transpile at runtime).
* temp directory now defaults to setting for report directory
* c8 will now load source-maps if possible and remap coverage accordingly
* switches to using NODE_V8_COVERAGE rather than inspector directly
* dropped subprocess support for the time being, while we march towards an initial implementation.
mcknasty pushed a commit to mcknasty/c8 that referenced this pull request Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants