tools icon indicating copy to clipboard operation
tools copied to clipboard

Example repo and coverage.json

Open stevepeak opened this issue 10 years ago โ€ข 9 comments

I'm looking to add support for Dart to codecov.io (full disclosure: I'm the founder)

I'm not familiar with Dart and hoping someone can help show me an example coverage.json output file so that I can upload it to Codecov. If you have a very lean example repo I can show customers that would be great!

Thanks ~ Steve

stevepeak avatar Feb 23 '15 14:02 stevepeak

Hi Steve, thanks for checking in. Can you use LCOV format? coverage.json is really just an intermediate format that we use, but format_coverage.dart includes an LCOV formatter.

Also, the minute I get some time to work on it, I intend to add an updated coverage collection tool that spawns another VM process running the test code, collects coverage from it and emits in the requested format in one go rather than via the current two step process. That might simplify things a bit for you.

If you've got any specific feature requests, please let me know!

cbracken avatar Mar 05 '15 01:03 cbracken

Thank you for the update! Producing an lcov file would work. Please correct me if I'm wrong: that lcov does not support branch coverage which is preferable.

If a customer can simply create the lcov file then my uploader will find it. They would only have to call codecov see example here and the file will be collected and submitted.

If it's not asking to much. I don't know Dart and it would be helpful to have an example repo like these: Codecov Examples. If you can help me create a Dart repo I would be in heaven :)

Thank again for your help.

stevepeak avatar Mar 05 '15 01:03 stevepeak

Sounds good! I've filed dart-lang/tools#550 for example coverage code. I'll try to get to this next week.

cbracken avatar Mar 06 '15 17:03 cbracken

For everyone interested. I just figured out how to send lcov data generated by the coverage package to codecov from Travis. My very basic .travis.yml looks something like this:

sudo: false

language: dart

script:
  - pub run test
  - pub global activate coverage
  - dart --observe=8111 test/all.dart &
  - sleep 1
  - pub global run coverage:collect_coverage --port=8111 -o coverage.json --resume-isolates
  - pub global run coverage:format_coverage --package-root=packages --report-on lib --in coverage.json --out lcov.info --lcov

after_success:
  - bash <(curl -s https://codecov.io/bash)

The sleep is kind of awkward, but it does the job. Ideally it would be nice if the coverage package can provide additional executable which would encapsulate observatory stuff and just output the lcov.info as a result. Can be tricky with dartium though.

pulyaevskiy avatar Apr 10 '16 03:04 pulyaevskiy

@pulyaevskiy would you be available to create a super simple "hello world" example of dart at https://github.com/codecov/example-dart

We can point out caveats like dartium and others that you are aware of. Thanks!

stevepeak avatar Aug 11 '16 22:08 stevepeak

@stevepeak I'd be happy to help. Might be able to push something over the weekend.

pulyaevskiy avatar Aug 11 '16 22:08 pulyaevskiy

@pulyaevskiy I've added you to as a contributors to the project ๐Ÿ‘ Thank you so much for helping out.

stevepeak avatar Aug 15 '16 20:08 stevepeak

@stevepeak regarding "Please correct me if I'm wrong: that lcov does not support branch coverage which is preferable.", c - Lcov: can not collect branch coverage statistics - Stack Overflow has some answers suggesting you simply need --rc lcov_branch_coverage=1.

Looks like coverage would need to modify https://github.com/dart-lang/coverage/blob/4d1a38e66da713b99f00cc46918936d171b42d85/lib/src/formatter.dart#L49 to write that info as defined at Linux Test Project - Coverage ยป lcov:

   Branch coverage information is stored which one line per branch:

     BRDA:<line number>,<block number>,<branch number>,<taken>

   Block  number  and  branch  number are gcc internal IDs for the branch.
   Taken is either โ€™-โ€™ if the basic block containing the branch was  never
   executed or a number indicating how often that branch was taken.

   Branch coverage summaries are stored in two lines:

     BRF:<number of branches found>
     BRH:<number of branches hit>

patkujawa-wf avatar Dec 15 '16 17:12 patkujawa-wf

@patkujawa-wf Thank you for pointing this out. Codecov does recognize BRDA data and properly reports branch coverage. ๐Ÿ‘

stevepeak avatar Dec 16 '16 17:12 stevepeak