Switch legacy platform manager to the new

This commit is contained in:
Ivan Kravets committed 2020-08-15 23:11:01 +03:00
1 parent bb6fb3fdf8
commit 04694b4126
25 files changed
+470 -1271

No files matched your search

+19 -10
View File
@@ -14,8 +14,9 @@
import json
from platformio import exception
from platformio.commands import platform as cli_platform
from platformio.package.exception import UnknownPackageError
from platformio.platform.exception import IncompatiblePlatform
def test_search_json_output(clirunner, validate_cliresult, isolated_pio_core):
@@ -39,22 +40,30 @@ def test_search_raw_output(clirunner, validate_cliresult):
def test_install_unknown_version(clirunner):
result = clirunner.invoke(cli_platform.platform_install, ["atmelavr@99.99.99"])
assert result.exit_code != 0
assert isinstance(result.exception, exception.UndefinedPackageVersion)
assert isinstance(result.exception, UnknownPackageError)
def test_install_unknown_from_registry(clirunner):
result = clirunner.invoke(cli_platform.platform_install, ["unknown-platform"])
assert result.exit_code != 0
assert isinstance(result.exception, exception.UnknownPackage)
assert isinstance(result.exception, UnknownPackageError)
def test_install_incompatbile(clirunner, validate_cliresult, isolated_pio_core):
result = clirunner.invoke(
cli_platform.platform_install, ["atmelavr@1.2.0", "--skip-default-package"],
)
assert result.exit_code != 0
assert isinstance(result.exception, IncompatiblePlatform)
def test_install_known_version(clirunner, validate_cliresult, isolated_pio_core):
result = clirunner.invoke(
cli_platform.platform_install,
["atmelavr@1.2.0", "--skip-default-package", "--with-package", "tool-avrdude"],
["atmelavr@2.0.0", "--skip-default-package", "--with-package", "tool-avrdude"],
)
validate_cliresult(result)
assert "atmelavr @ 1.2.0" in result.output
assert "atmelavr @ 2.0.0" in result.output
assert "Installing tool-avrdude @" in result.output
assert len(isolated_pio_core.join("packages").listdir()) == 1
@@ -63,7 +72,7 @@ def test_install_from_vcs(clirunner, validate_cliresult, isolated_pio_core):
result = clirunner.invoke(
cli_platform.platform_install,
[
"https://github.com/platformio/" "platform-espressif8266.git",
"https://github.com/platformio/platform-espressif8266.git",
"--skip-default-package",
],
)
@@ -90,7 +99,7 @@ def test_list_raw_output(clirunner, validate_cliresult):
def test_update_check(clirunner, validate_cliresult, isolated_pio_core):
result = clirunner.invoke(
cli_platform.platform_update, ["--only-check", "--json-output"]
cli_platform.platform_update, ["--dry-run", "--json-output"]
)
validate_cliresult(result)
output = json.loads(result.output)
@@ -102,9 +111,9 @@ def test_update_check(clirunner, validate_cliresult, isolated_pio_core):
def test_update_raw(clirunner, validate_cliresult, isolated_pio_core):
result = clirunner.invoke(cli_platform.platform_update)
validate_cliresult(result)
assert "Uninstalling atmelavr @ 1.2.0:" in result.output
assert "PlatformManager: Installing atmelavr @" in result.output
assert len(isolated_pio_core.join("packages").listdir()) == 1
assert "Removing atmelavr @ 2.0.0:" in result.output
assert "Platform Manager: Installing platformio/atmelavr @" in result.output
assert len(isolated_pio_core.join("packages").listdir()) == 2
def test_uninstall(clirunner, validate_cliresult, isolated_pio_core):
+5 -5
View File
@@ -13,13 +13,13 @@
# limitations under the License.
import json
import os
import re
from time import time
from platformio import app, maintenance
from platformio.__main__ import cli as cli_pio
from platformio.commands import upgrade as cmd_upgrade
from platformio.managers.platform import PlatformManager
def test_check_pio_upgrade(clirunner, isolated_pio_core, validate_cliresult):
@@ -89,7 +89,8 @@ def test_check_and_update_libraries(clirunner, isolated_pio_core, validate_clire
assert "There are the new updates for libraries (ArduinoJson)" in result.output
assert "Please wait while updating libraries" in result.output
assert re.search(
r"Updating bblanchon/ArduinoJson\s+6\.12\.0\s+\[[\d\.]+\]", result.output
r"Updating bblanchon/ArduinoJson\s+6\.12\.0\s+\[Outdated [\d\.]+\]",
result.output,
)
# check updated version
@@ -102,12 +103,11 @@ def test_check_platform_updates(clirunner, isolated_pio_core, validate_cliresult
# install obsolete platform
result = clirunner.invoke(cli_pio, ["platform", "install", "native"])
validate_cliresult(result)
os.remove(str(isolated_pio_core.join("platforms", "native", ".piopm")))
manifest_path = isolated_pio_core.join("platforms", "native", "platform.json")
manifest = json.loads(manifest_path.read())
manifest["version"] = "0.0.0"
manifest_path.write(json.dumps(manifest))
# reset cached manifests
PlatformManager().cache_reset()
# reset check time
interval = int(app.get_setting("check_platforms_interval")) * 3600 * 24
@@ -141,7 +141,7 @@ def test_check_and_update_platforms(clirunner, isolated_pio_core, validate_clire
validate_cliresult(result)
assert "There are the new updates for platforms (native)" in result.output
assert "Please wait while updating platforms" in result.output
assert re.search(r"Updating native\s+@ 0.0.0\s+\[[\d\.]+\]", result.output)
assert re.search(r"Updating native\s+0.0.0\s+\[Outdated [\d\.]+\]", result.output)
# check updated version
result = clirunner.invoke(cli_pio, ["platform", "list", "--json-output"])