-
-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed compile error when sketch has a broken symlink (#2497)
* Removed unneeded pointer * Improved error message * Update go-paths library * Added integration tests * Reduced timeout for symlink-loop tests * Fixed unit tests Previously the unit tests were creating the wrong env to test: internal/arduino/libraries/testdata/TestLib ├── examples │ ├── UpGoer1 -> testdata/TestLib │ └── UpGoer2 -> testdata/TestLib ├── library.properties └── src └── TestLib.h The two UpGoer1 and UpGoer2 are broken links. The correct tree is the following: internal/arduino/libraries/testdata/TestLib ├── examples │ ├── UpGoer1 -> .. │ └── UpGoer2 -> .. ├── library.properties └── src └── TestLib.h that actually triggers the symlink loop we are testing. * Fixed integration test * Removed apparently useless check for "readable" files
- Loading branch information
Showing
14 changed files
with
104 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// This file is part of arduino-cli. | ||
// | ||
// Copyright 2023 ARDUINO SA (http://www.arduino.cc/) | ||
// | ||
// This software is released under the GNU General Public License version 3, | ||
// which covers the main part of arduino-cli. | ||
// The terms of this license can be found at: | ||
// https://www.gnu.org/licenses/gpl-3.0.en.html | ||
// | ||
// You can be released from the requirements of the above licenses by purchasing | ||
// a commercial license. Buying such a license is mandatory if you want to | ||
// modify or otherwise use the software for commercial activities involving the | ||
// Arduino software without disclosing the source code of your own applications. | ||
// To purchase a commercial license, send an email to [email protected]. | ||
|
||
package compile_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/arduino/arduino-cli/internal/integrationtest" | ||
"github.com/arduino/go-paths-helper" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCompileWithBrokenSymLinks(t *testing.T) { | ||
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) | ||
t.Cleanup(env.CleanUp) | ||
|
||
// Install Arduino AVR Boards | ||
_, _, err := cli.Run("core", "install", "arduino:[email protected]") | ||
require.NoError(t, err) | ||
|
||
t.Run("NonSketchFileBroken", func(t *testing.T) { | ||
sketch, err := paths.New("testdata", "ValidSketchWithBrokenSymlink").Abs() | ||
require.NoError(t, err) | ||
_, _, err = cli.Run("compile", "-b", "arduino:avr:uno", sketch.String()) | ||
require.NoError(t, err) | ||
}) | ||
|
||
t.Run("SketchFileBroken", func(t *testing.T) { | ||
sketch, err := paths.New("testdata", "ValidSketchWithBrokenSketchFileSymlink").Abs() | ||
require.NoError(t, err) | ||
_, _, err = cli.Run("compile", "-b", "arduino:avr:uno", sketch.String()) | ||
require.Error(t, err) | ||
}) | ||
|
||
t.Run("NonInoSketchFileBroken", func(t *testing.T) { | ||
sketch, err := paths.New("testdata", "ValidSketchWithNonInoBrokenSketchFileSymlink").Abs() | ||
require.NoError(t, err) | ||
_, _, err = cli.Run("compile", "-b", "arduino:avr:uno", sketch.String()) | ||
require.Error(t, err) | ||
}) | ||
} |
2 changes: 2 additions & 0 deletions
2
...estdata/ValidSketchWithBrokenSketchFileSymlink/ValidSketchWithBrokenSketchFileSymlink.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
void setup() {} | ||
void loop() {} |
1 change: 1 addition & 0 deletions
1
.../integrationtest/compile_4/testdata/ValidSketchWithBrokenSketchFileSymlink/other_file.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
broken |
2 changes: 2 additions & 0 deletions
2
...tiontest/compile_4/testdata/ValidSketchWithBrokenSymlink/ValidSketchWithBrokenSymlink.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
void setup() {} | ||
void loop() {} |
1 change: 1 addition & 0 deletions
1
internal/integrationtest/compile_4/testdata/ValidSketchWithBrokenSymlink/other_file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
broken |
2 changes: 2 additions & 0 deletions
2
...dSketchWithNonInoBrokenSketchFileSymlink/ValidSketchWithNonInoBrokenSketchFileSymlink.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
void setup() {} | ||
void loop() {} |
1 change: 1 addition & 0 deletions
1
...egrationtest/compile_4/testdata/ValidSketchWithNonInoBrokenSketchFileSymlink/other_file.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
broken |