Unverified Commit 319dede4 authored by Umberto Baldi's avatar Umberto Baldi Committed by GitHub

Package index is now downloaded automatically when is required (#908)

* fix wrong assert in other test

* add automatic `core update-index` when `package_insex.json` are not there
parent 30365362
......@@ -80,6 +80,40 @@ func getInitResponse() (*rpc.InitResp, error) {
resp.PlatformsIndexErrors = rescanResp.PlatformsIndexErrors
}
// Init() succeeded but there were errors loading platform indexes,
// let's rescan and try again
if resp.GetPlatformsIndexErrors() != nil {
// log each error
for _, err := range resp.GetPlatformsIndexErrors() {
logrus.Errorf("Error loading platform index: %v", err)
}
// update platform index
_, err := commands.UpdateIndex(context.Background(),
&rpc.UpdateIndexReq{Instance: resp.GetInstance()}, output.ProgressBar())
if err != nil {
return nil, errors.Wrap(err, "updating the core index")
}
// rescan
rescanResp, err := commands.Rescan(resp.GetInstance().GetId())
if err != nil {
return nil, errors.Wrap(err, "during rescan")
}
// errors persist
if rescanResp.GetPlatformsIndexErrors() != nil {
for _, err := range rescanResp.GetPlatformsIndexErrors() {
logrus.Errorf("Still errors after rescan: %v", err)
}
}
// succeeded, copy over PlatformsIndexErrors in case errors occurred
// during rescan
resp.PlatformsIndexErrors = rescanResp.PlatformsIndexErrors
}
return resp, nil
}
......
......@@ -449,5 +449,5 @@ def test_board_details_no_flags(run_command):
assert result.ok
result = run_command("board details")
assert not result.ok
assert "Error getting board details: parsing fqbn: invalid fqbn:"
assert "Error getting board details: parsing fqbn: invalid fqbn:" in result.stderr
assert result.stdout == ""
......@@ -99,6 +99,14 @@ def test_core_updateindex_invalid_url(run_command):
assert result.failed
def test_core_install_without_updateindex(run_command):
# Missing "core update-index"
# Download samd core pinned to 1.8.6
result = run_command("core install arduino:samd@1.8.6")
assert result.ok
assert "Updating index: package_index.json downloaded" in result.stdout
@pytest.mark.skipif(
platform.system() == "Windows", reason="core fails with fatal error: bits/c++config.h: No such file or directory",
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment