Skip to content

Commit 634d074

Browse files
committed
Added integration tests
1 parent 34ff479 commit 634d074

File tree

6 files changed

+93
-0
lines changed

6 files changed

+93
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// This file is part of arduino-cli.
2+
//
3+
// Copyright 2022-2025 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 license@arduino.cc.
15+
16+
package sketch_test
17+
18+
import (
19+
"strings"
20+
"testing"
21+
22+
"github.com/arduino/arduino-cli/internal/integrationtest"
23+
"github.com/arduino/go-paths-helper"
24+
"github.com/stretchr/testify/require"
25+
)
26+
27+
func TestSketchProfileDump(t *testing.T) {
28+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
29+
defer env.CleanUp()
30+
31+
sketch, err := paths.New("testdata", "SketchWithLibrary").Abs()
32+
require.NoError(t, err)
33+
34+
_, _, err = cli.Run("core", "install", "arduino:avr@1.8.6")
35+
require.NoError(t, err)
36+
_, _, err = cli.Run("lib", "install", "Adafruit BusIO@1.17.1")
37+
require.NoError(t, err)
38+
_, _, err = cli.Run("lib", "install", "Adafruit GFX Library@1.12.1")
39+
require.NoError(t, err)
40+
_, _, err = cli.Run("lib", "install", "Adafruit SSD1306@2.5.14")
41+
require.NoError(t, err)
42+
43+
// Check if the profile dump:
44+
// - keeps libraries in the sketch with a relative path
45+
// - keeps libraries outside the sketch with an absolute path
46+
// - keeps libraries installed in the system with just the name and version
47+
libOutside := sketch.Join("..", "MyLibOutside")
48+
out, _, err := cli.Run("compile", "-b", "arduino:avr:uno",
49+
"--library", sketch.Join("libraries", "MyLib").String(),
50+
"--library", libOutside.String(),
51+
"--dump-profile",
52+
sketch.String())
53+
require.NoError(t, err)
54+
require.Equal(t, strings.TrimSpace(`
55+
profiles:
56+
uno:
57+
fqbn: arduino:avr:uno
58+
platforms:
59+
- platform: arduino:avr (1.8.6)
60+
libraries:
61+
- dir: libraries/MyLib
62+
- dir: `+libOutside.String()+`
63+
- Adafruit SSD1306 (2.5.14)
64+
- Adafruit GFX Library (1.12.1)
65+
- Adafruit BusIO (1.17.1)
66+
`), strings.TrimSpace(string(out)))
67+
}

internal/integrationtest/sketch/testdata/MyLibOutside/MyLibOutside.h

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=MyLibOutside
2+
version=1.3.7
3+
author=Arduino
4+
maintainer=Arduino <info@arduino.cc>
5+
sentence=
6+
paragraph=
7+
category=Communication
8+
url=
9+
architectures=*
10+
includes=MyLibOutside.h
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <MyLib.h>
2+
#include <MyLibOutside.h>
3+
#include <Adafruit_SSD1306.h>
4+
5+
void setup() {}
6+
void loop() {}

internal/integrationtest/sketch/testdata/SketchWithLibrary/libraries/MyLib/MyLib.h

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=MyLib
2+
version=1.3.7
3+
author=Arduino
4+
maintainer=Arduino <info@arduino.cc>
5+
sentence=
6+
paragraph=
7+
category=Communication
8+
url=
9+
architectures=*
10+
includes=MyLib.h

0 commit comments

Comments
 (0)