Skip to content

Commit 444c506

Browse files
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?
1 parent 2f0db25 commit 444c506

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Diff for: arduino/sketch/sketch.go

+8
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ func (s *Sketch) supportedFiles() (*paths.PathList, error) {
166166
}
167167
files.FilterOutDirs()
168168
files.FilterOutHiddenFiles()
169+
// Exclude files named compile_commands.json, to allow the user
170+
// creating a symlink to the autogenerated file in the sketch
171+
// directory, without that being handled or causing failure when
172+
// the target file does not exist yet.
173+
// TODO: This abuses FilterOutSuffix, it should match the
174+
// filename, but go-paths-helper does not support this now.
175+
files.FilterOutSuffix("compile_commands.json")
176+
169177
validExtensions := []string{}
170178
for ext := range globals.MainFileValidExtensions {
171179
validExtensions = append(validExtensions, ext)

Diff for: test/test_compile.py

+9
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,15 @@ def test_broken_symlink(sketch_name, link_name, target_name, expect_error):
228228
test_broken_symlink("CompileIntegrationTestSymlinkBrokenH", "link.h", "doesnotexist.h", expect_error=True)
229229
test_broken_symlink("CompileIntegrationTestSymlinkBrokenJson", "link.json", "doesnotexist.json", expect_error=True)
230230
test_broken_symlink("CompileIntegrationTestSymlinkBrokenXXX", "link.xxx", "doesnotexist.xxx", expect_error=False)
231+
# Support a usecase where a user makes a symlink to
232+
# compile_commands.json in the sketch root, even when it does not
233+
# exist yet/anymore
234+
test_broken_symlink(
235+
"CompileIntegrationTestSymlinkBrokenCompileCommands",
236+
"compile_commands.json",
237+
"doesnotexist.json",
238+
expect_error=False,
239+
)
231240

232241

233242
def test_compile_blacklisted_sketchname(run_command, data_dir):

0 commit comments

Comments
 (0)