-
Notifications
You must be signed in to change notification settings - Fork 218
Facilitate code coverage in test runner #36
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
Comments
👍 |
May be blocked on https://code.google.com/p/dart/issues/detail?id=21791 – we're actively investigating |
👍 |
#295 will provide access to the Observatory port for Dartium and content shell tests when run with All of that will require manually hooking up the coverage collector to Observatory. I'd like to support something more automatic, but that's not going to happen for a while. |
@nex3 The thing is that i also need to pause the test run after all tests executed in order to collect the complete coverage. Is there any way to achieve that? |
You should be able to talk to observatory and tell it to do that, either by setting some sort of pause-before-exit flag or by adding a breakpoint somewhere. |
@nex Thanx for the reply. Also using 'dart:developer' library does not stop on breakpoint when running the tests. The way i am running the tests is the following pub run test:test --pub-serve=<port> -p dartium --pause-after-load |
You can't pass flags directly to the VM from
That might be dart-lang/sdk#25369. |
@nex3 ok thanx a lot for the info |
In case it's useful, flutter's test wrapper does coverage collection: |
(Helping @nilsdoehring work around the It's unclear to me what the right division between package:test and package:coverage and package:dart_coveralls is. Right now you have to use pub run test has a much smarter crawler, but no way to collect coverage. It seems like the right split would be to add a Thoughts from others on what the right divisions are here? I'm happy to help hack together some of the necessary patches in my (very limited) hacking time. |
That sounds about right. @nex3 should really comment here. |
I agree that the best approach here is for |
Great. Two questions:
None of this is high priority, but with answers to the above, I might try to write up a patch to add coverage support to package:test one of these weekends in my free-hacking time. |
Probably yeah. If anyone knows of a way to get nice coverage reporting out of Chrome that would be rad, but the VM is the main focus.
No, this should work fine. We can connect to the VM service which will be able to provide us fine-grained information for exactly the isolates we care about. |
Any updates on this? |
I've not had much time to look, sorry. What would help me is understanding:
|
Just wanted to quickly chime in on question #2 and one of your previous comments - there was one package/suggestion out there (which I have since forgotten) that ran all of the test files on the same isolate. This creates an issue testing anything that modifies a static variable, since it carries to the next set of tests. Tests may then behave differently depending on the order their enclosing files are executed in. |
Any update on this issue @grouma ? |
Supporting coverage through the test runner was intended to be my summer intern's project. Unfortunately their internship was delayed so this work was never picked up. It's still on our radar however. We are making great progress on |
FYI @grouma and everyone else: The Dart platform team here at Workiva is facilitating our switch over to Dart 2, and coverage is a requirement for many of our teams to be confident in the switch. As such, we're looking at speccing out what implementing coverage within this package for VM and Chrome based tests involves. As of right now this includes:
|
Fantastic. Happy to help out where needed here.
…On Wed, Sep 18, 2019 at 9:36 AM willdrach-wk ***@***.***> wrote:
FYI @grouma <https://github.com/grouma> and everyone else:
The Dart platform team here at Workiva is facilitating our switch over to
Dart 2, and coverage is a requirement for many of our teams to be confident
in the switch. As such, we're looking at speccing out what implementing
coverage within this package for VM and Chrome based tests involves. As of
right now this includes:
- Implementing takePreciseCoverage and startPreciseCoverage from the
Chrome Profiler API in dwds
- Implementing coverage reports within the test runner
- Formatting those coverage reports from multiple runs into a single
lcov (or similar) report
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#36?email_source=notifications&email_token=AAOBNBK4YPU4MKTMI7HD4Q3QKJKHBA5CNFSM4A5XLJYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7AVWEA#issuecomment-532765456>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOBNBMBLKKUGZVKXRDUYADQKJKHBANCNFSM4A5XLJYA>
.
|
There's a good amount of work that needs to be done here, but the good news is that through my research I have found it to be... doable! VM CoverageVM coverage can be gathered through the Chrome CoverageFor Chrome coverage it gets a little more complicated, we need to integrate some APIs for working with the Chrome "Profiler" protocol (which is what allows us to gather coverage). That's described in dart-lang/webdev#674. Once that's done, it's a much more involved process: Concerns with DWDS:
Concerns with Chrome's coverage report
General concernsMy last concern comes with combining the coverage reports. The easiest solution would be to just to spit out multiple However, I'm far from an expert on that front, so I'd be happy if anyone has strong opinions about the output of a potential UpdatesThat's all I've got for today. This is definitely something that's on our radar, but is not prioritized or categorized at the moment. I can update when I have more news or code ready. |
Nope. It's used by the Flutter CLI and soon from some internal tools. It's intended to be consumed outside of
Not necessarily. We can alternatively expose this functionality through the Dart VM Service protocol. At the end of the day that's what
What issues were you running into? If I recall correctly Chrome provides ranges which are covered within a JS file. Those ranges have to be converted to JS line numbers. Then we should be able to translate that into Dart line numbers using the linked logic.
See above comment. Basically we want to implement this in
I think that's the best first approach. We've run into several issues with trying to merge VM and Browser coverage internally. It's difficult to get both tools to consider the exact same Dart lines for coverage. When different lines are considered for coverage you end up with invalid merged reports. |
Nice, concern addressed!
Good idea, I can look into this more as it gets closer to a reality
Mostly just ran out of time here, I believe I just wasn't passing the correct asset params in, so I was getting an empty sourcemap back.
Nice, another concern addressed! |
@grouma I have question regarding your comment
Is there an example somewhere where you actually using screenshot/hot reload. We are having hard time finding the way to trigger from the test package. |
Take a look at the screenshot test: I also think the Flutter CLI delegates to this in some form but I'm not super familiar with the code: |
FYI for the thread: code coverage collection is now implemented for Dart VM based tests! See the README for more details: https://pub.dev/packages/test#collecting-code-coverage |
Neat! FYI @zanderso in case |
/cc @jonahwilliams |
We can definitely get rid of the custom coverage script for measuring tool coverage with this! I'll see if we can also reuse it for flutter coverage too. |
@grouma I've been looking a bit more into gathering browser based coverage, and it seems that interacting with
It does seem doable to initialize the VM client in that way (creating a new It appears that Would you be open to a non- |
Yup. We'll need to provide an asset handler but that should be fairly straightforward. It likely can be a simple proxy server or even somehow delegate to the existing test handler. This is how we integrate the package with some internal tools.
I'm open to a non-dwds implementation but I'm cautious of supporting duplicate logic in I think we need to first nail down if this coverage feature will support both Dart2JS and DDC. If it's only the later than using Note that even internally we don't support coverage for Dart2JS. Our JS instrumentation approach to coverage does not work well with the tree shaken output of Dart2JS. If you feel that we should support Dart2JS coverage than a non-dwds approach likely makes sense. We'll have to be thoughtful of how we share the logic to support the various use cases. |
@grouma this is all good information. I'll take a few steps further down the As far as Dart2JS goes, I don't have any strong opinions one way or another. The one example I can provide is that we did have a push to run our unit tests in Dart2JS for a little while and it would have been more CI overhead to run a |
Towards dart-lang/test#36 Add `parseChromeCoverage` method to be used by `package:test` and internal tools. This method returns a hit-map based Dart report suitable for consumption by `package:coverage` to produce LCOV reports.
Support coverage collection for the Chrome platform. Coverage information is output to `.chrome.json` in a format suitable for consumption by `package:coverage`. Closes #36
Towards dart-lang/test#36 Add `parseChromeCoverage` method to be used by `package:test` and internal tools. This method returns a hit-map based Dart report suitable for consumption by `package:coverage` to produce LCOV reports.
Towards dart-lang/test#36 Add `parseChromeCoverage` method to be used by `package:test` and internal tools. This method returns a hit-map based Dart report suitable for consumption by `package:coverage` to produce LCOV reports.
I'm sure you guys are thinking about this but I didn't see an open issue to talk about it. The alpha runner looks great but would like to see the ability to generate test coverage from it by providing a remote debugging port (or some other more elegant solution!).
The text was updated successfully, but these errors were encountered: