Unverified Commit c5fe48d4 authored by Silvano Cerza's avatar Silvano Cerza Committed by GitHub

Fix lib upgrade trying to upgrade core bundled libraries (#1580)

parent b28e1390
......@@ -29,7 +29,7 @@ func LibraryUpgradeAll(instanceID int32, downloadCB commands.DownloadProgressCB,
return &arduino.InvalidInstanceError{}
}
if err := upgrade(lm, listLibraries(lm, true, true), downloadCB, taskCB); err != nil {
if err := upgrade(lm, listLibraries(lm, true, false), downloadCB, taskCB); err != nil {
return err
}
......
......@@ -16,6 +16,7 @@ import platform
import simplejson as json
import pytest
import shutil
from git import Repo
from pathlib import Path
import tempfile
......@@ -982,3 +983,67 @@ def test_install_git_invalid_library(run_command, data_dir, downloads_dir):
assert res.failed
assert "library not valid" in res.stderr
assert not lib_install_dir.exists()
def test_upgrade_does_not_try_to_upgrade_bundled_core_libraries_in_sketchbook(run_command, data_dir):
test_platform_name = "platform_with_bundled_library"
platform_install_dir = Path(data_dir, "hardware", "arduino-beta-dev", test_platform_name)
platform_install_dir.mkdir(parents=True)
# Install platform in Sketchbook hardware dir
shutil.copytree(
Path(__file__).parent / "testdata" / test_platform_name,
platform_install_dir,
dirs_exist_ok=True,
)
assert run_command(["update"])
# Install latest version of library identical to one
# bundled with test platform
assert run_command(["lib", "install", "USBHost"])
res = run_command(["lib", "list", "--all", "--format", "json"])
assert res.ok
libs = json.loads(res.stdout)
assert len(libs) == 2
# Verify both libraries have the same name
assert libs[0]["library"]["name"] == "USBHost"
assert libs[1]["library"]["name"] == "USBHost"
res = run_command(["lib", "upgrade"])
assert res.ok
# Empty output means nothing has been updated as expected
assert res.stdout == ""
def test_upgrade_does_not_try_to_upgrade_bundled_core_libraries(run_command, data_dir):
test_platform_name = "platform_with_bundled_library"
platform_install_dir = Path(data_dir, "packages", "arduino", "hardware", "arch", "4.2.0")
platform_install_dir.mkdir(parents=True)
# Simulate installation of a platform with arduino-cli
shutil.copytree(
Path(__file__).parent / "testdata" / test_platform_name,
platform_install_dir,
dirs_exist_ok=True,
)
assert run_command(["update"])
# Install latest version of library identical to one
# bundled with test platform
assert run_command(["lib", "install", "USBHost"])
res = run_command(["lib", "list", "--all", "--format", "json"])
assert res.ok
libs = json.loads(res.stdout)
assert len(libs) == 2
# Verify both libraries have the same name
assert libs[0]["library"]["name"] == "USBHost"
assert libs[1]["library"]["name"] == "USBHost"
res = run_command(["lib", "upgrade"])
assert res.ok
# Empty output means nothing has been updated as expected
assert res.stdout == ""
nessuno.name=Arduino Nessuno
nessuno.vid.0=0x2341
nessuno.pid.0=0x0043
nessuno.vid.1=0x2341
nessuno.pid.1=0x0001
nessuno.vid.2=0x2A03
nessuno.pid.2=0x0043
nessuno.vid.3=0x2341
nessuno.pid.3=0x0243
nessuno.upload.tool=avrdude
nessuno.upload.protocol=arduino
nessuno.upload.maximum_size=32256
nessuno.upload.maximum_data_size=2048
nessuno.upload.speed=115200
nessuno.bootloader.tool=avrdude
nessuno.bootloader.low_fuses=0xFF
nessuno.bootloader.high_fuses=0xDE
nessuno.bootloader.extended_fuses=0xFD
nessuno.bootloader.unlock_bits=0x3F
nessuno.bootloader.lock_bits=0x0F
nessuno.bootloader.file=optiboot/optiboot_atmega328.hex
nessuno.build.mcu=atmega328p
nessuno.build.f_cpu=16000000L
nessuno.build.board=AVR_NESSUNO
nessuno.build.core=arduino
nessuno.build.variant=standard
name=USBHost
version=0.0.1
author=Arduino
maintainer=Arduino <info@arduino.cc>
sentence=Allows the communication with USB peripherals like mice, keyboards, and thumbdrives. For Arduino MKR1000 and Zero.
paragraph=The USBHost library allows the board to appear as a USB host, enabling it to communicate with peripherals like USB mice and keyboards. USBHost does not support devices that are connected through USB hubs. This includes some keyboards that have an internal hub.
category=Other
url=https://www.arduino.cc/en/Reference/USBHost
architectures=samd
name=Arduino Test Boards
version=4.2.0
\ No newline at end of file
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