forked from platformio/platformio-core
Improve Package Manager when check for updates // Resolve #892
This commit is contained in:
1 parent
1d1c677c81
commit
1143012216
7 files changed
+111
-100
No files matched your search
@@ -100,10 +100,21 @@ def test_global_lib_list(clirunner, validate_cliresult, isolated_pio_home):
|
||||
assert set(items1) == set(items2)
|
||||
|
||||
|
||||
def test_global_lib_update_check(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
result = clirunner.invoke(
|
||||
cmd_lib, ["-g", "update", "--only-check", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
output = json.loads(result.output)
|
||||
assert set(["PJON", "RadioHead"]) == set([l['name'] for l in output])
|
||||
|
||||
|
||||
def test_global_lib_update(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cmd_lib, ["-g", "update"])
|
||||
validate_cliresult(result)
|
||||
assert all([s in result.output for s in ("[Up-to-date]", "[VCS]")])
|
||||
assert "[Up-to-date]" in result.output
|
||||
assert re.search(r"Updating PJON\s+@ 1fb26fd\s+\[[a-z\d]{7}\]",
|
||||
result.output)
|
||||
|
||||
|
||||
def test_global_lib_uninstall(clirunner, validate_cliresult,
|
||||
@@ -124,9 +135,8 @@ def test_global_lib_uninstall(clirunner, validate_cliresult,
|
||||
def test_lib_show(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cmd_lib, ["show", "64"])
|
||||
validate_cliresult(result)
|
||||
assert all([
|
||||
s in result.output for s in ("ArduinoJson", "Arduino", "Atmel AVR")
|
||||
])
|
||||
assert all(
|
||||
[s in result.output for s in ("ArduinoJson", "Arduino", "Atmel AVR")])
|
||||
result = clirunner.invoke(cmd_lib, ["show", "OneWire"])
|
||||
validate_cliresult(result)
|
||||
assert "OneWire" in result.output
|
||||
|
||||
@@ -13,30 +13,12 @@
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import os
|
||||
from os.path import join
|
||||
|
||||
from platformio import exception, util
|
||||
from platformio import exception
|
||||
from platformio.commands import platform as cli_platform
|
||||
|
||||
|
||||
def test_list_json_output(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli_platform.platform_list, ["--json-output"])
|
||||
validate_cliresult(result)
|
||||
list_result = json.loads(result.output)
|
||||
assert isinstance(list_result, list)
|
||||
assert len(list_result)
|
||||
platforms = [item['name'] for item in list_result]
|
||||
assert "titiva" in platforms
|
||||
|
||||
|
||||
def test_list_raw_output(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli_platform.platform_list)
|
||||
validate_cliresult(result)
|
||||
assert "teensy" in result.output
|
||||
|
||||
|
||||
def test_search_json_output(clirunner, validate_cliresult):
|
||||
def test_search_json_output(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_search,
|
||||
["arduino", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
@@ -47,82 +29,75 @@ def test_search_json_output(clirunner, validate_cliresult):
|
||||
assert "atmelsam" in platforms
|
||||
|
||||
|
||||
def test_search_raw_output(clirunner, validate_cliresult):
|
||||
def test_search_raw_output(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_search, ["arduino"])
|
||||
validate_cliresult(result)
|
||||
assert "teensy" in result.output
|
||||
|
||||
|
||||
def test_install_uknown_from_registry(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli_platform.platform_install,
|
||||
["uknown-platform"])
|
||||
assert result.exit_code == -1
|
||||
assert isinstance(result.exception, exception.UnknownPackage)
|
||||
|
||||
|
||||
def test_install_from_vcs(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli_platform.platform_install, [
|
||||
"https://github.com/platformio/"
|
||||
"platform-espressif8266.git#feature/stage"
|
||||
])
|
||||
validate_cliresult(result)
|
||||
assert "espressif8266_stage" in result.output
|
||||
|
||||
|
||||
def test_install_uknown_version(clirunner, validate_cliresult):
|
||||
def test_install_unknown_version(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_install,
|
||||
["atmelavr@99.99.99"])
|
||||
assert result.exit_code == -1
|
||||
assert isinstance(result.exception, exception.UndefinedPackageVersion)
|
||||
|
||||
|
||||
def test_complex(clirunner, validate_cliresult):
|
||||
with clirunner.isolated_filesystem():
|
||||
os.environ["PLATFORMIO_HOME_DIR"] = os.getcwd()
|
||||
try:
|
||||
result = clirunner.invoke(
|
||||
cli_platform.platform_install,
|
||||
["teensy", "--with-package", "framework-arduinoteensy"])
|
||||
validate_cliresult(result)
|
||||
assert all([
|
||||
s in result.output
|
||||
for s in ("teensy", "Downloading", "Unpacking")
|
||||
])
|
||||
def test_install_unknown_from_registry(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_install,
|
||||
["unknown-platform"])
|
||||
assert result.exit_code == -1
|
||||
assert isinstance(result.exception, exception.UnknownPackage)
|
||||
|
||||
# show platform information
|
||||
result = clirunner.invoke(cli_platform.platform_show, ["teensy"])
|
||||
validate_cliresult(result)
|
||||
assert "teensy" in result.output
|
||||
|
||||
# list platforms
|
||||
result = clirunner.invoke(cli_platform.platform_list,
|
||||
["--json-output"])
|
||||
validate_cliresult(result)
|
||||
list_result = json.loads(result.output)
|
||||
assert isinstance(list_result, list)
|
||||
assert len(list_result) == 1
|
||||
assert list_result[0]["name"] == "teensy"
|
||||
assert list_result[0]["packages"] == ["framework-arduinoteensy"]
|
||||
def test_install_known_version(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_install,
|
||||
["atmelavr@1.1.0", "--skip-default-package"])
|
||||
validate_cliresult(result)
|
||||
assert "atmelavr @ 1.1.0" in result.output
|
||||
|
||||
# try to install again
|
||||
result = clirunner.invoke(cli_platform.platform_install,
|
||||
["teensy"])
|
||||
validate_cliresult(result)
|
||||
assert "is already installed" in result.output
|
||||
|
||||
# try to update
|
||||
for _ in range(2):
|
||||
result = clirunner.invoke(cli_platform.platform_update)
|
||||
validate_cliresult(result)
|
||||
assert "teensy" in result.output
|
||||
assert "Up-to-date" in result.output
|
||||
assert "Out-of-date" not in result.output
|
||||
def test_install_from_vcs(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_install, [
|
||||
"https://github.com/platformio/"
|
||||
"platform-espressif8266.git#feature/stage", "--skip-default-package"
|
||||
])
|
||||
validate_cliresult(result)
|
||||
assert "espressif8266_stage" in result.output
|
||||
|
||||
# try to uninstall
|
||||
result = clirunner.invoke(cli_platform.platform_uninstall,
|
||||
["teensy"])
|
||||
validate_cliresult(result)
|
||||
for folder in ("platforms", "packages"):
|
||||
assert len(os.listdir(join(util.get_home_dir(), folder))) == 0
|
||||
finally:
|
||||
del os.environ["PLATFORMIO_HOME_DIR"]
|
||||
|
||||
def test_list_json_output(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_list, ["--json-output"])
|
||||
validate_cliresult(result)
|
||||
list_result = json.loads(result.output)
|
||||
assert isinstance(list_result, list)
|
||||
assert len(list_result)
|
||||
platforms = [item['name'] for item in list_result]
|
||||
assert set(["atmelavr", "espressif8266_stage"]) == set(platforms)
|
||||
|
||||
|
||||
def test_list_raw_output(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_list)
|
||||
validate_cliresult(result)
|
||||
assert all(
|
||||
[s in result.output for s in ("atmelavr", "espressif8266_stage")])
|
||||
|
||||
|
||||
def test_update_check(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_update,
|
||||
["--only-check", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
output = json.loads(result.output)
|
||||
assert len(output) == 1
|
||||
assert output[0]['name'] == "atmelavr"
|
||||
|
||||
|
||||
def test_uninstall(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_uninstall,
|
||||
["atmelavr", "espressif8266_stage"])
|
||||
validate_cliresult(result)
|
||||
assert len(
|
||||
[d.basename
|
||||
for d in isolated_pio_home.join("platforms").listdir()]) == 0
|
||||
@@ -13,6 +13,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import re
|
||||
from time import time
|
||||
|
||||
from platformio import app, maintenance
|
||||
@@ -135,7 +136,8 @@ def test_check_and_update_libraries(clirunner, validate_cliresult,
|
||||
assert ("There are the new updates for libraries (ArduinoJson)" in
|
||||
result.output)
|
||||
assert "Please wait while updating libraries" in result.output
|
||||
assert "[Out-of-date]" in result.output
|
||||
assert re.search(r"Updating ArduinoJson\s+@ 5.6.7\s+\[[\d\.]+\]",
|
||||
result.output)
|
||||
|
||||
# check updated version
|
||||
result = clirunner.invoke(cli_pio, ["lib", "-g", "list", "--json-output"])
|
||||
@@ -188,7 +190,8 @@ def test_check_and_update_platforms(clirunner, validate_cliresult,
|
||||
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 "[Out-of-date]" in result.output
|
||||
assert re.search(r"Updating native\s+@ 0.0.0\s+\[[\d\.]+\]",
|
||||
result.output)
|
||||
|
||||
# check updated version
|
||||
result = clirunner.invoke(cli_pio, ["platform", "list", "--json-output"])
|
||||
|
||||
Reference in new issue
Block a user