forked from platformio/platformio-core
Added support for “scripts” in package manifest // Resolve #485
This commit is contained in:
1 parent
d8be12dcdd
commit
8de5db4b48
9 files changed
+108
-11
No files matched your search
@@ -50,20 +50,20 @@ def test_project(clirunner, validate_cliresult, isolated_pio_core, tmp_path):
|
||||
)
|
||||
validate_cliresult(result)
|
||||
assert all(token in result.output for token in ("baremetal", "devkit"))
|
||||
assert result.output.count("Platform atmelavr@3.4.0") == 2
|
||||
assert result.output.count("Platform atmelavr @ 3.4.0") == 2
|
||||
assert (
|
||||
result.output.count(
|
||||
"toolchain-atmelavr@1.70300.191015 (required: "
|
||||
"toolchain-atmelavr @ 1.70300.191015 (required: "
|
||||
"platformio/toolchain-atmelavr @ ~1.70300.0)"
|
||||
)
|
||||
== 2
|
||||
)
|
||||
assert result.output.count("Libraries") == 1
|
||||
assert (
|
||||
"ArduinoJson@6.19.0+sha.9693fd2 (required: "
|
||||
"ArduinoJson @ 6.19.0+sha.9693fd2 (required: "
|
||||
"git+https://github.com/bblanchon/ArduinoJson.git#v6.19.0)"
|
||||
) in result.output
|
||||
assert "OneWire@2" in result.output
|
||||
assert "OneWire @ 2" in result.output
|
||||
|
||||
# test "baremetal"
|
||||
result = clirunner.invoke(
|
||||
@@ -71,7 +71,7 @@ def test_project(clirunner, validate_cliresult, isolated_pio_core, tmp_path):
|
||||
["-d", str(project_dir), "-e", "baremetal"],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
assert "Platform atmelavr@3" in result.output
|
||||
assert "Platform atmelavr @ 3" in result.output
|
||||
assert "Libraries" not in result.output
|
||||
|
||||
# filter by "tool" package
|
||||
@@ -100,7 +100,7 @@ def test_project(clirunner, validate_cliresult, isolated_pio_core, tmp_path):
|
||||
def test_global_packages(clirunner, validate_cliresult, isolated_pio_core, tmp_path):
|
||||
result = clirunner.invoke(package_list_cmd, ["-g"])
|
||||
validate_cliresult(result)
|
||||
assert "atmelavr@3" in result.output
|
||||
assert "atmelavr @ 3" in result.output
|
||||
assert "framework-arduino-avr-attiny" in result.output
|
||||
|
||||
# only tools
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
import semantic_version
|
||||
@@ -290,6 +291,44 @@ def test_install_force(isolated_pio_core, tmpdir_factory):
|
||||
assert pkg.metadata.version.major > 5
|
||||
|
||||
|
||||
def test_scripts(isolated_pio_core, tmp_path: Path):
|
||||
pkg_dir = tmp_path / "foo"
|
||||
scripts_dir = pkg_dir / "scripts"
|
||||
scripts_dir.mkdir(parents=True)
|
||||
(scripts_dir / "script.py").write_text(
|
||||
"""
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
action = "postinstall" if len(sys.argv) == 1 else sys.argv[1]
|
||||
Path("%s.flag" % action).touch()
|
||||
|
||||
if action == "preuninstall":
|
||||
Path("../%s.flag" % action).touch()
|
||||
"""
|
||||
)
|
||||
(pkg_dir / "library.json").write_text(
|
||||
"""
|
||||
{
|
||||
"name": "foo",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"postinstall": "scripts/script.py",
|
||||
"preuninstall2": ["scripts/script.py", "preuninstall"]
|
||||
}
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
storage_dir = tmp_path / "storage"
|
||||
lm = LibraryPackageManager(str(storage_dir))
|
||||
lm.set_log_level(logging.ERROR)
|
||||
lm.install("file://%s" % str(pkg_dir))
|
||||
assert os.path.isfile(os.path.join(lm.get_package("foo").path, "postinstall.flag"))
|
||||
lm.uninstall("foo")
|
||||
(storage_dir / "preuninstall.flag").is_file()
|
||||
|
||||
|
||||
def test_get_installed(isolated_pio_core, tmpdir_factory):
|
||||
storage_dir = tmpdir_factory.mktemp("storage")
|
||||
pm = ToolPackageManager(str(storage_dir))
|
||||
|
||||
@@ -322,6 +322,9 @@ def test_library_json_schema():
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"postinstall": "script.py"
|
||||
},
|
||||
"examples": [
|
||||
{
|
||||
"name": "JsonConfigFile",
|
||||
@@ -372,6 +375,7 @@ def test_library_json_schema():
|
||||
"frameworks": ["arduino"],
|
||||
"platforms": ["*"],
|
||||
"license": "MIT",
|
||||
"scripts": {"postinstall": "script.py"},
|
||||
"examples": [
|
||||
{
|
||||
"name": "JsonConfigFile",
|
||||
|
||||
Reference in new issue
Block a user