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

Chrome coverage support #1155

Merged
merged 4 commits into from
Jan 24, 2020
Merged

Chrome coverage support #1155

merged 4 commits into from
Jan 24, 2020

Conversation

grouma
Copy link
Member

@grouma grouma commented Jan 24, 2020

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

@grouma grouma requested a review from natebosch January 24, 2020 21:01
@grouma grouma changed the title Browser coverage Chrome coverage support Jan 24, 2020

import '../executable_settings.dart';
import 'browser.dart';
import 'default_settings.dart';

// TODO(nweiz): move this into its own package?
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Are we using it? Should we file an issue to migrate to that package?

Copy link
Member Author

Choose a reason for hiding this comment

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

@grouma grouma requested a review from jakemac53 January 24, 2020 21:03
@@ -73,6 +82,8 @@ class Chrome extends Browser {
if (port != null) {
remoteDebuggerCompleter.complete(
getRemoteDebuggerUrl(Uri.parse('http://localhost:$port')));

connectionCompleter.complete(await _connect(process, port, idToUrl));
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this await is necessary, Completer.complete takes a FutureOr.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -3,6 +3,8 @@
* Bump minimum SDK to `2.4.0` for safer usage of for-loop elements.
* Deprecate `PhantomJS` and provide warning when used. Support for `PhantomJS`
will be removed in version `2.0.0`.
* Support coverage collection for the Chrome platform. See `README.md` for usage
Copy link
Contributor

Choose a reason for hiding this comment

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

1.12.0 since this is a new feature 🎉

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

message, gatherCoverage: () async {
var browser = _browser;
if (browser is Chrome) return browser.gatherCoverage();
return {};
Copy link
Contributor

Choose a reason for hiding this comment

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

should we warn here or anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

This will produce an empty result which is consistent with the current behavior. I might follow up with a PR that warns at the time of arg parsing.

var script = _idToUrl[scriptId];
if (script == null) return null;
var uri = Uri.parse(script);
var path = p.join(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you could do

var path = p.joinAll([
  ...uri.pathSegments.sublist(1, uri.pathSegments.length - 1),
  sourceUrl,
]);

@grouma grouma merged commit 3625dd8 into master Jan 24, 2020
@grouma grouma deleted the browser-coverage branch January 24, 2020 22:40
@robbecker-wf
Copy link

What a nice surprise for a Friday afternoon! Thank you!

@robbecker-wf
Copy link

We're pretty excited to use this .. will there be a 1.12 release with coverage soon?

@grouma
Copy link
Member Author

grouma commented Jan 28, 2020

Likely next week (busy this week traveling for work).

I need to make sure this solution scales for our internal use and so far it has been extremely promising. I have uncovered an issue in which invalid source maps can cause a crash. Once I fix that up I'll publish a new version of package:test.

Glad you folks are excited :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Facilitate code coverage in test runner
5 participants