aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2021-01-05 10:25:47 +0100
committerDmitry Vyukov <dvyukov@google.com>2021-01-05 10:53:17 +0100
commit7aaf16ad601b3a8a6a8bc14a308629ba3a6f530c (patch)
tree4524cd2475af375b7c313a530f140ba89d983b06 /pkg
parent043df049706d4f6ad65771fe22579b1dbfd54ac7 (diff)
pkg/build: extract another build error root cause
Diffstat (limited to 'pkg')
-rw-r--r--pkg/build/build.go25
-rw-r--r--pkg/build/build_test.go26
2 files changed, 39 insertions, 12 deletions
diff --git a/pkg/build/build.go b/pkg/build/build.go
index 9931ce0ea..aa7797650 100644
--- a/pkg/build/build.go
+++ b/pkg/build/build.go
@@ -257,7 +257,7 @@ func extractCauseRaw(s []byte) [][]byte {
dedup := make(map[string]bool)
for _, line := range bytes.Split(s, []byte{'\n'}) {
for _, pattern := range buildFailureCauses {
- if !bytes.Contains(line, pattern.pattern) {
+ if !pattern.pattern.Match(line) {
continue
}
if weak && !pattern.weak {
@@ -279,21 +279,22 @@ func extractCauseRaw(s []byte) [][]byte {
}
type buildFailureCause struct {
- pattern []byte
+ pattern *regexp.Regexp
weak bool
}
var buildFailureCauses = [...]buildFailureCause{
- {pattern: []byte(": error: ")},
- {pattern: []byte("ERROR: ")},
- {pattern: []byte(": fatal error: ")},
- {pattern: []byte(": undefined reference to")},
- {pattern: []byte(": multiple definition of")},
- {pattern: []byte(": Permission denied")},
- {pattern: []byte(": not found")},
- {weak: true, pattern: []byte(": final link failed: ")},
- {weak: true, pattern: []byte("collect2: error: ")},
- {weak: true, pattern: []byte("FAILED: Build did NOT complete")},
+ {pattern: regexp.MustCompile(`: error: `)},
+ {pattern: regexp.MustCompile(`ERROR: `)},
+ {pattern: regexp.MustCompile(`: fatal error: `)},
+ {pattern: regexp.MustCompile(`: undefined reference to`)},
+ {pattern: regexp.MustCompile(`: multiple definition of`)},
+ {pattern: regexp.MustCompile(`: Permission denied`)},
+ {pattern: regexp.MustCompile(`: not found`)},
+ {pattern: regexp.MustCompile(`^([a-zA-Z0-9_\-/.]+):[0-9]+:([0-9]+:)?.*(error|invalid|fatal|wrong)`)},
+ {weak: true, pattern: regexp.MustCompile(`: final link failed: `)},
+ {weak: true, pattern: regexp.MustCompile(`collect2: error: `)},
+ {weak: true, pattern: regexp.MustCompile(`FAILED: Build did NOT complete`)},
}
var fileRes = []*regexp.Regexp{
diff --git a/pkg/build/build_test.go b/pkg/build/build_test.go
index 3c7e815dd..50a2bb9a0 100644
--- a/pkg/build/build_test.go
+++ b/pkg/build/build_test.go
@@ -482,4 +482,30 @@ make: *** [bzImage] Error 2
"",
"",
},
+ {`
+ HOSTCC scripts/basic/fixdep
+ HOSTCC scripts/kconfig/conf.o
+ HOSTCC scripts/kconfig/confdata.o
+ HOSTCC scripts/kconfig/expr.o
+ LEX scripts/kconfig/lexer.lex.c
+ YACC scripts/kconfig/parser.tab.[ch]
+ HOSTCC scripts/kconfig/preprocess.o
+ HOSTCC scripts/kconfig/symbol.o
+ HOSTCC scripts/kconfig/util.o
+ HOSTCC scripts/kconfig/lexer.lex.o
+ HOSTCC scripts/kconfig/parser.tab.o
+ HOSTLD scripts/kconfig/conf
+/usr/bin/env: invalid option -- 'S'
+Try '/usr/bin/env --help' for more information.
+init/Kconfig:39: syntax error
+init/Kconfig:38: invalid statement
+scripts/kconfig/Makefile:71: recipe for target 'oldconfig' failed
+make[1]: *** [oldconfig] Error 1
+Makefile:602: recipe for target 'oldconfig' failed
+make: *** [oldconfig] Error 2
+`,
+ "init/Kconfig:39: syntax error\ninit/Kconfig:38: invalid statement",
+ "",
+ "init/Kconfig",
+ },
}