Skip to content

Commit 814f4d8

Browse files
committed
go/analysis/analysistest: Raise error when edited file cannot be formatted
There are instances when the diagnostics are reported correctly by the analyzer, but the suggested fixes are wrong, and result in code that cannot be formatted by `format.Source` (due to errors in the edited code). Right now, in those cases, the tests pass despite the format errors. This commit fixes that. Signed-off-by: Sourya Vatsyayan <[email protected]>
1 parent 2caf765 commit 814f4d8

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

go/analysis/analysistest/analysistest.go

+1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ func RunWithSuggestedFixes(t Testing, dir string, a *analysis.Analyzer, patterns
209209

210210
formatted, err := format.Source([]byte(out))
211211
if err != nil {
212+
t.Errorf("Could not format edited file %s. Error: %s", file.Name(), err)
212213
continue
213214
}
214215
if want != string(formatted) {

0 commit comments

Comments
 (0)