Skip to content

Commit 53ae148

Browse files
Add test related to the changes
1 parent 372ed13 commit 53ae148

File tree

7 files changed

+52
-0
lines changed

7 files changed

+52
-0
lines changed

internal/integrationtest/compile_3/compile_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,48 @@ func TestCompilerErrOutput(t *testing.T) {
116116
compilerErr := requirejson.Parse(t, out).Query(".compiler_err")
117117
compilerErr.MustContain(`"error"`)
118118
}
119+
120+
func TestCompileRelativeLibraryPath(t *testing.T) {
121+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
122+
defer env.CleanUp()
123+
124+
// Initialize configs to enable --zip-path flag
125+
_, _, err := cli.Run("config", "init", "--dest-dir", ".")
126+
require.NoError(t, err)
127+
_, _, err = cli.Run("config", "set", "library.enable_unsafe_install", "true", "--config-file", "arduino-cli.yaml")
128+
require.NoError(t, err)
129+
configFile := cli.WorkingDir().Join("arduino-cli.yaml")
130+
131+
_, _, err = cli.Run("core", "install", "arduino:avr")
132+
require.NoError(t, err)
133+
134+
// Install library and its dependencies
135+
zipPath, err := paths.New("..", "testdata", "FooLib.zip").Abs()
136+
require.NoError(t, err)
137+
_, _, err = cli.Run("lib", "install", "--zip-path", zipPath.String(), "--config-file", configFile.String())
138+
require.NoError(t, err)
139+
140+
// Uninstall library
141+
_, _, err = cli.Run("lib", "uninstall", "FooLib")
142+
require.NoError(t, err)
143+
144+
// Manually install the library and move into one of the example's directories
145+
FooLib := cli.WorkingDir().Join("FooLib")
146+
err = paths.New("..", "testdata", "FooLib").CopyDirTo(FooLib)
147+
require.NoError(t, err)
148+
cli.SetWorkingDir(FooLib.Join("examples", "FooSketch"))
149+
150+
// Compile using a relative path to the library
151+
_, _, err = cli.Run("compile", "-b", "arduino:avr:uno", "--library", "../../")
152+
require.NoError(t, err)
153+
154+
// Install the same library using lib install and compile again using the relative path.
155+
// The manually installed library should be chosen
156+
_, _, err = cli.Run("lib", "install", "--zip-path", zipPath.String(), "--config-file", configFile.String())
157+
require.NoError(t, err)
158+
stdout, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "--library", "../../", "-v")
159+
require.NoError(t, err)
160+
require.Contains(t, string(stdout), "Multiple libraries were found for \"FooLib.h\"")
161+
require.Contains(t, string(stdout), "Used: "+FooLib.String())
162+
require.Contains(t, string(stdout), "Not used: "+cli.SketchbookDir().Join("libraries", "FooLib").String())
163+
}
1.25 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// This file intentionally left empty.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// This file intentionally left empty.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// This file intentionally left empty.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// This file intentionally left empty.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include <FooLib.h>
2+
void setup() {}
3+
void loop() {}

0 commit comments

Comments
 (0)