-
Notifications
You must be signed in to change notification settings - Fork 13
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
Allow for uncovered range? #30
Comments
nice idea, PR welcome. |
This is the direction I'm going in... passes all the tests, but ironically they're not covered 🤪. I'm uncertain if this is complete or not. From 42fdee2ffe8415a40e2918fdc5ee827be32a6632 Mon Sep 17 00:00:00 2001
From: Ryan Davis <[email protected]>
Date: Fri, 13 May 2022 12:43:06 -0700
Subject: [PATCH] Added support for uncovered ranges.
This will reduce false negatives under dual-boot testing scenarios.
---
.rubocop.yml | 3 +++
lib/single_cov.rb | 7 +++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/.rubocop.yml b/.rubocop.yml
index 1538d56..5580801 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -2,6 +2,9 @@ AllCops:
TargetRubyVersion: 2.5 # lowest supported version
NewCops: enable
+Style/CaseEquality:
+ Enabled: false
+
Style/StringLiterals:
Enabled: false
diff --git a/lib/single_cov.rb b/lib/single_cov.rb
index ca49fcd..b42c778 100644
--- a/lib/single_cov.rb
+++ b/lib/single_cov.rb
@@ -34,7 +34,7 @@ module SingleCov
next no_coverage_error(file) unless coverage = result["#{root}/#{file}"]
uncovered = uncovered(coverage)
- next if uncovered.size == expected_uncovered
+ next if expected_uncovered === uncovered.size
# ignore lines that are marked as uncovered via comments
# TODO: warn when using uncovered but the section is indeed covered
@@ -42,7 +42,7 @@ module SingleCov
uncovered.reject! do |line_start, _, _, _|
content[line_start - 1].match?(UNCOVERED_COMMENT_MARKER)
end
- next if uncovered.size == expected_uncovered
+ next if expected_uncovered === uncovered.size
bad_coverage_error(file, expected_uncovered, uncovered)
end.compact
@@ -291,6 +291,9 @@ module SingleCov
def bad_coverage_error(file, expected_uncovered, uncovered)
details = "(#{uncovered.size} current vs #{expected_uncovered} configured)"
+
+ return warning "File #{file} is no longer covered by range #{details}" if Range === expected_uncovered
+
if expected_uncovered > uncovered.size
if running_single_file?
warning "#{file} has less uncovered lines #{details}, decrement configured uncovered"
--
2.36.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using
===
instead of==
could allow for a range of declared uncovered lines. This could encompass the variability of running under different versions of rails, for example or having versioned code:The text was updated successfully, but these errors were encountered: