-
-
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.
ported CheckBuildOptionsFile from legacy into integration test
- Loading branch information
1 parent
7c8dddb
commit fe86e78
Showing
2 changed files
with
59 additions
and
131 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 |
---|---|---|
|
@@ -28,6 +28,7 @@ import ( | |
"github.com/arduino/arduino-cli/internal/integrationtest" | ||
"github.com/arduino/go-paths-helper" | ||
"github.com/stretchr/testify/require" | ||
"go.bug.st/testifyjson/requirejson" | ||
"golang.org/x/exp/slices" | ||
) | ||
|
||
|
@@ -954,3 +955,61 @@ func TestMergeSketchWithBootloader(t *testing.T) { | |
require.Contains(t, mergedSketchHex, ":100000000C9434000C9446000C9446000C9446006A\n") | ||
require.True(t, strings.HasSuffix(mergedSketchHex, ":00000001FF\n")) | ||
} | ||
|
||
func TestBuildOptionsFile(t *testing.T) { | ||
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) | ||
defer env.CleanUp() | ||
|
||
sketchPath := cli.CopySketch("sketch_simple") | ||
defer sketchPath.RemoveAll() | ||
|
||
_, _, err := cli.Run("core", "install", "arduino:[email protected]") | ||
require.NoError(t, err) | ||
|
||
buildPath, err := paths.MkTempDir("", "arduino-integration-test") | ||
require.NoError(t, err) | ||
defer buildPath.RemoveAll() | ||
|
||
// Build first time | ||
_, _, err = cli.Run("compile", "-b", "arduino:avr:uno", "--build-path", buildPath.String(), sketchPath.String()) | ||
require.NoError(t, err) | ||
|
||
exist, err := buildPath.Join("build.options.json").ExistCheck() | ||
require.NoError(t, err) | ||
require.True(t, exist) | ||
|
||
buildOptionsBytes, err := buildPath.Join("build.options.json").ReadFile() | ||
require.NoError(t, err) | ||
|
||
requirejson.Query(t, buildOptionsBytes, "keys", `[ | ||
"additionalFiles", | ||
"builtInToolsFolders", | ||
"compiler.optimization_flags", | ||
"customBuildProperties", | ||
"fqbn", | ||
"hardwareFolders", | ||
"otherLibrariesFolders", | ||
"sketchLocation" | ||
]`) | ||
requirejson.Query(t, buildOptionsBytes, ".fqbn", `"arduino:avr:uno"`) | ||
requirejson.Query(t, buildOptionsBytes, ".customBuildProperties", `"build.warn_data_percentage=75"`) | ||
|
||
// Recompiling a second time should provide the same result | ||
_, _, err = cli.Run("compile", "-b", "arduino:avr:uno", "--build-path", buildPath.String(), sketchPath.String()) | ||
require.NoError(t, err) | ||
|
||
buildOptionsBytes, err = buildPath.Join("build.options.json").ReadFile() | ||
require.NoError(t, err) | ||
requirejson.Query(t, buildOptionsBytes, ".customBuildProperties", `"build.warn_data_percentage=75"`) | ||
|
||
// Recompiling with a new build option must produce a new `build.options.json` | ||
_, _, err = cli.Run("compile", "-b", "arduino:avr:uno", "--build-path", buildPath.String(), | ||
"--build-property", "custom=prop", | ||
sketchPath.String(), | ||
) | ||
require.NoError(t, err) | ||
|
||
buildOptionsBytes, err = buildPath.Join("build.options.json").ReadFile() | ||
require.NoError(t, err) | ||
requirejson.Query(t, buildOptionsBytes, ".customBuildProperties", `"custom=prop,build.warn_data_percentage=75"`) | ||
} |
This file was deleted.
Oops, something went wrong.