Skip to content

Commit 2f0db25

Browse files
Fail when sketch files cannot be opened during load
Before commit e7d4eaa ([breaking] Refactor codebase to use a single Sketch struct (#1353)), any sketch file that could not be opened would report a fatal error, but the behavior was changed to silently skip such failing files instead. This restores the original behavior and fails to load a sketch of some of the contained files (after filtering on file extension, so this only includes files that are actually intended to be processed), instead of silently excluding the files (which likely produces hard to explain compilation errors later).
1 parent 38f72ef commit 2f0db25

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Diff for: arduino/sketch/sketch.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func New(path *paths.Path) (*Sketch, error) {
115115
// Skip files that can't be opened
116116
f, err := p.Open()
117117
if err != nil {
118-
continue
118+
return nil, err
119119
}
120120
f.Close()
121121

Diff for: test/test_compile.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,16 @@ def test_broken_symlink(sketch_name, link_name, target_name, expect_error):
217217
result = run_command(["compile", "-b", fqbn, sketch_path])
218218

219219
if expect_error:
220-
expected_error = "Error during build: Can't open sketch: stat {}: ".format(symlink_file)
220+
expected_error = "Error during build: Can't open sketch: open {}: ".format(symlink_file)
221221
assert expected_error in result.stderr
222222
assert not result.ok
223223
else:
224224
assert result.ok
225225

226-
test_broken_symlink("CompileIntegrationTestSymlinkBrokenIno", "link.ino", "doesnotexist.ino", expect_error=False)
227-
test_broken_symlink("CompileIntegrationTestSymlinkBrokenCpp", "link.cpp", "doesnotexist.cpp", expect_error=False)
228-
test_broken_symlink("CompileIntegrationTestSymlinkBrokenH", "link.h", "doesnotexist.h", expect_error=False)
229-
test_broken_symlink("CompileIntegrationTestSymlinkBrokenJson", "link.json", "doesnotexist.json", expect_error=False)
226+
test_broken_symlink("CompileIntegrationTestSymlinkBrokenIno", "link.ino", "doesnotexist.ino", expect_error=True)
227+
test_broken_symlink("CompileIntegrationTestSymlinkBrokenCpp", "link.cpp", "doesnotexist.cpp", expect_error=True)
228+
test_broken_symlink("CompileIntegrationTestSymlinkBrokenH", "link.h", "doesnotexist.h", expect_error=True)
229+
test_broken_symlink("CompileIntegrationTestSymlinkBrokenJson", "link.json", "doesnotexist.json", expect_error=True)
230230
test_broken_symlink("CompileIntegrationTestSymlinkBrokenXXX", "link.xxx", "doesnotexist.xxx", expect_error=False)
231231

232232

0 commit comments

Comments
 (0)