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

--coverage should generate a lcov.info file #1265

Open
rrousselGit opened this issue Jun 16, 2020 · 16 comments
Open

--coverage should generate a lcov.info file #1265

rrousselGit opened this issue Jun 16, 2020 · 16 comments
Labels
next-breaking-release Issues that are worth doing but need to wait for a breaking version bump

Comments

@rrousselGit
Copy link
Contributor

Currently when running pub run test --coverage or dart test --coverage, only proprietary JSON files are generated.

Most tools use an lcov.info file instead. It would be great if --coverage could generate that file too.

@grouma
Copy link
Member

grouma commented Jun 16, 2020

package:coverage can consume these files and output into the lcov format. I believe the command is format_coverage. See the readme: https://github.com/dart-lang/coverage

@grouma grouma closed this as completed Jun 16, 2020
@rrousselGit
Copy link
Contributor Author

But why do we need an extra dependency for it when the flag is built-in?

Flutter doesn't require people to install package:coverage.

@grouma
Copy link
Member

grouma commented Jun 16, 2020

What's the workflow like with Flutter? Note that Flutter Tools does depend on package:coverage so it is pulled in implicitly. Note also you don't need package:coverage as a dev dependency, it can be used as a global dependency.

@rrousselGit
Copy link
Contributor Author

What's the workflow like with Flutter

flutter test --coverage generates a lcov.info file directly instead of all of these json files.

Sure people could use coverage. But why should they have to?
The generated json files are useless to most users, so that shouldn't be the default behavior.

Considering that as part of Dart 2.9, we now have an official dart test command, the current behavior looks sketchy.
It'd be logical to have dart test --coverage and flutter test --coverage behave the same

@grouma
Copy link
Member

grouma commented Jun 16, 2020

That's a fair argument. I likely won't be able to get to this in the near future but I'm happy to review PRs. We'll likely have to model this as a breaking change.

@grouma grouma reopened this Jun 16, 2020
@mit-mit
Copy link
Member

mit-mit commented Jun 29, 2020

cc @jwren, and a +1 for supporting lcov in dart test

@natebosch
Copy link
Member

The flutter test --coverage and pub run test --coverage flags are already quite different. Outputting to a different format by default won't normalize their behavior.

pub run test:

    --coverage=<directory>            Gathers coverage and outputs it to the specified directory.
                                      Implies --debug.

flutter test:

    --coverage                        Whether to collect coverage information.
    --merge-coverage                  Whether to merge coverage data with "coverage/lcov.base.info".
                                      Implies collecting coverage data. (Requires lcov)
    --coverage-path                   Where to store coverage information (if coverage is enabled).
                                      (defaults to "coverage/lcov.info")

I'd be fine with changing package:test options to match flutter test with --coverage and --coverage-path on the next breaking change release. I don't know what --merge-coverage does here, but if it is useful we could add it too.

I'm not sure that any other changes before then move the needle much in terms of making things feel consistent. I also do not think it is a good idea to try to do argument manipulation in dart test to try to normalize things with some hack in package:test.

@natebosch natebosch added the next-breaking-release Issues that are worth doing but need to wait for a breaking version bump label Jun 29, 2020
@rrousselGit
Copy link
Contributor Author

Would it make sense to make dart test do some extra logic on the top of package:test?
Such that dart pub run test --coverage would be untouched – but dart test --coverage would match Flutter?

This should make the change less breaking (if breaking at all as 2.9 is not stable yet) and not require hacking on package:test.

dart test could internally run the logic to combine both package:test and package:coverage together.

@natebosch
Copy link
Member

Would it make sense to make dart test do some extra logic on the top of package:test?

This is what I was referring to when I said "I also do not think it is a good idea to try to do argument manipulation in dart test to try to normalize things with some hack in package:test."

The argument differences in webdev from pub run build_runner already cause us some headaches and I'm leaning towards that being a bad idea. Having 2 commands that mostly do the same thing, and is documented as "uses package:test to run tests" should behave as close as possible. @mit-mit and @jwren might have different opinions on that.

@natebosch
Copy link
Member

If we do think its best to try to normalize the flags we should check whether the 3 flags that flutter test have chosen make sense. It is strange that --merge-coverage implicitly enables --coverage, but --coverage-path doesn't.

@mit-mit
Copy link
Member

mit-mit commented Jun 30, 2020

cc @jonahwilliams @zanderso can you have some background on the flutter test flags?

@jonahwilliams
Copy link
Contributor

I've never used merge-coverage or coverage-path. coverage-path might just be for the fuchsia tooling, and merge-coverage requires having the lcov tool available which requires a bit of hacking on windows. IMO it's not really clear how useful it is.

sensuikan1973 added a commit to sensuikan1973/libedax4dart that referenced this issue Jan 24, 2021
sensuikan1973 added a commit to sensuikan1973/libedax4dart that referenced this issue Jan 24, 2021
* add coverage package. See: dart-lang/test#1265
* use codecov
* add codecov badge
* fix test/coverage command & add .codecov.yml
* remove unused factory
* codecov ignore ffi structs
@natebosch
Copy link
Member

@christopherfujino do you know if we have any analytics for the usage of coverage test runs in the flutter tool?

@bkonyi have we started collecting usage metrics from the dart dev tool?

If we can validate what set of flags and behavior makes the most sense and that usage is low enough to not break a bunch of folks then we could look at these changes.

@bkonyi
Copy link
Contributor

bkonyi commented Aug 19, 2021

@natebosch we do have usage metrics, but I don't believe we collect anything other than which commands are being used. I'm guessing we care about coverage flags provided to dart test in this case?

@christopherfujino
Copy link
Member

we have analytics of flutter test, but not flutter test --coverage

@rrousselGit
Copy link
Contributor Author

Gentle bump on this~

Being unable to run dart test --coverage and generate a lcov file is a significant user experience issue.
Even as an experienced Dart user, I always have to google how to convert the generated JSON in the industry-standard lcov file.

If we don't want a breaking change, what about a --coverage-format=lcov at least?
That would still be more intuitive than having to do it by hand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next-breaking-release Issues that are worth doing but need to wait for a breaking version bump
Projects
None yet
Development

No branches or pull requests

7 participants