diff --git a/internal/arduino/builder/internal/detector/detector.go b/internal/arduino/builder/internal/detector/detector.go index 17de9377833..eb3d887d3fe 100644 --- a/internal/arduino/builder/internal/detector/detector.go +++ b/internal/arduino/builder/internal/detector/detector.go @@ -477,8 +477,7 @@ func (l *SketchLibrariesDetector) failIfImportedLibraryIsWrong() error { return nil } -// includeRegexp fixdoc -var includeRegexp = regexp.MustCompile("(?ms)^\\s*#[ \t]*include\\s*[<\"](\\S+)[\">]") +var includeRegexp = regexp.MustCompile(`(?ms)^\s*[0-9 |]*\s*#[ \t]*include\s*[<"](\S+)[">]`) // IncludesFinderWithRegExp fixdoc func IncludesFinderWithRegExp(source string) string { diff --git a/internal/arduino/builder/internal/detector/detector_test.go b/internal/arduino/builder/internal/detector/detector_test.go index 6e7f72648a4..dbec95ca918 100644 --- a/internal/arduino/builder/internal/detector/detector_test.go +++ b/internal/arduino/builder/internal/detector/detector_test.go @@ -75,3 +75,13 @@ func TestIncludesFinderWithRegExpPaddedIncludes4(t *testing.T) { require.Equal(t, "register.h", include) } + +func TestIncludesFinderWithRegExpPaddedIncludes5(t *testing.T) { + output := "/some/path/sketch.ino:23:42: fatal error: 'Foobar.h' file not found\n" + + " 23 | #include \"Foobar.h\"\n" + + " | ^~~~~~~~~~\n" + + include := detector.IncludesFinderWithRegExp(output) + + require.Equal(t, "Foobar.h", include) +}