cmd/cover: //line directives frequently handled incorrectly #41222
Labels
help wanted
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
(This combines #35781, #33690, #25280, and golang/vscode-go#603)
Source files that contain //line directives confuse the coverage tool, prducing coverage output that is unhelpful or confusing to users.
For instance, a short main.go (import path
foo.gak
) with first linesproduces a coverage file:
If the first line is changed to
the coverage file changes to:
This file does not refer to
con.go
, and the ranges are wrong (or, at best, imprecise) for that file, and completely wrong formain.go
.A minimal improvement would be for the coverage tool to change user's
//line
directives to bare//
comments, so that the coverage data corresponds to the file presented to the tool. [Getting results that point to files mentioned in//line
directives would require changing the format of the tables in the generated code, at least. Even then the results might be peculiar, for instance if the generated file were run through go fmt.]The text was updated successfully, but these errors were encountered: