8000 Improve handling of read errors during sketch enumeration by matthijskooijman · Pull Request #1438 · arduino/arduino-cli · GitHub
[go: up one dir, main page]

Skip to content

Improve handling of read errors during sketch enumeration #1438

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

Closed
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
Draft: Exclude compile_commands.json from sketch loading
This allows users to create a symlink to the autogenerated file in the
sketch directory, without that file being handled or causing failure
when the target file does not exist yet (or anymore).

Draft: This abuses FilterOutSuffix, it should match the filename, but
go-paths-helper does not support this now.

Draft: Is this really the right place/approach to exclude this file?
  • Loading branch information
matthijskooijman committed Jan 12, 2024
commit 444c506f57ec715e38aa17013d0dab80d506cbad
8 changes: 8 additions & 0 deletions arduino/sketch/sketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ func (s *Sketch) supportedFiles() (*paths.PathList, error) {
}
files.FilterOutDirs()
files.FilterOutHiddenFiles()
// Exclude files named compile_commands.json, to allow the user
// creating a symlink to the autogenerated file in the sketch
// directory, without that being handled or causing failure when
// the target file does not exist yet.
// TODO: This abuses FilterOutSuffix, it should match the
// filename, but go-paths-helper does not support this now.
files.FilterOutSuffix("compile_commands.json")

validExtensions := []string{}
for ext := range globals.MainFileValidExtensions {
validExtensions = append(validExtensions, ext)
Expand Down
9 changes: 9 additions & 0 deletions test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,15 @@ def test_broken_symlink(sketch_name, link_name, target_name, expect_error):
test_broken_symlink("CompileIntegrationTestSymlinkBrokenH", "link.h", "doesnotexist.h", expect_error=True)
test_broken_symlink("CompileIntegrationTestSymlinkBrokenJson", "link.json", "doesnotexist.json", expect_error=True)
test_broken_symlink("CompileIntegrationTestSymlinkBrokenXXX", "link.xxx", "doesnotexist.xxx", expect_error=False)
# Support a usecase where a user makes a symlink to
# compile_commands.json in the sketch root, even when it does not
# exist yet/anymore
test_broken_symlink(
"CompileIntegrationTestSymlinkBrokenCompileCommands",
"compile_commands.json",
"doesnotexist.json",
expect_error=False,
)


def test_compile_blacklisted_sketchname(run_command, data_dir):
Expand Down
0