improved error messages parsing (#2782) · arduino/arduino-cli@63bfd5c (original) (raw)

File tree

2 files changed

lines changed

2 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -477,8 +477,7 @@ func (l *SketchLibrariesDetector) failIfImportedLibraryIsWrong() error {
477 477 return nil
478 478 }
479 479
480 -// includeRegexp fixdoc
481 -var includeRegexp = regexp.MustCompile("(?ms)^\\s*#[ \t]*include\\s*[<\"](\\S+)[\">]")
480 +var includeRegexp = regexp.MustCompile(`(?ms)^\s*[0-9 |]*\s*#[ \t]*include\s*[<"](\S+)[">]`)
482 481
483 482 // IncludesFinderWithRegExp fixdoc
484 483 func IncludesFinderWithRegExp(source string) string {
Original file line number Diff line number Diff line change
@@ -75,3 +75,13 @@ func TestIncludesFinderWithRegExpPaddedIncludes4(t *testing.T) {
75 75
76 76 require.Equal(t, "register.h", include)
77 77 }
78 +
79 +func TestIncludesFinderWithRegExpPaddedIncludes5(t *testing.T) {
80 +output := "/some/path/sketch.ino:23:42: fatal error: 'Foobar.h' file not found\n" +
81 +" 23 | #include \"Foobar.h\"\n" +
82 +" | ^~~~~~~~~~\n"
83 +
84 +include := detector.IncludesFinderWithRegExp(output)
85 +
86 +require.Equal(t, "Foobar.h", include)
87 +}