Skip to content

improved regexp to also parse error messages with single quotes around header file name #2782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use a more strict regexp / fix unit-test
  • Loading branch information
cmaglie committed Jan 7, 2025
commit fea0d5b5d301900b6f3e1f51a4267d699a57330d
3 changes: 1 addition & 2 deletions internal/arduino/builder/internal/detector/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,7 @@ func (l *SketchLibrariesDetector) failIfImportedLibraryIsWrong() error {
return nil
}

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

// IncludesFinderWithRegExp fixdoc
func IncludesFinderWithRegExp(source string) string {
Expand Down
6 changes: 3 additions & 3 deletions internal/arduino/builder/internal/detector/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ func TestIncludesFinderWithRegExpPaddedIncludes4(t *testing.T) {
}

func TestIncludesFinderWithRegExpPaddedIncludes5(t *testing.T) {
output := "/some/path/sketch.ino:23:42: fatal error: 'Foobar.h' file not found" +
" 23 | #include \"Foobar.h\"" +
" | ^~~~~~~~~~"
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)

Expand Down
Loading