|
| 1 | +// This file is part of arduino-cli. |
| 2 | +// |
| 3 | +// Copyright 2023 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 | + "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 TestDumpProfileClean(t *testing.T) { |
| 28 | + env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) |
| 29 | + t.Cleanup(env.CleanUp) |
| 30 | + |
| 31 | + // Install Arduino AVR Boards |
| 32 | + _, _, err := cli. Run( "core", "install", "arduino:[email protected]") |
| 33 | + require.NoError(t, err) |
| 34 | + |
| 35 | + validSketchPath, err := paths.New("testdata", "ValidSketch").Abs() |
| 36 | + require.NoError(t, err) |
| 37 | + invalidSketchPath, err := paths.New("testdata", "InvalidSketch").Abs() |
| 38 | + require.NoError(t, err) |
| 39 | + |
| 40 | + validProfile := `profiles: |
| 41 | + uno: |
| 42 | + fqbn: arduino:avr:uno |
| 43 | + platforms: |
| 44 | + - platform: arduino:avr (1.8.6)` |
| 45 | + t.Run("NoVerbose", func(t *testing.T) { |
| 46 | + stdout, stderr, err := cli.Run("compile", "-b", "arduino:avr:uno", validSketchPath.String(), "--dump-profile") |
| 47 | + require.NoError(t, err) |
| 48 | + require.Empty(t, stderr) |
| 49 | + profile := strings.TrimSpace(string(stdout)) |
| 50 | + require.Equal(t, validProfile, profile) |
| 51 | + }) |
| 52 | + t.Run("Verbose", func(t *testing.T) { |
| 53 | + stdout, stderr, err := cli.Run("compile", "-b", "arduino:avr:uno", validSketchPath.String(), "--dump-profile", "--verbose") |
| 54 | + require.NoError(t, err) |
| 55 | + require.Empty(t, stderr) |
| 56 | + profile := strings.TrimSpace(string(stdout)) |
| 57 | + require.Equal(t, validProfile, profile) |
| 58 | + }) |
| 59 | + t.Run("ErrorNoVerbose", func(t *testing.T) { |
| 60 | + stdout, stderr, err := cli.Run("compile", "-b", "arduino:avr:uno", invalidSketchPath.String(), "--dump-profile") |
| 61 | + require.Error(t, err) |
| 62 | + require.NotEmpty(t, stderr) |
| 63 | + require.NotContains(t, string(stdout), validProfile) |
| 64 | + }) |
| 65 | + t.Run("ErrorVerbose", func(t *testing.T) { |
| 66 | + stdout, stderr, err := cli.Run("compile", "-b", "arduino:avr:uno", invalidSketchPath.String(), "--dump-profile", "--verbose") |
| 67 | + require.Error(t, err) |
| 68 | + require.NotEmpty(t, stderr) |
| 69 | + require.NotContains(t, string(stdout), validProfile) |
| 70 | + }) |
| 71 | +} |
0 commit comments