Skip to content

Commit f793bb1

Browse files
committed
Do not fail if a non-sketch file is a broken symlink
1 parent ee8786a commit f793bb1

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed

Diff for: internal/arduino/sketch/sketch.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,16 @@ func (s *Sketch) supportedFiles() (paths.PathList, error) {
169169
return !p.Join("build.options.json").Exist()
170170
}
171171

172+
filterOutBrokenLinks := func(p *paths.Path) bool {
173+
_, err := p.Stat()
174+
return err == nil
175+
}
176+
172177
files, err := s.FullPath.ReadDirRecursiveFiltered(
173-
filterOutBuildPaths,
178+
paths.AndFilter(
179+
filterOutBrokenLinks,
180+
filterOutBuildPaths,
181+
),
174182
paths.AndFilter(
175183
paths.FilterOutPrefixes("."),
176184
filterValidExtensions,
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// This file is part of arduino-cli.
2+
//
3+
// Copyright 2023 ARDUINO SA (http://www.arduino.cc/)
4+
//
5+
// This software is released under the GNU General Public License version 3,
6+
// which covers the main part of arduino-cli.
7+
// The terms of this license can be found at:
8+
// https://www.gnu.org/licenses/gpl-3.0.en.html
9+
//
10+
// You can be released from the requirements of the above licenses by purchasing
11+
// a commercial license. Buying such a license is mandatory if you want to
12+
// modify or otherwise use the software for commercial activities involving the
13+
// Arduino software without disclosing the source code of your own applications.
14+
// To purchase a commercial license, send an email to [email protected].
15+
16+
package compile_test
17+
18+
import (
19+
"testing"
20+
21+
"github.com/arduino/arduino-cli/internal/integrationtest"
22+
"github.com/arduino/go-paths-helper"
23+
"github.com/stretchr/testify/require"
24+
)
25+
26+
func TestCompileWithBrokenSymLinks(t *testing.T) {
27+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
28+
t.Cleanup(env.CleanUp)
29+
30+
// Install Arduino AVR Boards
31+
_, _, err := cli.Run("core", "install", "arduino:[email protected]")
32+
require.NoError(t, err)
33+
34+
t.Run("NonSketchFileBroken", func(t *testing.T) {
35+
sketch, err := paths.New("testdata", "ValidSketchWithBrokenSymlink").Abs()
36+
require.NoError(t, err)
37+
_, _, err = cli.Run("compile", "-b", "arduino:avr:uno", sketch.String())
38+
require.NoError(t, err)
39+
})
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
void setup() {}
2+
void loop() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
broken
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
broken

0 commit comments

Comments
 (0)