Fix: careful with linenumber removal in order to improve code coverage#281
Draft
lkdvos wants to merge 1 commit into
Draft
Fix: careful with linenumber removal in order to improve code coverage#281lkdvos wants to merge 1 commit into
lkdvos wants to merge 1 commit into
Conversation
Contributor
|
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/src/indexnotation/postprocessors.jl b/src/indexnotation/postprocessors.jl
index 21bc613..8909dd5 100644
--- a/src/indexnotation/postprocessors.jl
+++ b/src/indexnotation/postprocessors.jl
@@ -48,8 +48,10 @@ coverage).
function removeinternallinenumbernodes(ex)
if isexpr(ex, :block)
# within a block, `LineNumberNode`s are statement markers: drop the internal ones
- args = Any[removeinternallinenumbernodes(e) for e in ex.args
- if !_isinternallinenumber(e)]
+ args = Any[
+ removeinternallinenumbernodes(e) for e in ex.args
+ if !_isinternallinenumber(e)
+ ]
return Expr(:block, args...)
elseif isa(ex, Expr)
# elsewhere (e.g. the mandatory 2nd argument of a `:macrocall`) a `LineNumberNode` may
diff --git a/test/butensor.jl b/test/butensor.jl
index b0e4d50..ebb837c 100644
--- a/test/butensor.jl
+++ b/test/butensor.jl
@@ -13,10 +13,12 @@ using Bumper
lnns = LineNumberNode[]
collect_lnns(x) = x isa LineNumberNode ? push!(lnns, x) :
x isa Expr && foreach(collect_lnns, x.args)
- collect_lnns(@macroexpand @butensor begin
- T[a, b] := X[a, c] * Y[c, b]
- Z[a, b] := T[a, c] * W[c, b]
- end)
+ collect_lnns(
+ @macroexpand @butensor begin
+ T[a, b] := X[a, c] * Y[c, b]
+ Z[a, b] := T[a, c] * W[c, b]
+ end
+ )
@test !any(l -> startswith(String(l.file), pkgsrc), lnns)
@test count(l -> String(l.file) == @__FILE__, lnns) >= 2
end
diff --git a/test/macro_kwargs.jl b/test/macro_kwargs.jl
index 621bc05..b83d687 100644
--- a/test/macro_kwargs.jl
+++ b/test/macro_kwargs.jl
@@ -97,8 +97,10 @@ end
# parser's own internal ones (which would otherwise pollute the package's coverage).
@testset "line numbers (issue #280)" begin
collectlinenumbernodes(ex, acc = LineNumberNode[]) =
- (ex isa LineNumberNode ? push!(acc, ex) :
- ex isa Expr && foreach(e -> collectlinenumbernodes(e, acc), ex.args); acc)
+ (
+ ex isa LineNumberNode ? push!(acc, ex) :
+ ex isa Expr && foreach(e -> collectlinenumbernodes(e, acc), ex.args); acc
+ )
pkgsrc = dirname(pathof(TensorOperations))
pkglnns(lnns) = filter(l -> startswith(String(l.file), pkgsrc), lnns)
userlines(lnns) = sort!(unique!([l.line for l in lnns if String(l.file) == @__FILE__])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a claude-aided attempt of resolving #280.
From what I could tell, the removal of the line numbers is what causes the codecov gaps.
@Jutho I'm not entirely sure if we really need these to begin with, or if this is just a cosmetic thing to make the generated expressions easier to inspect?
In any case, I still have to more carefully investigate if this actually resolves the issue, and additionally if this automatically carries over to
@planarand@plansor.