Skip to content

Commit

Permalink
ported CheckBuildOptionsFile from legacy into integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed Sep 14, 2023
1 parent 7c8dddb commit fe86e78
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 131 deletions.
59 changes: 59 additions & 0 deletions internal/integrationtest/compile_4/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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"`)
}
131 changes: 0 additions & 131 deletions legacy/builder/test/store_build_options_map_test.go

This file was deleted.

0 comments on commit fe86e78

Please sign in to comment.