|
16 | 16 |
|
17 | 17 | import simplejson as json
|
18 | 18 | import pytest
|
| 19 | +import shutil |
19 | 20 | from git import Repo
|
20 | 21 | from pathlib import Path
|
21 | 22 | import tempfile
|
@@ -982,3 +983,67 @@ def test_install_git_invalid_library(run_command, data_dir, downloads_dir):
|
982 | 983 | assert res.failed
|
983 | 984 | assert "library not valid" in res.stderr
|
984 | 985 | assert not lib_install_dir.exists()
|
| 986 | + |
| 987 | + |
| 988 | +def test_upgrade_does_not_try_to_upgrade_bundled_core_libraries_in_sketchbook(run_command, data_dir): |
| 989 | + test_platform_name = "platform_with_bundled_library" |
| 990 | + platform_install_dir = Path(data_dir, "hardware", "arduino-beta-dev", test_platform_name) |
| 991 | + platform_install_dir.mkdir(parents=True) |
| 992 | + |
| 993 | + # Install platform in Sketchbook hardware dir |
| 994 | + shutil.copytree( |
| 995 | + Path(__file__).parent / "testdata" / test_platform_name, |
| 996 | + platform_install_dir, |
| 997 | + dirs_exist_ok=True, |
| 998 | + ) |
| 999 | + |
| 1000 | + assert run_command(["update"]) |
| 1001 | + |
| 1002 | + # Install latest version of library identical to one |
| 1003 | + # bundled with test platform |
| 1004 | + assert run_command(["lib", "install", "USBHost"]) |
| 1005 | + |
| 1006 | + res = run_command(["lib", "list", "--all", "--format", "json"]) |
| 1007 | + assert res.ok |
| 1008 | + libs = json.loads(res.stdout) |
| 1009 | + assert len(libs) == 2 |
| 1010 | + # Verify both libraries have the same name |
| 1011 | + assert libs[0]["library"]["name"] == "USBHost" |
| 1012 | + assert libs[1]["library"]["name"] == "USBHost" |
| 1013 | + |
| 1014 | + res = run_command(["lib", "upgrade"]) |
| 1015 | + assert res.ok |
| 1016 | + # Empty output means nothing has been updated as expected |
| 1017 | + assert res.stdout == "" |
| 1018 | + |
| 1019 | + |
| 1020 | +def test_upgrade_does_not_try_to_upgrade_bundled_core_libraries(run_command, data_dir): |
| 1021 | + test_platform_name = "platform_with_bundled_library" |
| 1022 | + platform_install_dir = Path(data_dir, "packages", "arduino", "hardware", "arch", "4.2.0") |
| 1023 | + platform_install_dir.mkdir(parents=True) |
| 1024 | + |
| 1025 | + # Simulate installation of a platform with arduino-cli |
| 1026 | + shutil.copytree( |
| 1027 | + Path(__file__).parent / "testdata" / test_platform_name, |
| 1028 | + platform_install_dir, |
| 1029 | + dirs_exist_ok=True, |
| 1030 | + ) |
| 1031 | + |
| 1032 | + assert run_command(["update"]) |
| 1033 | + |
| 1034 | + # Install latest version of library identical to one |
| 1035 | + # bundled with test platform |
| 1036 | + assert run_command(["lib", "install", "USBHost"]) |
| 1037 | + |
| 1038 | + res = run_command(["lib", "list", "--all", "--format", "json"]) |
| 1039 | + assert res.ok |
| 1040 | + libs = json.loads(res.stdout) |
| 1041 | + assert len(libs) == 2 |
| 1042 | + # Verify both libraries have the same name |
| 1043 | + assert libs[0]["library"]["name"] == "USBHost" |
| 1044 | + assert libs[1]["library"]["name"] == "USBHost" |
| 1045 | + |
| 1046 | + res = run_command(["lib", "upgrade"]) |
| 1047 | + assert res.ok |
| 1048 | + # Empty output means nothing has been updated as expected |
| 1049 | + assert res.stdout == "" |
0 commit comments