|
| 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 | +} |
0 commit comments