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

Code coverage #2294

Merged
merged 31 commits into from
Sep 13, 2024
Merged

Code coverage #2294

merged 31 commits into from
Sep 13, 2024

Conversation

gogolon
Copy link
Collaborator

@gogolon gogolon commented Aug 6, 2024

This adds a possibility to collect code coverage from patrol tests using patrol test --coverage. Unwanted files can be ignored using glob patterns, i.e: patrol test --coverage --coverage-ignore="**/*.g.dart"

The PR is not finished yet - there is one thing that needs to be addressed. Currently, the coverage is only collected from isolates that are running when particular test finishes - if an isolate exits prior to this, it will be omitted. The --pause-on-exit flag is already set, but coverage has to be collected from the paused isolate separately, and it has to be resumed (other isolates might be waiting for its result).

The code should be now fully functional, but it needs some cleanup

gogolon added 3 commits August 6, 2024 17:32
…trol to not collect coverage from all tests if there were more than 1 tests per file
Copy link

docs-page bot commented Aug 6, 2024

To view this pull requests documentation preview, visit the following URL:

patrol.leancode.co/~2294

Documentation is deployed and generated using docs.page.

@github-actions github-actions bot added package: patrol Related to the patrol package (native automation, test bundling) package: patrol_cli Related to the patrol_cli package labels Aug 6, 2024
Copy link
Contributor

@bartekpacia bartekpacia left a comment

Choose a reason for hiding this comment

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

nice idea:)

packages/patrol/lib/src/binding.dart Outdated Show resolved Hide resolved
@gogolon gogolon marked this pull request as ready for review August 19, 2024 08:39
@gogolon gogolon changed the title [WIP] Code coverage Code coverage Aug 21, 2024
@gogolon gogolon requested a review from bartekpacia August 22, 2024 12:11
Copy link
Contributor

@bartekpacia bartekpacia left a comment

Choose a reason for hiding this comment

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

:)

packages/patrol/lib/src/binding.dart Outdated Show resolved Hide resolved
packages/patrol/lib/src/common.dart Show resolved Hide resolved
packages/patrol_cli/lib/src/coverage/coverage_tool.dart Outdated Show resolved Hide resolved
packages/patrol_cli/lib/src/coverage/coverage_tool.dart Outdated Show resolved Hide resolved
packages/patrol_cli/lib/src/coverage/coverage_tool.dart Outdated Show resolved Hide resolved
Comment on lines +205 to +213
extension<T> on Completer<T> {
void disposedBy(DisposeScope disposeScope, T disposeValue) {
disposeScope.addDispose(() {
if (!isCompleted) {
complete(disposeValue);
}
});
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a good addition to package:dispose_scope by @RobertOdrowaz.

packages/patrol_cli/lib/src/coverage/coverage_tool.dart Outdated Show resolved Hide resolved
@gogolon gogolon requested a review from piotruela September 9, 2024 08:35
Copy link
Collaborator

@piotruela piotruela left a comment

Choose a reason for hiding this comment

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

Nice work, lgtm 👍

@pdenert
Copy link
Collaborator

pdenert commented Sep 10, 2024

@gogolon good job! Please bump versions of patrol and patrol_cli, remember about packages/patrol_cli/lib/src/base/constants.dart and compatibility_table. Also add Changelog for both packages

@@ -92,7 +92,7 @@ Future<void> main() async {
);
testExplorationCompleter.complete(dartTestGroup);
print('patrol_test_explorer: obtained Dart-side test hierarchy:');
printGroupStructure(dartTestGroup);
reportGroupStructure(dartTestGroup);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This probably force incompatibility with old patrol versions

@github-actions github-actions bot added the docs Concerns doc comments, READMEs, or docs label Sep 11, 2024
Copy link
Collaborator

@pdenert pdenert left a comment

Choose a reason for hiding this comment

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

LGTM - Just two small changes in changelogs and you can merge it

packages/patrol_cli/CHANGELOG.md Show resolved Hide resolved
packages/patrol/CHANGELOG.md Outdated Show resolved Hide resolved
@gogolon gogolon merged commit 2656cfe into leancodepl:master Sep 13, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Concerns doc comments, READMEs, or docs package: patrol_cli Related to the patrol_cli package package: patrol Related to the patrol package (native automation, test bundling)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants