block-forest / dart-coveralls

Calculate coverage of your dart scripts, format it to LCOV and send it to coveralls
https://pub.dartlang.org/packages/dart_coveralls
MIT License
27 stars 17 forks source link

Taking into account all dart files not run by unit tests #74

Open gesellc opened 7 years ago

gesellc commented 7 years ago

We run dart_coveralls via travis.ci.

Now dart_coveralls seems to upload only coverage information for the files that are run during unit testing. Meaning all dart files that are not yet checked by unit tests (0% coverage) are ignored during code coverage calculation.

As a result the coverage percentage is too high not taking into account all the non-covered dart files.

Is there a way to measure coverage for the group of all existing dart files in a repository tree or a subfolder?

zoechi commented 7 years ago

Coverage measures what part of the code was actually executed. If it's not executed it's not measured as executed. To me it's entirely unclear what this request is about.

Is there a way to measure coverage for the group of all existing dart files in a repository tree or a subfolder?

What exactly is this supposed to measure? Measure the code that would be executed if it would be executed?

gesellc commented 7 years ago

For example: When a commit adds a dart file to our project without any unit test executing that file I would like to see a decrease in the code coverage report on coveralls.io.

For that to happen I assume that the coveralls upload must also include all the source files that we are interested in, but that are not covered yet.

zoechi commented 7 years ago

Just integrate coverage with CI so that it's run on every commit.

gesellc commented 7 years ago

Just to reply to your last post: We have integrated coverage in CI and since then it runs on every commit. Links are in the first post of this issue.

I'll use coverage.py to try to explain this from another angle. In this section the coverage.py documentation describes the feature we are looking for:

You can specify source to measure with the --source command-line switch, or the [run] source configuration value. The value is a comma- or newline-separated list of directories or package names. If specified, only source inside these directories or packages will be measured.

This is the important part:

Specifying the source option also enables coverage.py to report on unexecuted files, since it can search the source tree for files that haven’t been measured at all.

That's it, I would like coveralls.io to show unexecuted files that are part of our dart package. I want to see those files with 0% coverage so that we can observe where we stand and how we progress while writing more unit tests.

Can we do this with dart_coveralls?

zoechi commented 7 years ago

@gesellc I think that makes it clear what the issue is about.

nilsdoehring commented 7 years ago

@zoechi @gesellc thanks for the clarification loop. This seems not covered by the VM, so the implementation would be something like this:

  1. Add a command-line option similar to coverage.py with directories or files as CSV. External packages won't work, as there's no way to dirlist those from inside the depending package.
  2. Parse coverage data from the VM as usual
  3. When converting to LCOV, check against CSV and add all 'unreported' files as 0% to the LCOV file before uploading to coveralls.io

I'm unsure though if this is to be considered 'core functionality'. You could achieve the same by:

  1. running the calc command
  2. parsing the resulting LCOV json with your own script, adding anything you want
  3. running the upload command

Do you think you could start with the 2nd approach and see how it works? Once it does, I would happily include it into dart_coveralls.