mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 18:44:27 +02:00
Update tests
This commit is contained in:
@@ -24,7 +24,7 @@ PROJECT_OUTDATED_CONFIG_TPL = """
|
|||||||
platform = platformio/atmelavr@^2
|
platform = platformio/atmelavr@^2
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = attiny88
|
board = attiny88
|
||||||
lib_deps = milesburton/DallasTemperature@~3.8.0
|
lib_deps = milesburton/DallasTemperature@~3.9.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
PROJECT_UPDATED_CONFIG_TPL = """
|
PROJECT_UPDATED_CONFIG_TPL = """
|
||||||
@@ -32,7 +32,7 @@ PROJECT_UPDATED_CONFIG_TPL = """
|
|||||||
platform = platformio/atmelavr@<4
|
platform = platformio/atmelavr@<4
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = attiny88
|
board = attiny88
|
||||||
lib_deps = milesburton/DallasTemperature@^3.8.0
|
lib_deps = milesburton/DallasTemperature@^3.9.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ def test_project(clirunner, validate_cliresult, isolated_pio_core, tmp_path):
|
|||||||
re.MULTILINE,
|
re.MULTILINE,
|
||||||
)
|
)
|
||||||
assert re.search(
|
assert re.search(
|
||||||
r"^DallasTemperature\s+3\.8\.1\s+3\.\d+\.\d+\s+3\.\d+\.\d+\s+Library\s+devkit",
|
r"^DallasTemperature\s+3\.\.1\s+3\.\d+\.\d+\s+3\.\d+\.\d+\s+Library\s+devkit",
|
||||||
result.output,
|
result.output,
|
||||||
re.MULTILINE,
|
re.MULTILINE,
|
||||||
)
|
)
|
||||||
|
@@ -26,12 +26,14 @@ from platformio.package.manager.tool import ToolPackageManager
|
|||||||
from platformio.package.meta import PackageSpec
|
from platformio.package.meta import PackageSpec
|
||||||
from platformio.project.config import ProjectConfig
|
from platformio.project.config import ProjectConfig
|
||||||
|
|
||||||
|
DALLASTEMPERATURE_LATEST_VERSION = "3.11.0"
|
||||||
|
|
||||||
PROJECT_OUTDATED_CONFIG_TPL = """
|
PROJECT_OUTDATED_CONFIG_TPL = """
|
||||||
[env:devkit]
|
[env:devkit]
|
||||||
platform = platformio/atmelavr@^2
|
platform = platformio/atmelavr@^2
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = attiny88
|
board = attiny88
|
||||||
lib_deps = milesburton/DallasTemperature@~3.8.0
|
lib_deps = milesburton/DallasTemperature@^3.8.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
PROJECT_UPDATED_CONFIG_TPL = """
|
PROJECT_UPDATED_CONFIG_TPL = """
|
||||||
@@ -162,7 +164,7 @@ def test_project(
|
|||||||
os.path.join(config.get("platformio", "libdeps_dir"), "devkit")
|
os.path.join(config.get("platformio", "libdeps_dir"), "devkit")
|
||||||
)
|
)
|
||||||
assert pkgs_to_specs(lm.get_installed()) == [
|
assert pkgs_to_specs(lm.get_installed()) == [
|
||||||
PackageSpec("DallasTemperature@3.8.1"),
|
PackageSpec(f"DallasTemperature@{DALLASTEMPERATURE_LATEST_VERSION}"),
|
||||||
PackageSpec(
|
PackageSpec(
|
||||||
"OneWire@%s" % get_pkg_latest_version("paulstoffregen/OneWire")
|
"OneWire@%s" % get_pkg_latest_version("paulstoffregen/OneWire")
|
||||||
),
|
),
|
||||||
@@ -176,7 +178,7 @@ def test_project(
|
|||||||
PackageSpec("toolchain-atmelavr@1.50400.190710"),
|
PackageSpec("toolchain-atmelavr@1.50400.190710"),
|
||||||
]
|
]
|
||||||
assert config.get("env:devkit", "lib_deps") == [
|
assert config.get("env:devkit", "lib_deps") == [
|
||||||
"milesburton/DallasTemperature@~3.8.0"
|
"milesburton/DallasTemperature@^3.8.0"
|
||||||
]
|
]
|
||||||
|
|
||||||
# update packages
|
# update packages
|
||||||
@@ -227,7 +229,7 @@ def test_custom_project_libraries(
|
|||||||
project_dir = tmp_path / "project"
|
project_dir = tmp_path / "project"
|
||||||
project_dir.mkdir()
|
project_dir.mkdir()
|
||||||
(project_dir / "platformio.ini").write_text(PROJECT_OUTDATED_CONFIG_TPL)
|
(project_dir / "platformio.ini").write_text(PROJECT_OUTDATED_CONFIG_TPL)
|
||||||
spec = "milesburton/DallasTemperature@~3.8.0"
|
spec = "milesburton/DallasTemperature@^3.8.0"
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
package_install_cmd,
|
package_install_cmd,
|
||||||
["-d", str(project_dir), "-e", "devkit", "-l", spec],
|
["-d", str(project_dir), "-e", "devkit", "-l", spec],
|
||||||
@@ -240,7 +242,7 @@ def test_custom_project_libraries(
|
|||||||
os.path.join(config.get("platformio", "libdeps_dir"), "devkit")
|
os.path.join(config.get("platformio", "libdeps_dir"), "devkit")
|
||||||
)
|
)
|
||||||
assert pkgs_to_specs(lm.get_installed()) == [
|
assert pkgs_to_specs(lm.get_installed()) == [
|
||||||
PackageSpec("DallasTemperature@3.8.1"),
|
PackageSpec(f"DallasTemperature@{DALLASTEMPERATURE_LATEST_VERSION}"),
|
||||||
PackageSpec(
|
PackageSpec(
|
||||||
"OneWire@%s" % get_pkg_latest_version("paulstoffregen/OneWire")
|
"OneWire@%s" % get_pkg_latest_version("paulstoffregen/OneWire")
|
||||||
),
|
),
|
||||||
|
@@ -42,7 +42,7 @@ board = devkit
|
|||||||
framework = foo
|
framework = foo
|
||||||
lib_deps =
|
lib_deps =
|
||||||
CustomLib
|
CustomLib
|
||||||
ArduinoJson @ 5.10.1
|
ArduinoJson @ 6.18.5
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
@@ -163,7 +163,7 @@ def test_update(clirunner, validate_cliresult, isolated_pio_core, tmpdir_factory
|
|||||||
storage_dir = tmpdir_factory.mktemp("test-updates")
|
storage_dir = tmpdir_factory.mktemp("test-updates")
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_lib,
|
cmd_lib,
|
||||||
["-d", str(storage_dir), "install", "ArduinoJson @ 5.10.1", "Blynk @ ~0.5.0"],
|
["-d", str(storage_dir), "install", "ArduinoJson @ 6.18.5", "Blynk @ ~1.2"],
|
||||||
)
|
)
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
@@ -173,17 +173,17 @@ def test_update(clirunner, validate_cliresult, isolated_pio_core, tmpdir_factory
|
|||||||
outdated = json.loads(result.stdout)
|
outdated = json.loads(result.stdout)
|
||||||
assert len(outdated) == 2
|
assert len(outdated) == 2
|
||||||
# ArduinoJson
|
# ArduinoJson
|
||||||
assert outdated[0]["version"] == "5.10.1"
|
assert outdated[0]["version"] == "6.18.5"
|
||||||
assert outdated[0]["versionWanted"] is None
|
assert outdated[0]["versionWanted"] is None
|
||||||
assert semantic_version.Version(
|
assert semantic_version.Version(
|
||||||
outdated[0]["versionLatest"]
|
outdated[0]["versionLatest"]
|
||||||
) > semantic_version.Version("6.16.0")
|
) > semantic_version.Version("6.18.5")
|
||||||
# Blynk
|
# Blynk
|
||||||
assert outdated[1]["version"] == "0.5.4"
|
assert outdated[1]["version"] == "1.2.0"
|
||||||
assert outdated[1]["versionWanted"] is None
|
assert outdated[1]["versionWanted"] is None
|
||||||
assert semantic_version.Version(
|
assert semantic_version.Version(
|
||||||
outdated[1]["versionLatest"]
|
outdated[1]["versionLatest"]
|
||||||
) > semantic_version.Version("0.6.0")
|
) > semantic_version.Version("1.2.0")
|
||||||
|
|
||||||
# check with spec
|
# check with spec
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
@@ -194,19 +194,19 @@ def test_update(clirunner, validate_cliresult, isolated_pio_core, tmpdir_factory
|
|||||||
"update",
|
"update",
|
||||||
"--dry-run",
|
"--dry-run",
|
||||||
"--json-output",
|
"--json-output",
|
||||||
"ArduinoJson @ ^5",
|
"ArduinoJson @ ^6",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
outdated = json.loads(result.stdout)
|
outdated = json.loads(result.stdout)
|
||||||
assert outdated[0]["version"] == "5.10.1"
|
assert outdated[0]["version"] == "6.18.5"
|
||||||
assert outdated[0]["versionWanted"] == "5.13.4"
|
assert outdated[0]["versionWanted"] == "6.21.5"
|
||||||
assert semantic_version.Version(
|
assert semantic_version.Version(
|
||||||
outdated[0]["versionLatest"]
|
outdated[0]["versionLatest"]
|
||||||
) > semantic_version.Version("6.16.0")
|
) > semantic_version.Version("6.16.0")
|
||||||
# update with spec
|
# update with spec
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_lib, ["-d", str(storage_dir), "update", "--silent", "ArduinoJson @ ^5.10.1"]
|
cmd_lib, ["-d", str(storage_dir), "update", "--silent", "ArduinoJson @ ^6.18.5"]
|
||||||
)
|
)
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
@@ -215,12 +215,12 @@ def test_update(clirunner, validate_cliresult, isolated_pio_core, tmpdir_factory
|
|||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
items = json.loads(result.stdout)
|
items = json.loads(result.stdout)
|
||||||
assert len(items) == 2
|
assert len(items) == 2
|
||||||
assert items[0]["version"] == "5.13.4"
|
assert items[0]["version"] == "6.21.5"
|
||||||
assert items[1]["version"] == "0.5.4"
|
assert items[1]["version"] == "1.2.0"
|
||||||
|
|
||||||
# Check incompatible
|
# Check incompatible
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_lib, ["-d", str(storage_dir), "update", "--dry-run", "ArduinoJson @ ^5"]
|
cmd_lib, ["-d", str(storage_dir), "update", "--dry-run", "ArduinoJson @ ^6"]
|
||||||
)
|
)
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
AssertionError,
|
AssertionError,
|
||||||
@@ -228,7 +228,7 @@ def test_update(clirunner, validate_cliresult, isolated_pio_core, tmpdir_factory
|
|||||||
):
|
):
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_lib, ["-d", str(storage_dir), "update", "ArduinoJson @ ^5"]
|
cmd_lib, ["-d", str(storage_dir), "update", "ArduinoJson @ ^6"]
|
||||||
)
|
)
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
assert "ArduinoJson@5.13.4 is already up-to-date" in result.stdout
|
assert "ArduinoJson@6.21.5 is already up-to-date" in result.stdout
|
||||||
|
@@ -61,7 +61,7 @@ def test_global_install_registry(clirunner, validate_cliresult, isolated_pio_cor
|
|||||||
items1 = [d.basename for d in isolated_pio_core.join("lib").listdir()]
|
items1 = [d.basename for d in isolated_pio_core.join("lib").listdir()]
|
||||||
items2 = [
|
items2 = [
|
||||||
"ArduinoJson",
|
"ArduinoJson",
|
||||||
"fArduinoJson@{ARDUINO_JSON_VERSION}",
|
f"ArduinoJson@{ARDUINO_JSON_VERSION}",
|
||||||
"NeoPixelBus",
|
"NeoPixelBus",
|
||||||
"AsyncMqttClient",
|
"AsyncMqttClient",
|
||||||
"ESPAsyncTCP",
|
"ESPAsyncTCP",
|
||||||
@@ -189,7 +189,7 @@ def test_global_lib_list(clirunner, validate_cliresult):
|
|||||||
for n in (
|
for n in (
|
||||||
"__pkg_dir",
|
"__pkg_dir",
|
||||||
'"__src_url": "git+https://github.com/gioblu/PJON.git#6.2"',
|
'"__src_url": "git+https://github.com/gioblu/PJON.git#6.2"',
|
||||||
'"version": "5.10.1"',
|
f'"version": "{ARDUINO_JSON_VERSION}"',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
items1 = [i["name"] for i in json.loads(result.output)]
|
items1 = [i["name"] for i in json.loads(result.output)]
|
||||||
@@ -219,13 +219,13 @@ def test_global_lib_list(clirunner, validate_cliresult):
|
|||||||
]
|
]
|
||||||
versions2 = [
|
versions2 = [
|
||||||
"ArduinoJson@5.8.2",
|
"ArduinoJson@5.8.2",
|
||||||
"ArduinoJson@5.10.1",
|
f"ArduinoJson@{ARDUINO_JSON_VERSION}",
|
||||||
"AsyncMqttClient@0.8.2",
|
"AsyncMqttClient@0.8.2",
|
||||||
"NeoPixelBus@2.7.3",
|
"NeoPixelBus@2.7.3",
|
||||||
"PJON@6.2.0+sha.07fe9aa",
|
"PJON@6.2.0+sha.07fe9aa",
|
||||||
"PJON@3.0.0+sha.1fb26fd",
|
"PJON@3.0.0+sha.1fb26fd",
|
||||||
"PubSubClient@2.6.0+sha.bef5814",
|
"PubSubClient@2.6.0+sha.bef5814",
|
||||||
"Adafruit PN532@1.2.0",
|
"Adafruit PN532@1.3.2",
|
||||||
]
|
]
|
||||||
assert set(versions1) >= set(versions2)
|
assert set(versions1) >= set(versions2)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user