forked from platformio/platformio-core
Improve base package manager; VCS and package ID support
This commit is contained in:
1 parent
e3bf12f65c
commit
e60c2a6ba1
13 files changed
+668
-433
No files matched your search
@@ -13,15 +13,15 @@
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import os
|
||||
from os.path import join
|
||||
|
||||
from platformio.commands.platform import \
|
||||
platform_list as cmd_platform_list
|
||||
from platformio.commands.platform import \
|
||||
platform_search as cmd_platform_search
|
||||
from platformio.commands import platform as cli_platform
|
||||
from platformio import exception, util
|
||||
|
||||
|
||||
def test_list_json_output(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cmd_platform_list, ["--json-output"])
|
||||
result = clirunner.invoke(cli_platform.platform_list, ["--json-output"])
|
||||
validate_cliresult(result)
|
||||
list_result = json.loads(result.output)
|
||||
assert isinstance(list_result, list)
|
||||
@@ -31,13 +31,13 @@ def test_list_json_output(clirunner, validate_cliresult):
|
||||
|
||||
|
||||
def test_list_raw_output(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cmd_platform_list)
|
||||
result = clirunner.invoke(cli_platform.platform_list)
|
||||
validate_cliresult(result)
|
||||
assert "teensy" in result.output
|
||||
|
||||
|
||||
def test_search_json_output(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cmd_platform_search,
|
||||
result = clirunner.invoke(cli_platform.platform_search,
|
||||
["arduino", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
search_result = json.loads(result.output)
|
||||
@@ -48,6 +48,79 @@ def test_search_json_output(clirunner, validate_cliresult):
|
||||
|
||||
|
||||
def test_search_raw_output(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cmd_platform_search, ["arduino"])
|
||||
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_uknown_version(clirunner, validate_cliresult):
|
||||
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):
|
||||
items = [
|
||||
"teensy",
|
||||
"https://github.com/platformio/platform-teensy/archive/develop.zip",
|
||||
"https://github.com/platformio/platform-teensy.git",
|
||||
"platformio/platform-teensy",
|
||||
]
|
||||
for item in items:
|
||||
with clirunner.isolated_filesystem():
|
||||
os.environ["PLATFORMIO_HOME_DIR"] = os.getcwd()
|
||||
try:
|
||||
result = clirunner.invoke(cli_platform.platform_install,
|
||||
[item])
|
||||
validate_cliresult(result)
|
||||
assert all([
|
||||
s in result.output
|
||||
for s in ("teensy", "Downloading", "Unpacking",
|
||||
"tool-scons")
|
||||
])
|
||||
|
||||
# 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"] == ["tool-scons"]
|
||||
|
||||
# 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
|
||||
result = clirunner.invoke(cli_platform.platform_update)
|
||||
validate_cliresult(result)
|
||||
assert "teensy" in result.output
|
||||
assert "Up-to-date" 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"]
|
||||
@@ -0,0 +1,66 @@
|
||||
# Copyright 2014-present Ivan Kravets <me@ikravets.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from platformio import util
|
||||
from platformio.managers.package import BasePkgManager
|
||||
|
||||
|
||||
def test_pkg_name_parser():
|
||||
items = [
|
||||
["PkgName", ("PkgName", None, None)],
|
||||
[("PkgName", "!=1.2.3,<2.0"), ("PkgName", "!=1.2.3,<2.0", None)],
|
||||
["PkgName@1.2.3", ("PkgName", "1.2.3", None)],
|
||||
[("PkgName@1.2.3", "1.2.5"), ("PkgName@1.2.3", "1.2.5", None)],
|
||||
["id:13", ("id:13", None, None)],
|
||||
["id:13@~1.2.3", ("id:13", "~1.2.3", None)],
|
||||
[util.get_home_dir(),
|
||||
(".platformio", None, "file://" + util.get_home_dir())],
|
||||
["LocalName=" + util.get_home_dir(),
|
||||
("LocalName", None, "file://" + util.get_home_dir())],
|
||||
["https://github.com/user/package.git",
|
||||
("package", None, "git+https://github.com/user/package.git")],
|
||||
["https://github.com/user/package/archive/branch.zip",
|
||||
("branch", None,
|
||||
"https://github.com/user/package/archive/branch.zip")],
|
||||
["https://github.com/user/package/archive/branch.tar.gz",
|
||||
("branch", None,
|
||||
"https://github.com/user/package/archive/branch.tar.gz")],
|
||||
["https://developer.mbed.org/users/user/code/package/",
|
||||
("package", None,
|
||||
"hg+https://developer.mbed.org/users/user/code/package/")],
|
||||
["https://github.com/user/package#v1.2.3",
|
||||
("package", None, "git+https://github.com/user/package#v1.2.3")],
|
||||
["https://github.com/user/package.git#branch",
|
||||
("package", None, "git+https://github.com/user/package.git#branch")],
|
||||
["PkgName=https://github.com/user/package.git#a13d344fg56",
|
||||
("PkgName", None,
|
||||
"git+https://github.com/user/package.git#a13d344fg56")],
|
||||
["PkgName=user/package",
|
||||
("PkgName", None, "git+https://github.com/user/package")],
|
||||
["PkgName=user/package#master",
|
||||
("PkgName", None, "git+https://github.com/user/package#master")],
|
||||
["git+https://github.com/user/package",
|
||||
("package", None, "git+https://github.com/user/package")],
|
||||
["hg+https://example.com/user/package",
|
||||
("package", None, "hg+https://example.com/user/package")],
|
||||
["git@github.com:user/package.git",
|
||||
("package", None, "git@github.com:user/package.git")],
|
||||
["git@github.com:user/package.git#v1.2.0",
|
||||
("package", None, "git@github.com:user/package.git#v1.2.0")]
|
||||
]
|
||||
for params, result in items:
|
||||
if isinstance(params, tuple):
|
||||
assert BasePkgManager.parse_pkg_name(*params) == result
|
||||
else:
|
||||
assert BasePkgManager.parse_pkg_name(params) == result
|
||||
Reference in new issue
Block a user