Skip to content

Commit 27f9b05

Browse files
use feedback.PrintResult instead of using fatal
1 parent 074965d commit 27f9b05

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

Diff for: internal/cli/core/upgrade.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func Upgrade(inst *rpc.Instance, args []string, skipPostInstall bool) {
110110
warningMissingIndex(response)
111111
if err != nil {
112112
if _, ok := err.(*arduino.PlatformAlreadyAtTheLatestVersionError); ok {
113-
feedback.Fatal(err.Error(), feedback.Success)
113+
feedback.Warning(err.Error())
114114
continue
115115
}
116116

@@ -121,4 +121,19 @@ func Upgrade(inst *rpc.Instance, args []string, skipPostInstall bool) {
121121
if hasBadArguments {
122122
feedback.Fatal(tr("Some upgrades failed, please check the output for details."), feedback.ErrBadArgument)
123123
}
124+
125+
feedback.PrintResult(&platformUpgradeResult{})
126+
}
127+
128+
// This is needed so we can print warning messages in case users use --format json
129+
type platformUpgradeResult struct{}
130+
131+
// Data implements feedback.Result.
132+
func (r *platformUpgradeResult) Data() interface{} {
133+
return r
134+
}
135+
136+
// String implements feedback.Result.
137+
func (r *platformUpgradeResult) String() string {
138+
return ""
124139
}

Diff for: internal/integrationtest/core/core_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1041,16 +1041,16 @@ func TestCoreUpgradeWarningWithPackageInstalledButNotIndexed(t *testing.T) {
10411041
_, _, err = cli.Run("core", "install", "test:[email protected]", "--additional-urls="+url)
10421042
require.NoError(t, err)
10431043
//upgrade without index fires a warning
1044-
_, jsonStderr, _ := cli.Run("core", "upgrade", "test:x86", "--format", "json")
1045-
requirejson.Query(t, jsonStderr, ".warnings[]", `"missing package index for test:x86, future updates cannot be guaranteed"`)
1044+
jsonStdout, _, _ := cli.Run("core", "upgrade", "test:x86", "--format", "json")
1045+
requirejson.Query(t, jsonStdout, ".warnings[]", `"missing package index for test:x86, future updates cannot be guaranteed"`)
10461046
})
10471047

10481048
// removing installed.json
10491049
installedJson := cli.DataDir().Join("packages", "test", "hardware", "x86", "1.0.0", "installed.json")
10501050
require.NoError(t, os.Remove(installedJson.String()))
10511051

10521052
t.Run("missing both installed.json and additional-urls", func(t *testing.T) {
1053-
_, jsonStderr, _ := cli.Run("core", "upgrade", "test:x86", "--format", "json")
1054-
requirejson.Query(t, jsonStderr, ".warnings[]", `"missing package index for test:x86, future updates cannot be guaranteed"`)
1053+
jsonStdout, _, _ := cli.Run("core", "upgrade", "test:x86", "--format", "json")
1054+
requirejson.Query(t, jsonStdout, ".warnings[]", `"missing package index for test:x86, future updates cannot be guaranteed"`)
10551055
})
10561056
}

0 commit comments

Comments
 (0)