Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3a25147

Browse files
cmaglieper1234
andauthored
Expand property references in version property of platform.txt (#1830)
* Added test for issue #1823 * Do not assume that version in platforms.txt is correct semver * When parsing version in platform.txt perform a variable replace * Update internal/integrationtest/core/testdata/issue_1823/DxCore-dev/megaavr/README.md * Update internal/integrationtest/core/core_list_test.go Co-authored-by: per1234 <accounts@perglass.com>
1 parent 869c971 commit 3a25147

File tree

6 files changed

+3463
-1
lines changed

6 files changed

+3463
-1
lines changed

‎arduino/cores/packagemanager/loader.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"strconv"
2424
"strings"
2525

26+
"github.com/arduino/arduino-cli/arduino"
2627
"github.com/arduino/arduino-cli/arduino/cores"
2728
"github.com/arduino/arduino-cli/arduino/discovery"
2829
"github.com/arduino/arduino-cli/configuration"
@@ -196,7 +197,11 @@ func (pm *PackageManager) loadPlatform(targetPackage *cores.Package, architectur
196197
return fmt.Errorf("%s: %w", tr("loading platform.txt"), err)
197198
}
198199

199-
version := semver.MustParse(platformProperties.Get("version"))
200+
versionString := platformProperties.ExpandPropsInString(platformProperties.Get("version"))
201+
version, err := semver.Parse(versionString)
202+
if err != nil {
203+
return &arduino.InvalidVersionError{Cause: fmt.Errorf("%s: %s", platformTxtPath, err)}
204+
}
200205

201206
// Check if package_bundled_index.json exists.
202207
// This is used indirectly by the Java IDE since it's necessary for the arduino-builder
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 license@arduino.cc.
15+
16+
package core_test
17+
18+
import (
19+
"testing"
20+
21+
"github.com/arduino/arduino-cli/internal/integrationtest"
22+
"github.com/arduino/go-paths-helper"
23+
"github.com/stretchr/testify/require"
24+
"go.bug.st/testsuite"
25+
"go.bug.st/testsuite/requirejson"
26+
)
27+
28+
func TestCorrectHandlingOfPlatformVersionProperty(t *testing.T) {
29+
// See: https://github.com/arduino/arduino-cli/issues/1823
30+
31+
env := testsuite.NewEnvironment(t)
32+
defer env.CleanUp()
33+
34+
cli := integrationtest.NewArduinoCliWithinEnvironment(env, &integrationtest.ArduinoCLIConfig{
35+
ArduinoCLIPath: paths.New("..", "..", "..", "arduino-cli"),
36+
UseSharedStagingFolder: true,
37+
})
38+
39+
// Copy test platform
40+
testPlatform := paths.New("testdata", "issue_1823", "DxCore-dev")
41+
require.NoError(t, testPlatform.CopyDirTo(cli.SketchbookDir().Join("hardware", "DxCore-dev")))
42+
43+
// Trigger problematic call
44+
out, _, err := cli.Run("core", "list", "--format", "json")
45+
require.NoError(t, err)
46+
requirejson.Contains(t, out, `[{"id":"DxCore-dev:megaavr","installed":"1.4.10","name":"DxCore"}]`)
47+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is an extract of https://github.com/SpenceKonde/DxCore at the revision 1.4.10.
2+
3+
https://github.com/SpenceKonde/DxCore/commit/b0bb30f8cb703991d3fe97a3241091a221eab09b

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /