|
| 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 debug_test |
| 17 | + |
| 18 | +import ( |
| 19 | + "testing" |
| 20 | + |
| 21 | + "github.com/arduino/arduino-cli/internal/integrationtest" |
| 22 | + "github.com/stretchr/testify/require" |
| 23 | +) |
| 24 | + |
| 25 | +func TestDebuggerStarts(t *testing.T) { |
| 26 | + env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) |
| 27 | + defer env.CleanUp() |
| 28 | + |
| 29 | + // Init the environment explicitly |
| 30 | + _, _, err := cli.Run("core", "update-index") |
| 31 | + require.NoError(t, err) |
| 32 | + |
| 33 | + // Install cores |
| 34 | + _, _, err = cli.Run("core", "install", "arduino:samd") |
| 35 | + require.NoError(t, err) |
| 36 | + |
| 37 | + // Create sketch for testing |
| 38 | + sketchName := "DebuggerStartTest" |
| 39 | + sketchPath := cli.DataDir().Join(sketchName) |
| 40 | + fqbn := "arduino:samd:mkr1000" |
| 41 | + |
| 42 | + _, _, err = cli.Run("sketch", "new", sketchPath.String()) |
| 43 | + require.NoError(t, err) |
| 44 | + |
| 45 | + // Build sketch |
| 46 | + _, _, err = cli.Run("compile", "-b", fqbn, sketchPath.String()) |
| 47 | + require.NoError(t, err) |
| 48 | + |
| 49 | + programmer := "atmel_ice" |
| 50 | + // Starts debugger |
| 51 | + _, _, err = cli.Run("debug", "-b", fqbn, "-P", programmer, sketchPath.String(), "--info") |
| 52 | + require.NoError(t, err) |
| 53 | +} |
| 54 | + |
| 55 | +func TestDebuggerWithPdeSketchStarts(t *testing.T) { |
| 56 | + env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) |
| 57 | + defer env.CleanUp() |
| 58 | + |
| 59 | + _, _, err := cli.Run("update") |
| 60 | + require.NoError(t, err) |
| 61 | + |
| 62 | + // Install core |
| 63 | + _, _, err = cli.Run("core", "install", "arduino:samd") |
| 64 | + require.NoError(t, err) |
| 65 | + |
| 66 | + sketchName := "DebuggerPdeSketchStartTest" |
| 67 | + sketchPath := cli.DataDir().Join(sketchName) |
| 68 | + fqbn := "arduino:samd:mkr1000" |
| 69 | + |
| 70 | + _, _, err = cli.Run("sketch", "new", sketchPath.String()) |
| 71 | + require.NoError(t, err) |
| 72 | + |
| 73 | + // Looks for sketch file .ino |
| 74 | + pathDir, err := sketchPath.ReadDir() |
| 75 | + require.NoError(t, err) |
| 76 | + fileIno := pathDir[0] |
| 77 | + |
| 78 | + // Renames sketch file to pde |
| 79 | + filePde := sketchPath.Join(sketchName + ".pde") |
| 80 | + err = fileIno.Rename(filePde) |
| 81 | + require.NoError(t, err) |
| 82 | + |
| 83 | + // Build sketch |
| 84 | + _, _, err = cli.Run("compile", "-b", fqbn, filePde.String()) |
| 85 | + require.NoError(t, err) |
| 86 | + |
| 87 | + programmer := "atmel_ice" |
| 88 | + // Starts debugger |
| 89 | + _, _, err = cli.Run("debug", "-b", fqbn, "-P", programmer, filePde.String(), "--info") |
| 90 | + require.NoError(t, err) |
| 91 | +} |
0 commit comments