godoc/analysis: log one error per error package.
Previously type errors were reported via the web interface but not logged, but this led to confusion as to why SSA construction and/or pointer analysis were not attempted. LGTM=gri R=gri, bradfitz CC=golang-codereviews https://golang.org/cl/136660043
This commit is contained in:
parent
9dcf670d50
commit
15e89a9a8c
|
@ -340,7 +340,11 @@ func Run(pta bool, result *Result) {
|
||||||
SourceImports: true,
|
SourceImports: true,
|
||||||
AllowErrors: true,
|
AllowErrors: true,
|
||||||
}
|
}
|
||||||
conf.TypeChecker.Error = func(e error) {} // silence the default error handler
|
|
||||||
|
// Silence the default error handler.
|
||||||
|
// Don't print all errors; we'll report just
|
||||||
|
// one per errant package later.
|
||||||
|
conf.TypeChecker.Error = func(e error) {}
|
||||||
|
|
||||||
var roots, args []string // roots[i] ends with os.PathSeparator
|
var roots, args []string // roots[i] ends with os.PathSeparator
|
||||||
|
|
||||||
|
@ -365,6 +369,7 @@ func Run(pta bool, result *Result) {
|
||||||
|
|
||||||
if _, err := conf.FromArgs(args, true); err != nil {
|
if _, err := conf.FromArgs(args, true); err != nil {
|
||||||
// TODO(adonovan): degrade gracefully, not fail totally.
|
// TODO(adonovan): degrade gracefully, not fail totally.
|
||||||
|
// (The crippling case is a parse error in an external test file.)
|
||||||
result.setStatusf("Analysis failed: %s.", err) // import error
|
result.setStatusf("Analysis failed: %s.", err) // import error
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -372,6 +377,13 @@ func Run(pta bool, result *Result) {
|
||||||
result.setStatusf("Loading and type-checking packages...")
|
result.setStatusf("Loading and type-checking packages...")
|
||||||
iprog, err := conf.Load()
|
iprog, err := conf.Load()
|
||||||
if iprog != nil {
|
if iprog != nil {
|
||||||
|
// Report only the first error of each package.
|
||||||
|
for _, info := range iprog.AllPackages {
|
||||||
|
for _, err := range info.Errors {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
log.Printf("Loaded %d packages.", len(iprog.AllPackages))
|
log.Printf("Loaded %d packages.", len(iprog.AllPackages))
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -394,7 +406,7 @@ func Run(pta bool, result *Result) {
|
||||||
mainPkgs = append(mainPkgs, pkg)
|
mainPkgs = append(mainPkgs, pkg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Print("Main packages: ", mainPkgs)
|
log.Print("Transitively error-free main packages: ", mainPkgs)
|
||||||
|
|
||||||
// Build SSA code for bodies of all functions in the whole program.
|
// Build SSA code for bodies of all functions in the whole program.
|
||||||
result.setStatusf("Constructing SSA form...")
|
result.setStatusf("Constructing SSA form...")
|
||||||
|
|
Loading…
Reference in New Issue