Skip to content

Commit fea0d5b

Browse files
committed
Use a more strict regexp / fix unit-test
1 parent c47f78b commit fea0d5b

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

internal/arduino/builder/internal/detector/detector.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,7 @@ func (l *SketchLibrariesDetector) failIfImportedLibraryIsWrong() error {
477477
return nil
478478
}
479479

480-
// includeRegexp fixdoc
481-
var includeRegexp = regexp.MustCompile(`#include[ \t]*[<"](\S+)[">]`)
480+
var includeRegexp = regexp.MustCompile(`(?ms)^\s*[0-9 |]*\s*#[ \t]*include\s*[<"](\S+)[">]`)
482481

483482
// IncludesFinderWithRegExp fixdoc
484483
func IncludesFinderWithRegExp(source string) string {

internal/arduino/builder/internal/detector/detector_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ func TestIncludesFinderWithRegExpPaddedIncludes4(t *testing.T) {
7777
}
7878

7979
func TestIncludesFinderWithRegExpPaddedIncludes5(t *testing.T) {
80-
output := "/some/path/sketch.ino:23:42: fatal error: 'Foobar.h' file not found" +
81-
" 23 | #include \"Foobar.h\"" +
82-
" | ^~~~~~~~~~"
80+
output := "/some/path/sketch.ino:23:42: fatal error: 'Foobar.h' file not found\n" +
81+
" 23 | #include \"Foobar.h\"\n" +
82+
" | ^~~~~~~~~~\n"
8383

8484
include := detector.IncludesFinderWithRegExp(output)
8585

0 commit comments

Comments
 (0)