-
-
Notifications
You must be signed in to change notification settings - Fork 405
[skip-changelog] Migrate tests from test_compile_part_3.py
to compile_part_3_test.go
#1906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b31ea08
Migrate TestCompileSketchWithPdeExtension from test_compile_part_3.py…
MatteoPologruto 6482686
Migrate TestCompileSketchWithMultipleMainFiles from test_compile_part…
MatteoPologruto 821a746
Migrate TestCompileSketchCaseMismatchFails from test_compile_part_3.p…
MatteoPologruto 16b29e5
Migrate TestCompileWithOnlyCompilationDatabaseFlag from test_compile_…
MatteoPologruto 33dd1e0
Migrate TestCompileUsingPlatformLocalTxt from test_compile_part_3.py …
MatteoPologruto 1a9f90c
Migrate TestCompileUsingBoardsLocalTxt from test_compile_part_3.py to…
MatteoPologruto 0983d63
Migrate TestCompileManuallyInstalledPlatform from test_compile_part_3…
MatteoPologruto f620c28
Migrate TestCompileManuallyInstalledPlatformUsingPlatformLocalTxt fro…
MatteoPologruto 885aa40
Migrate TestCompileWithFullyPrecompiledLibrary to compile_part_3_test…
MatteoPologruto 8a8df2b
Rearrange tests to have them share the same environment
MatteoPologruto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
internal/integrationtest/compile/compile_part_3_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// This file is part of arduino-cli. | ||
// | ||
// Copyright 2022 ARDUINO SA (http://www.arduino.cc/) | ||
// | ||
// This software is released under the GNU General Public License version 3, | ||
// which covers the main part of arduino-cli. | ||
// The terms of this license can be found at: | ||
// https://www.gnu.org/licenses/gpl-3.0.en.html | ||
// | ||
// You can be released from the requirements of the above licenses by purchasing | ||
// a commercial license. Buying such a license is mandatory if you want to | ||
// modify or otherwise use the software for commercial activities involving the | ||
// Arduino software without disclosing the source code of your own applications. | ||
// To purchase a commercial license, send an email to license@arduino.cc. | ||
|
||
package compile_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/arduino/arduino-cli/internal/integrationtest" | ||
"github.com/arduino/go-paths-helper" | ||
"github.com/stretchr/testify/require" | ||
"gopkg.in/src-d/go-git.v4" | ||
"gopkg.in/src-d/go-git.v4/plumbing" | ||
) | ||
|
||
func TestCompileWithFullyPrecompiledLibrary(t *testing.T) { | ||
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) | ||
defer env.CleanUp() | ||
|
||
_, _, err := cli.Run("update") | ||
require.NoError(t, err) | ||
|
||
_, _, err = cli.Run("core", "install", "arduino:mbed@1.3.1") | ||
require.NoError(t, err) | ||
fqbn := "arduino:mbed:nano33ble" | ||
|
||
// Create settings with library unsafe install set to true | ||
envVar := cli.GetDefaultEnv() | ||
envVar["ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL"] = "true" | ||
_, _, err = cli.RunWithCustomEnv(envVar, "config", "init", "--dest-dir", ".") | ||
require.NoError(t, err) | ||
|
||
// Install fully precompiled library | ||
// For more information see: | ||
// https://arduino.github.io/arduino-cli/latest/library-specification/#precompiled-binaries | ||
wd, err := paths.Getwd() | ||
require.NoError(t, err) | ||
_, _, err = cli.Run("lib", "install", "--zip-path", wd.Parent().Join("testdata", "Arduino_TensorFlowLite-2.1.0-ALPHA-precompiled.zip").String()) | ||
require.NoError(t, err) | ||
sketchFolder := cli.SketchbookDir().Join("libraries", "Arduino_TensorFlowLite-2.1.0-ALPHA-precompiled", "examples", "hello_world") | ||
|
||
// Install example dependency | ||
_, _, err = cli.Run("lib", "install", "Arduino_LSM9DS1") | ||
require.NoError(t, err) | ||
|
||
// Compile and verify dependencies detection for fully precompiled library is skipped | ||
stdout, _, err := cli.Run("compile", "-b", fqbn, sketchFolder.String(), "-v") | ||
require.NoError(t, err) | ||
require.Contains(t, string(stdout), "Skipping dependencies detection for precompiled library Arduino_TensorFlowLite") | ||
} | ||
|
||
func TestCompileManuallyInstalledPlatform(t *testing.T) { | ||
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) | ||
defer env.CleanUp() | ||
|
||
_, _, err := cli.Run("update") | ||
require.NoError(t, err) | ||
|
||
sketchName := "CompileSketchManuallyInstalledPlatformUsingPlatformLocalTxt" | ||
sketchPath := cli.SketchbookDir().Join(sketchName) | ||
fqbn := "arduino-beta-development:avr:uno" | ||
_, _, err = cli.Run("sketch", "new", sketchPath.String()) | ||
require.NoError(t, err) | ||
|
||
// Manually installs a core in sketchbooks hardware folder | ||
gitUrl := "https://github.com/arduino/ArduinoCore-avr.git" | ||
repoDir := cli.SketchbookDir().Join("hardware", "arduino-beta-development", "avr") | ||
_, err = git.PlainClone(repoDir.String(), false, &git.CloneOptions{ | ||
URL: gitUrl, | ||
ReferenceName: plumbing.NewTagReferenceName("1.8.3"), | ||
}) | ||
require.NoError(t, err) | ||
|
||
// Installs also the same core via CLI so all the necessary tools are installed | ||
_, _, err = cli.Run("core", "install", "arduino:avr@1.8.3") | ||
require.NoError(t, err) | ||
|
||
// Verifies compilation works without issues | ||
_, _, err = cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String()) | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestCompileManuallyInstalledPlatformUsingPlatformLocalTxt(t *testing.T) { | ||
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) | ||
defer env.CleanUp() | ||
|
||
_, _, err := cli.Run("update") | ||
require.NoError(t, err) | ||
|
||
sketchName := "CompileSketchManuallyInstalledPlatformUsingPlatformLocalTxt" | ||
sketchPath := cli.SketchbookDir().Join(sketchName) | ||
fqbn := "arduino-beta-development:avr:uno" | ||
_, _, err = cli.Run("sketch", "new", sketchPath.String()) | ||
require.NoError(t, err) | ||
|
||
// Manually installs a core in sketchbooks hardware folder | ||
gitUrl := "https://github.com/arduino/ArduinoCore-avr.git" | ||
repoDir := cli.SketchbookDir().Join("hardware", "arduino-beta-development", "avr") | ||
_, err = git.PlainClone(repoDir.String(), false, &git.CloneOptions{ | ||
URL: gitUrl, | ||
ReferenceName: plumbing.NewTagReferenceName("1.8.3"), | ||
}) | ||
require.NoError(t, err) | ||
|
||
// Installs also the same core via CLI so all the necessary tools are installed | ||
_, _, err = cli.Run("core", "install", "arduino:avr@1.8.3") | ||
require.NoError(t, err) | ||
|
||
// Verifies compilation works without issues | ||
_, _, err = cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String()) | ||
require.NoError(t, err) | ||
|
||
// Overrides default platform compiler with an unexisting one | ||
platformLocalTxt := repoDir.Join("platform.local.txt") | ||
platformLocalTxt.WriteFile([]byte("compiler.c.cmd=my-compiler-that-does-not-exist")) | ||
|
||
// Verifies compilation now fails because compiler is not found | ||
_, stderr, err := cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String()) | ||
require.Error(t, err) | ||
require.Contains(t, string(stderr), "my-compiler-that-does-not-exist") | ||
} |
Binary file added
BIN
+2.8 MB
internal/integrationtest/testdata/Arduino_TensorFlowLite-2.1.0-ALPHA-precompiled.zip
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
nessuno.name=Arduino Nessuno | ||
nessuno.vid.0=0x2341 | ||
nessuno.pid.0=0x0043 | ||
nessuno.vid.1=0x2341 | ||
nessuno.pid.1=0x0001 | ||
nessuno.vid.2=0x2A03 | ||
nessuno.pid.2=0x0043 | ||
nessuno.vid.3=0x2341 | ||
nessuno.pid.3=0x0243 | ||
nessuno.upload.tool=avrdude | ||
nessuno.upload.protocol=arduino | ||
nessuno.upload.maximum_size=32256 | ||
nessuno.upload.maximum_data_size=2048 | ||
nessuno.upload.speed=115200 | ||
nessuno.bootloader.tool=avrdude | ||
nessuno.bootloader.low_fuses=0xFF | ||
nessuno.bootloader.high_fuses=0xDE | ||
nessuno.bootloader.extended_fuses=0xFD | ||
nessuno.bootloader.unlock_bits=0x3F | ||
nessuno.bootloader.lock_bits=0x0F | ||
nessuno.bootloader.file=optiboot/optiboot_atmega328.hex | ||
nessuno.build.mcu=atmega328p | ||
nessuno.build.f_cpu=16000000L | ||
nessuno.build.board=AVR_NESSUNO | ||
umbynos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
nessuno.build.core=arduino | ||
nessuno.build.variant=standard |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.