Skip to content

Commit af162f1

Browse files
committed
Added integration tests
1 parent d343ee5 commit af162f1

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed
+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// This file is part of arduino-cli.
2+
//
3+
// Copyright 2022 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+
"go.bug.st/testifyjson/requirejson"
25+
)
26+
27+
func TestCompileLibrarySelection(t *testing.T) {
28+
// See: https://github.com/arduino/arduino-cli/issues/2106
29+
30+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
31+
defer env.CleanUp()
32+
33+
// Run update-index with our test index
34+
_, _, err := cli.Run("core", "install", "arduino:[email protected]")
35+
require.NoError(t, err)
36+
37+
// Prepare sketchbook and sketch
38+
sketchBook, err := paths.New("testdata", "sketchbook_for_testing_lib_priorities").Abs()
39+
require.NoError(t, err)
40+
vars := map[string]string{"ARDUINO_DIRECTORIES_USER": sketchBook.String()}
41+
42+
sketch := sketchBook.Join("SketchUsingLibraryA")
43+
anotherLib := sketchBook.Join("libraries", "AnotherLibrary")
44+
45+
// Perform two compile:
46+
// - the first should use LibraryA
47+
stdout, _, err := cli.RunWithCustomEnv(vars, "compile", "-b", "arduino:avr:mega", "--format", "json", sketch.String())
48+
require.NoError(t, err)
49+
requirejson.Contains(t, stdout, `{
50+
"builder_result" : {
51+
"used_libraries" : [
52+
{ "name": "LibraryA" }
53+
]
54+
}
55+
}`)
56+
57+
// - the second should use AnotherLibrary (because it was forced by --library)
58+
stdout, _, err = cli.RunWithCustomEnv(vars, "compile", "-b", "arduino:avr:mega", "--library", anotherLib.String(), "--format", "json", sketch.String())
59+
require.NoError(t, err)
60+
requirejson.Contains(t, stdout, `{
61+
"builder_result" : {
62+
"used_libraries" : [
63+
{ "name": "AnotherLibrary" }
64+
]
65+
}
66+
}`)
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include <LibraryA.h>
2+
void setup() {}
3+
void loop() {}

Diff for: internal/integrationtest/compile_3/testdata/sketchbook_for_testing_lib_priorities/libraries/AnotherLibrary/LibraryA.h

Whitespace-only changes.

Diff for: internal/integrationtest/compile_3/testdata/sketchbook_for_testing_lib_priorities/libraries/LibraryA/LibraryA.h

Whitespace-only changes.

0 commit comments

Comments
 (0)