-
Notifications
You must be signed in to change notification settings - Fork 50
Add --fail-under flag for minimum coverage threshold #2075
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
Add --fail-under flag for minimum coverage threshold #2075
Conversation
Signed-off-by: vvs-personalstash <[email protected]>
Signed-off-by: vvs-personalstash <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unit test that checks the calculateCoveragePercentage
function is a good start, but we'll also need an integration test to verify that the check's logic works: one test that verifies that the command succeeds when the coverage percentage is above the threshold, and test that verifies it fails when the coverage is below the threshold. There's a few existing integration tests that you can piggy back on. Maybe test_with_coverage_test.dart
, but there's others too.
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
PR HealthBreaking changes ✔️
Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs.
Coverage
|
File | Coverage |
---|---|
pkgs/coverage/bin/format_coverage.dart | 💔 44 % ⬇️ 9 % |
pkgs/coverage/bin/test_with_coverage.dart | 💚 37 % ⬆️ 2 % |
pkgs/coverage/lib/src/coverage_percentage.dart | 💚 100 % |
This check for test coverage is informational (issues shown here will not fail the PR).
This check can be disabled by tagging the PR with skip-coverage-check
.
API leaks ✔️
The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
Package | Leaked API symbols |
---|
License Headers ✔️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files |
---|
no missing headers |
All source files should start with a license header.
Unrelated files missing license headers
Files |
---|
pkgs/bazel_worker/benchmark/benchmark.dart |
pkgs/bazel_worker/example/client.dart |
pkgs/bazel_worker/example/worker.dart |
pkgs/benchmark_harness/integration_test/perf_benchmark_test.dart |
pkgs/boolean_selector/example/example.dart |
pkgs/clock/lib/clock.dart |
pkgs/clock/lib/src/clock.dart |
pkgs/clock/lib/src/default.dart |
pkgs/clock/lib/src/stopwatch.dart |
pkgs/clock/lib/src/utils.dart |
pkgs/clock/test/clock_test.dart |
pkgs/clock/test/default_test.dart |
pkgs/clock/test/stopwatch_test.dart |
pkgs/clock/test/utils.dart |
pkgs/coverage/lib/src/coverage_options.dart |
pkgs/coverage/test/collect_coverage_config_test.dart |
pkgs/coverage/test/config_file_locator_test.dart |
pkgs/html/example/main.dart |
pkgs/html/lib/dom.dart |
pkgs/html/lib/dom_parsing.dart |
pkgs/html/lib/html_escape.dart |
pkgs/html/lib/parser.dart |
pkgs/html/lib/src/constants.dart |
pkgs/html/lib/src/encoding_parser.dart |
pkgs/html/lib/src/html_input_stream.dart |
pkgs/html/lib/src/list_proxy.dart |
pkgs/html/lib/src/query_selector.dart |
pkgs/html/lib/src/token.dart |
pkgs/html/lib/src/tokenizer.dart |
pkgs/html/lib/src/treebuilder.dart |
pkgs/html/lib/src/utils.dart |
pkgs/html/test/dom_test.dart |
pkgs/html/test/parser_feature_test.dart |
pkgs/html/test/parser_test.dart |
pkgs/html/test/query_selector_test.dart |
pkgs/html/test/selectors/level1_baseline_test.dart |
pkgs/html/test/selectors/level1_lib.dart |
pkgs/html/test/selectors/selectors.dart |
pkgs/html/test/support.dart |
pkgs/html/test/tokenizer_test.dart |
pkgs/html/test/trie_test.dart |
pkgs/html/tool/generate_trie.dart |
pkgs/pubspec_parse/test/git_uri_test.dart |
pkgs/stack_trace/example/example.dart |
pkgs/watcher/test/custom_watcher_factory_test.dart |
pkgs/yaml_edit/example/example.dart |
Pull Request Test Coverage Report for Build 14722503205Details
💛 - Coveralls |
Signed-off-by: vvs-personalstash <[email protected]>
Signed-off-by: vvs-personalstash <[email protected]>
Signed-off-by: vvs-personalstash <[email protected]>
2b32fff
to
d271d3a
Compare
Hi Liam I decided to use the test_with_coverage_test to create the integration tests both checking whether the command passes when threshold is met and exits with exit(1) if not and also modified the test_with_coverage_package to test for branch hits also.I would like to know if these tests work for you or do you have a different approach in mind and if I am making any mistakes in my implementations till now. |
…ge percentage Signed-off-by: vvs-personalstash <[email protected]>
d271d3a
to
3a1eba8
Compare
Signed-off-by: vvs-personalstash <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Just a couple more tiny comments, then I think this will be ready to land.
Oh, also take a look at the analyzer failures on the GitHub bot |
Signed-off-by: vvs-personalstash <[email protected]>
Signed-off-by: vvs-personalstash <[email protected]>
Revisions updated by `dart tools/rev_sdk_deps.dart`. i18n (https://github.com/dart-lang/i18n/compare/de19436..e44af54): e44af54 2025-05-01 dependabot[bot] Bump the github-actions group with 2 updates (dart-lang/i18n#966) test (https://github.com/dart-lang/test/compare/3ac991f..c3755d8): c3755d80 2025-05-01 dependabot[bot] Bump github/codeql-action from 3.28.13 to 3.28.16 in the github-actions group (dart-lang/test#2492) 935b8b04 2025-04-28 Danny Tuppeny Allow specifying an explicit location for test/groups (dart-lang/test#2481) tools (https://github.com/dart-lang/tools/compare/11f4cf7..92f10a9): 92f10a9a 2025-04-30 Liam Appelbe [coverage] Fix resume after shutdown error (dart-lang/tools#2079) 7e8cb037 2025-04-29 Viral Verma Add --fail-under flag for minimum coverage threshold (dart-lang/tools#2075) web (https://github.com/dart-lang/web/compare/553c14d..f1becf0): f1becf0 2025-04-30 Natalie Weizenbaum Add conversions between Dart's Uri and the JS URL (dart-lang/web#365) Change-Id: Icc33983c9cc2cdad7add25494c92a21e8605b2a1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425900 Commit-Queue: Devon Carew <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
Implement
--fail-under
Flag for Enforcing Minimum Code Coverage ThresholdsThis pull request introduces a new command-line flag,
--fail-under
, to thepackage:coverage
tool. The feature is modeled after the behavior of the--fail-under
flag in Python’scoverage.py
library.Overview of Changes
New Feature:
--fail-under
exit(1)
), signaling failure.Optional Precision Control:
--precision
--precision
flag has been introduced to control the number of decimal places shown in the computed coverage percentage.Need Clarity
-Currently i have only added tests for directly testing the coverage percentage calculator,Is it sufficient or should I modify the test_with_coverage_test to test the flag also
Fixes #514