-
-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added integration tests for all default_profile cases
- Loading branch information
Showing
5 changed files
with
95 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -20,6 +20,7 @@ import ( | |
|
||
"github.com/arduino/arduino-cli/internal/integrationtest" | ||
"github.com/stretchr/testify/require" | ||
"go.bug.st/testifyjson/requirejson" | ||
) | ||
|
||
func TestCompileWithProfiles(t *testing.T) { | ||
|
@@ -78,16 +79,74 @@ func TestCompileWithDefaultProfile(t *testing.T) { | |
_, _, err := cli.Run("core", "update-index") | ||
require.NoError(t, err) | ||
|
||
// copy sketch_with_profile into the working directory | ||
sketchPath := cli.CopySketch("sketch_with_profile") | ||
|
||
// compile using the default profile with its fqbn | ||
stdout, _, err := cli.Run("compile", sketchPath.String()) | ||
// Installa core/libs globally | ||
_, _, err = cli.Run("core", "install", "arduino:[email protected]") | ||
require.NoError(t, err) | ||
require.Contains(t, string(stdout), "arduino:avr") | ||
|
||
// compile using a different fbqn -> should have priority over the one in the default profile | ||
stdout, _, err = cli.Run("compile", "-b", "arduino:samd:mkr1000", sketchPath.String()) | ||
require.NoError(t, err) | ||
require.Contains(t, string(stdout), "arduino:samd") | ||
// copy sketch_with_profile into the working directory | ||
sketchWithoutDefProfilePath := cli.CopySketch("sketch_without_default_profile") | ||
sketchWithDefProfilePath := cli.CopySketch("sketch_with_default_profile") | ||
|
||
{ | ||
// no default profile -> error missing FQBN | ||
_, _, err := cli.Run("compile", sketchWithoutDefProfilePath.String(), "--format", "json") | ||
require.Error(t, err) | ||
} | ||
{ | ||
// specified fbqn -> compile with specified FQBN and use global installation | ||
stdout, _, err := cli.Run("compile", "-b", "arduino:avr:nano", sketchWithoutDefProfilePath.String(), "--format", "json") | ||
require.NoError(t, err) | ||
jsonOut := requirejson.Parse(t, stdout) | ||
jsonOut.Query(".builder_result.build_platform").MustContain(`{"id":"arduino:avr", "version":"1.8.3"}`) | ||
jsonOut.Query(".builder_result.build_properties").MustContain(`[ "build.fqbn=arduino:avr:nano" ]`) | ||
} | ||
{ | ||
// specified profile -> use the specified profile | ||
stdout, _, err := cli.Run("compile", "--profile", "avr1", sketchWithoutDefProfilePath.String(), "--format", "json") | ||
require.NoError(t, err) | ||
jsonOut := requirejson.Parse(t, stdout) | ||
jsonOut.Query(".builder_result.build_platform").MustContain(`{"id":"arduino:avr", "version":"1.8.4"}`) | ||
jsonOut.Query(".builder_result.build_properties").MustContain(`[ "build.fqbn=arduino:avr:uno" ]`) | ||
} | ||
{ | ||
// specified profile and fqbn -> use the specified profile and override fqbn | ||
stdout, _, err := cli.Run("compile", "--profile", "avr1", "-b", "arduino:avr:nano", sketchWithoutDefProfilePath.String(), "--format", "json") | ||
require.NoError(t, err) | ||
jsonOut := requirejson.Parse(t, stdout) | ||
jsonOut.Query(".builder_result.build_platform").MustContain(`{"id":"arduino:avr", "version":"1.8.4"}`) | ||
jsonOut.Query(".builder_result.build_properties").MustContain(`[ "build.fqbn=arduino:avr:nano" ]`) | ||
} | ||
|
||
{ | ||
// default profile -> use default profile | ||
stdout, _, err := cli.Run("compile", sketchWithDefProfilePath.String(), "--format", "json") | ||
require.NoError(t, err) | ||
jsonOut := requirejson.Parse(t, stdout) | ||
jsonOut.Query(".builder_result.build_platform").MustContain(`{"id":"arduino:avr", "version":"1.8.5"}`) | ||
jsonOut.Query(".builder_result.build_properties").MustContain(`[ "build.fqbn=arduino:avr:leonardo" ]`) | ||
} | ||
{ | ||
// default profile, specified fbqn -> use default profile, override fqbn | ||
stdout, _, err := cli.Run("compile", "-b", "arduino:avr:nano", sketchWithDefProfilePath.String(), "--format", "json") | ||
require.NoError(t, err) | ||
jsonOut := requirejson.Parse(t, stdout) | ||
jsonOut.Query(".builder_result.build_platform").MustContain(`{"id":"arduino:avr", "version":"1.8.5"}`) | ||
jsonOut.Query(".builder_result.build_properties").MustContain(`[ "build.fqbn=arduino:avr:nano" ]`) | ||
} | ||
{ | ||
// default profile, specified different profile -> use the specified profile | ||
stdout, _, err := cli.Run("compile", "--profile", "avr1", sketchWithDefProfilePath.String(), "--format", "json") | ||
require.NoError(t, err) | ||
jsonOut := requirejson.Parse(t, stdout) | ||
jsonOut.Query(".builder_result.build_platform").MustContain(`{"id":"arduino:avr", "version":"1.8.4"}`) | ||
jsonOut.Query(".builder_result.build_properties").MustContain(`[ "build.fqbn=arduino:avr:uno" ]`) | ||
} | ||
{ | ||
// default profile, specified different profile and fqbn -> use the specified profile and override fqbn | ||
stdout, _, err := cli.Run("compile", "--profile", "avr1", "-b", "arduino:avr:nano", sketchWithDefProfilePath.String(), "--format", "json") | ||
require.NoError(t, err) | ||
jsonOut := requirejson.Parse(t, stdout) | ||
jsonOut.Query(".builder_result.build_platform").MustContain(`{"id":"arduino:avr", "version":"1.8.4"}`) | ||
jsonOut.Query(".builder_result.build_properties").MustContain(`[ "build.fqbn=arduino:avr:nano" ]`) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
internal/integrationtest/testdata/sketch_with_default_profile/sketch.yaml
This file contains 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,12 @@ | ||
profiles: | ||
avr1: | ||
fqbn: arduino:avr:uno | ||
platforms: | ||
- platform: arduino:avr (1.8.4) | ||
|
||
avr2: | ||
fqbn: arduino:avr:leonardo | ||
platforms: | ||
- platform: arduino:avr (1.8.5) | ||
|
||
default_profile: avr2 |
2 changes: 2 additions & 0 deletions
2
...rnal/integrationtest/testdata/sketch_with_default_profile/sketch_with_default_profile.ino
This file contains 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,2 @@ | ||
void setup() {} | ||
void loop() {} |
10 changes: 10 additions & 0 deletions
10
internal/integrationtest/testdata/sketch_without_default_profile/sketch.yaml
This file contains 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,10 @@ | ||
profiles: | ||
avr1: | ||
fqbn: arduino:avr:uno | ||
platforms: | ||
- platform: arduino:avr (1.8.4) | ||
|
||
avr2: | ||
fqbn: arduino:avr:leonardo | ||
platforms: | ||
- platform: arduino:avr (1.8.5) |
2 changes: 2 additions & 0 deletions
2
...ntegrationtest/testdata/sketch_without_default_profile/sketch_without_default_profile.ino
This file contains 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,2 @@ | ||
void setup() {} | ||
void loop() {} |