forked from platformio/platformio-core
Introduce Black to automate code formatting
This commit is contained in:
1 parent
5e144a2c98
commit
7c41c7c2f3
90 files changed
+4064
-3367
No files matched your search
@@ -23,7 +23,7 @@ def test_board_json_output(clirunner, validate_cliresult):
|
||||
validate_cliresult(result)
|
||||
boards = json.loads(result.output)
|
||||
assert isinstance(boards, list)
|
||||
assert any(["mbed" in b['frameworks'] for b in boards])
|
||||
assert any(["mbed" in b["frameworks"] for b in boards])
|
||||
|
||||
|
||||
def test_board_raw_output(clirunner, validate_cliresult):
|
||||
@@ -33,8 +33,7 @@ def test_board_raw_output(clirunner, validate_cliresult):
|
||||
|
||||
|
||||
def test_board_options(clirunner, validate_cliresult):
|
||||
required_opts = set(
|
||||
["fcpu", "frameworks", "id", "mcu", "name", "platform"])
|
||||
required_opts = set(["fcpu", "frameworks", "id", "mcu", "name", "platform"])
|
||||
|
||||
# fetch available platforms
|
||||
result = clirunner.invoke(cmd_platform_search, ["--json-output"])
|
||||
@@ -42,7 +41,7 @@ def test_board_options(clirunner, validate_cliresult):
|
||||
search_result = json.loads(result.output)
|
||||
assert isinstance(search_result, list)
|
||||
assert len(search_result)
|
||||
platforms = [item['name'] for item in search_result]
|
||||
platforms = [item["name"] for item in search_result]
|
||||
|
||||
result = clirunner.invoke(cmd_boards, ["mbed", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
@@ -50,4 +49,4 @@ def test_board_options(clirunner, validate_cliresult):
|
||||
|
||||
for board in boards:
|
||||
assert required_opts.issubset(set(board))
|
||||
assert board['platform'] in platforms
|
||||
assert board["platform"] in platforms
|
||||
@@ -90,47 +90,43 @@ def test_check_cli_output(clirunner, check_dir):
|
||||
|
||||
errors, warnings, style = count_defects(result.output)
|
||||
|
||||
assert (result.exit_code != 0)
|
||||
assert (errors + warnings + style == EXPECTED_DEFECTS)
|
||||
assert result.exit_code != 0
|
||||
assert errors + warnings + style == EXPECTED_DEFECTS
|
||||
|
||||
|
||||
def test_check_json_output(clirunner, check_dir):
|
||||
result = clirunner.invoke(
|
||||
cmd_check,
|
||||
["--project-dir", str(check_dir), "--json-output"])
|
||||
cmd_check, ["--project-dir", str(check_dir), "--json-output"]
|
||||
)
|
||||
output = json.loads(result.stdout.strip())
|
||||
|
||||
assert isinstance(output, list)
|
||||
assert (len(output[0].get("defects", [])) == EXPECTED_DEFECTS)
|
||||
assert len(output[0].get("defects", [])) == EXPECTED_DEFECTS
|
||||
|
||||
|
||||
def test_check_tool_defines_passed(clirunner, check_dir):
|
||||
result = clirunner.invoke(
|
||||
cmd_check,
|
||||
["--project-dir", str(check_dir), "--verbose"])
|
||||
result = clirunner.invoke(cmd_check, ["--project-dir", str(check_dir), "--verbose"])
|
||||
output = result.output
|
||||
|
||||
assert ("PLATFORMIO=" in output)
|
||||
assert ("__GNUC__" in output)
|
||||
assert "PLATFORMIO=" in output
|
||||
assert "__GNUC__" in output
|
||||
|
||||
|
||||
def test_check_severity_threshold(clirunner, check_dir):
|
||||
result = clirunner.invoke(
|
||||
cmd_check,
|
||||
["--project-dir", str(check_dir), "--severity=high"])
|
||||
cmd_check, ["--project-dir", str(check_dir), "--severity=high"]
|
||||
)
|
||||
|
||||
errors, warnings, style = count_defects(result.output)
|
||||
|
||||
assert (result.exit_code != 0)
|
||||
assert (errors == EXPECTED_ERRORS)
|
||||
assert (warnings == 0)
|
||||
assert (style == 0)
|
||||
assert result.exit_code != 0
|
||||
assert errors == EXPECTED_ERRORS
|
||||
assert warnings == 0
|
||||
assert style == 0
|
||||
|
||||
|
||||
def test_check_includes_passed(clirunner, check_dir):
|
||||
result = clirunner.invoke(
|
||||
cmd_check,
|
||||
["--project-dir", str(check_dir), "--verbose"])
|
||||
result = clirunner.invoke(cmd_check, ["--project-dir", str(check_dir), "--verbose"])
|
||||
output = result.output
|
||||
|
||||
inc_count = 0
|
||||
@@ -139,13 +135,11 @@ def test_check_includes_passed(clirunner, check_dir):
|
||||
inc_count = l.count("-I")
|
||||
|
||||
# at least 1 include path for default mode
|
||||
assert (inc_count > 1)
|
||||
assert inc_count > 1
|
||||
|
||||
|
||||
def test_check_silent_mode(clirunner, check_dir):
|
||||
result = clirunner.invoke(
|
||||
cmd_check,
|
||||
["--project-dir", str(check_dir), "--silent"])
|
||||
result = clirunner.invoke(cmd_check, ["--project-dir", str(check_dir), "--silent"])
|
||||
|
||||
errors, warnings, style = count_defects(result.output)
|
||||
|
||||
@@ -159,9 +153,8 @@ def test_check_filter_sources(clirunner, check_dir):
|
||||
check_dir.mkdir(join("src", "app")).join("additional.cpp").write(TEST_CODE)
|
||||
|
||||
result = clirunner.invoke(
|
||||
cmd_check,
|
||||
["--project-dir",
|
||||
str(check_dir), "--filter=-<*> +<src/app/>"])
|
||||
cmd_check, ["--project-dir", str(check_dir), "--filter=-<*> +<src/app/>"]
|
||||
)
|
||||
|
||||
errors, warnings, style = count_defects(result.output)
|
||||
|
||||
@@ -187,8 +180,8 @@ def test_check_failed_if_no_source_files(clirunner, tmpdir):
|
||||
|
||||
def test_check_failed_if_bad_flag_passed(clirunner, check_dir):
|
||||
result = clirunner.invoke(
|
||||
cmd_check, ["--project-dir",
|
||||
str(check_dir), '"--flags=--UNKNOWN"'])
|
||||
cmd_check, ["--project-dir", str(check_dir), '"--flags=--UNKNOWN"']
|
||||
)
|
||||
|
||||
errors, warnings, style = count_defects(result.output)
|
||||
|
||||
@@ -200,7 +193,8 @@ def test_check_failed_if_bad_flag_passed(clirunner, check_dir):
|
||||
|
||||
def test_check_success_if_no_errors(clirunner, tmpdir):
|
||||
tmpdir.join("platformio.ini").write(DEFAULT_CONFIG)
|
||||
tmpdir.mkdir("src").join("main.c").write("""
|
||||
tmpdir.mkdir("src").join("main.c").write(
|
||||
"""
|
||||
#include <stdlib.h>
|
||||
|
||||
void unused_functin(){
|
||||
@@ -211,7 +205,8 @@ void unused_functin(){
|
||||
|
||||
int main() {
|
||||
}
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
result = clirunner.invoke(cmd_check, ["--project-dir", str(tmpdir)])
|
||||
|
||||
@@ -243,14 +238,17 @@ def test_check_individual_flags_passed(clirunner, tmpdir):
|
||||
|
||||
|
||||
def test_check_cppcheck_misra_addon(clirunner, check_dir):
|
||||
check_dir.join("misra.json").write("""
|
||||
check_dir.join("misra.json").write(
|
||||
"""
|
||||
{
|
||||
"script": "addons/misra.py",
|
||||
"args": ["--rule-texts=rules.txt"]
|
||||
}
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
check_dir.join("rules.txt").write("""
|
||||
check_dir.join("rules.txt").write(
|
||||
"""
|
||||
Appendix A Summary of guidelines
|
||||
Rule 3.1 Required
|
||||
R3.1 text.
|
||||
@@ -272,12 +270,12 @@ Rule 21.3 Required
|
||||
R21.3 Found MISRA defect
|
||||
Rule 21.4
|
||||
R21.4 text.
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
result = clirunner.invoke(
|
||||
cmd_check,
|
||||
["--project-dir",
|
||||
str(check_dir), "--flags=--addon=misra.json"])
|
||||
cmd_check, ["--project-dir", str(check_dir), "--flags=--addon=misra.json"]
|
||||
)
|
||||
|
||||
assert result.exit_code != 0
|
||||
assert "R21.3 Found MISRA defect" in result.output
|
||||
|
||||
+68
-26
@@ -25,37 +25,63 @@ def test_ci_empty(clirunner):
|
||||
|
||||
|
||||
def test_ci_boards(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cmd_ci, [
|
||||
join("examples", "wiring-blink", "src", "main.cpp"), "-b", "uno", "-b",
|
||||
"leonardo"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_ci,
|
||||
[
|
||||
join("examples", "wiring-blink", "src", "main.cpp"),
|
||||
"-b",
|
||||
"uno",
|
||||
"-b",
|
||||
"leonardo",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
|
||||
|
||||
def test_ci_build_dir(clirunner, tmpdir_factory, validate_cliresult):
|
||||
build_dir = str(tmpdir_factory.mktemp("ci_build_dir"))
|
||||
result = clirunner.invoke(cmd_ci, [
|
||||
join("examples", "wiring-blink", "src", "main.cpp"), "-b", "uno",
|
||||
"--build-dir", build_dir
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_ci,
|
||||
[
|
||||
join("examples", "wiring-blink", "src", "main.cpp"),
|
||||
"-b",
|
||||
"uno",
|
||||
"--build-dir",
|
||||
build_dir,
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
assert not isfile(join(build_dir, "platformio.ini"))
|
||||
|
||||
|
||||
def test_ci_keep_build_dir(clirunner, tmpdir_factory, validate_cliresult):
|
||||
build_dir = str(tmpdir_factory.mktemp("ci_build_dir"))
|
||||
result = clirunner.invoke(cmd_ci, [
|
||||
join("examples", "wiring-blink", "src", "main.cpp"), "-b", "uno",
|
||||
"--build-dir", build_dir, "--keep-build-dir"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_ci,
|
||||
[
|
||||
join("examples", "wiring-blink", "src", "main.cpp"),
|
||||
"-b",
|
||||
"uno",
|
||||
"--build-dir",
|
||||
build_dir,
|
||||
"--keep-build-dir",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
assert isfile(join(build_dir, "platformio.ini"))
|
||||
|
||||
# 2nd attempt
|
||||
result = clirunner.invoke(cmd_ci, [
|
||||
join("examples", "wiring-blink", "src", "main.cpp"), "-b", "metro",
|
||||
"--build-dir", build_dir, "--keep-build-dir"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_ci,
|
||||
[
|
||||
join("examples", "wiring-blink", "src", "main.cpp"),
|
||||
"-b",
|
||||
"metro",
|
||||
"--build-dir",
|
||||
build_dir,
|
||||
"--keep-build-dir",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
|
||||
assert "board: uno" in result.output
|
||||
@@ -64,10 +90,14 @@ def test_ci_keep_build_dir(clirunner, tmpdir_factory, validate_cliresult):
|
||||
|
||||
def test_ci_project_conf(clirunner, validate_cliresult):
|
||||
project_dir = join("examples", "wiring-blink")
|
||||
result = clirunner.invoke(cmd_ci, [
|
||||
join(project_dir, "src", "main.cpp"), "--project-conf",
|
||||
join(project_dir, "platformio.ini")
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_ci,
|
||||
[
|
||||
join(project_dir, "src", "main.cpp"),
|
||||
"--project-conf",
|
||||
join(project_dir, "platformio.ini"),
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
assert "uno" in result.output
|
||||
|
||||
@@ -75,12 +105,24 @@ def test_ci_project_conf(clirunner, validate_cliresult):
|
||||
def test_ci_lib_and_board(clirunner, tmpdir_factory, validate_cliresult):
|
||||
storage_dir = str(tmpdir_factory.mktemp("lib"))
|
||||
result = clirunner.invoke(
|
||||
cmd_lib, ["--storage-dir", storage_dir, "install", "1@2.3.2"])
|
||||
cmd_lib, ["--storage-dir", storage_dir, "install", "1@2.3.2"]
|
||||
)
|
||||
validate_cliresult(result)
|
||||
|
||||
result = clirunner.invoke(cmd_ci, [
|
||||
join(storage_dir, "OneWire_ID1", "examples", "DS2408_Switch",
|
||||
"DS2408_Switch.pde"), "-l",
|
||||
join(storage_dir, "OneWire_ID1"), "-b", "uno"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_ci,
|
||||
[
|
||||
join(
|
||||
storage_dir,
|
||||
"OneWire_ID1",
|
||||
"examples",
|
||||
"DS2408_Switch",
|
||||
"DS2408_Switch.pde",
|
||||
),
|
||||
"-l",
|
||||
join(storage_dir, "OneWire_ID1"),
|
||||
"-b",
|
||||
"uno",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
+27
-26
@@ -25,8 +25,7 @@ from platformio.project.config import ProjectConfig
|
||||
def validate_pioproject(pioproject_dir):
|
||||
pioconf_path = join(pioproject_dir, "platformio.ini")
|
||||
assert isfile(pioconf_path) and getsize(pioconf_path) > 0
|
||||
assert isdir(join(pioproject_dir, "src")) and isdir(
|
||||
join(pioproject_dir, "lib"))
|
||||
assert isdir(join(pioproject_dir, "src")) and isdir(join(pioproject_dir, "lib"))
|
||||
|
||||
|
||||
def test_init_default(clirunner, validate_cliresult):
|
||||
@@ -66,18 +65,17 @@ def test_init_ide_without_board(clirunner, tmpdir):
|
||||
def test_init_ide_atom(clirunner, validate_cliresult, tmpdir):
|
||||
with tmpdir.as_cwd():
|
||||
result = clirunner.invoke(
|
||||
cmd_init, ["--ide", "atom", "-b", "uno", "-b", "teensy31"])
|
||||
cmd_init, ["--ide", "atom", "-b", "uno", "-b", "teensy31"]
|
||||
)
|
||||
validate_cliresult(result)
|
||||
validate_pioproject(str(tmpdir))
|
||||
assert all([
|
||||
tmpdir.join(f).check()
|
||||
for f in (".clang_complete", ".gcc-flags.json")
|
||||
])
|
||||
assert all(
|
||||
[tmpdir.join(f).check() for f in (".clang_complete", ".gcc-flags.json")]
|
||||
)
|
||||
assert "arduinoavr" in tmpdir.join(".clang_complete").read()
|
||||
|
||||
# switch to NodeMCU
|
||||
result = clirunner.invoke(cmd_init,
|
||||
["--ide", "atom", "-b", "nodemcuv2"])
|
||||
result = clirunner.invoke(cmd_init, ["--ide", "atom", "-b", "nodemcuv2"])
|
||||
validate_cliresult(result)
|
||||
validate_pioproject(str(tmpdir))
|
||||
assert "arduinoespressif" in tmpdir.join(".clang_complete").read()
|
||||
@@ -110,46 +108,49 @@ def test_init_special_board(clirunner, validate_cliresult):
|
||||
config = ProjectConfig(join(getcwd(), "platformio.ini"))
|
||||
config.validate()
|
||||
|
||||
expected_result = dict(platform=str(boards[0]['platform']),
|
||||
board="uno",
|
||||
framework=[str(boards[0]['frameworks'][0])])
|
||||
expected_result = dict(
|
||||
platform=str(boards[0]["platform"]),
|
||||
board="uno",
|
||||
framework=[str(boards[0]["frameworks"][0])],
|
||||
)
|
||||
assert config.has_section("env:uno")
|
||||
assert sorted(config.items(env="uno", as_dict=True).items()) == sorted(
|
||||
expected_result.items())
|
||||
expected_result.items()
|
||||
)
|
||||
|
||||
|
||||
def test_init_enable_auto_uploading(clirunner, validate_cliresult):
|
||||
with clirunner.isolated_filesystem():
|
||||
result = clirunner.invoke(
|
||||
cmd_init, ["-b", "uno", "--project-option", "targets=upload"])
|
||||
cmd_init, ["-b", "uno", "--project-option", "targets=upload"]
|
||||
)
|
||||
validate_cliresult(result)
|
||||
validate_pioproject(getcwd())
|
||||
config = ProjectConfig(join(getcwd(), "platformio.ini"))
|
||||
config.validate()
|
||||
expected_result = dict(targets=["upload"],
|
||||
platform="atmelavr",
|
||||
board="uno",
|
||||
framework=["arduino"])
|
||||
expected_result = dict(
|
||||
targets=["upload"], platform="atmelavr", board="uno", framework=["arduino"]
|
||||
)
|
||||
assert config.has_section("env:uno")
|
||||
assert sorted(config.items(env="uno", as_dict=True).items()) == sorted(
|
||||
expected_result.items())
|
||||
expected_result.items()
|
||||
)
|
||||
|
||||
|
||||
def test_init_custom_framework(clirunner, validate_cliresult):
|
||||
with clirunner.isolated_filesystem():
|
||||
result = clirunner.invoke(
|
||||
cmd_init, ["-b", "teensy31", "--project-option", "framework=mbed"])
|
||||
cmd_init, ["-b", "teensy31", "--project-option", "framework=mbed"]
|
||||
)
|
||||
validate_cliresult(result)
|
||||
validate_pioproject(getcwd())
|
||||
config = ProjectConfig(join(getcwd(), "platformio.ini"))
|
||||
config.validate()
|
||||
expected_result = dict(platform="teensy",
|
||||
board="teensy31",
|
||||
framework=["mbed"])
|
||||
expected_result = dict(platform="teensy", board="teensy31", framework=["mbed"])
|
||||
assert config.has_section("env:teensy31")
|
||||
assert sorted(config.items(env="teensy31",
|
||||
as_dict=True).items()) == sorted(
|
||||
expected_result.items())
|
||||
assert sorted(config.items(env="teensy31", as_dict=True).items()) == sorted(
|
||||
expected_result.items()
|
||||
)
|
||||
|
||||
|
||||
def test_init_incorrect_board(clirunner):
|
||||
|
||||
+163
-94
@@ -28,19 +28,25 @@ def test_search(clirunner, validate_cliresult):
|
||||
match = re.search(r"Found\s+(\d+)\slibraries:", result.output)
|
||||
assert int(match.group(1)) > 2
|
||||
|
||||
result = clirunner.invoke(cmd_lib,
|
||||
["search", "DHT22", "--platform=timsp430"])
|
||||
result = clirunner.invoke(cmd_lib, ["search", "DHT22", "--platform=timsp430"])
|
||||
validate_cliresult(result)
|
||||
match = re.search(r"Found\s+(\d+)\slibraries:", result.output)
|
||||
assert int(match.group(1)) > 1
|
||||
|
||||
|
||||
def test_global_install_registry(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
result = clirunner.invoke(cmd_lib, [
|
||||
"-g", "install", "64", "ArduinoJson@~5.10.0", "547@2.2.4",
|
||||
"AsyncMqttClient@<=0.8.2", "999@77d4eb3f8a"
|
||||
])
|
||||
def test_global_install_registry(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
[
|
||||
"-g",
|
||||
"install",
|
||||
"64",
|
||||
"ArduinoJson@~5.10.0",
|
||||
"547@2.2.4",
|
||||
"AsyncMqttClient@<=0.8.2",
|
||||
"999@77d4eb3f8a",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
|
||||
# install unknown library
|
||||
@@ -50,29 +56,40 @@ def test_global_install_registry(clirunner, validate_cliresult,
|
||||
|
||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
||||
items2 = [
|
||||
"ArduinoJson_ID64", "ArduinoJson_ID64@5.10.1", "NeoPixelBus_ID547",
|
||||
"AsyncMqttClient_ID346", "ESPAsyncTCP_ID305", "AsyncTCP_ID1826",
|
||||
"RFcontrol_ID999"
|
||||
"ArduinoJson_ID64",
|
||||
"ArduinoJson_ID64@5.10.1",
|
||||
"NeoPixelBus_ID547",
|
||||
"AsyncMqttClient_ID346",
|
||||
"ESPAsyncTCP_ID305",
|
||||
"AsyncTCP_ID1826",
|
||||
"RFcontrol_ID999",
|
||||
]
|
||||
assert set(items1) == set(items2)
|
||||
|
||||
|
||||
def test_global_install_archive(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
result = clirunner.invoke(cmd_lib, [
|
||||
"-g", "install",
|
||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip",
|
||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip@5.8.2",
|
||||
"SomeLib=http://dl.platformio.org/libraries/archives/0/9540.tar.gz",
|
||||
"https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip"
|
||||
])
|
||||
def test_global_install_archive(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
[
|
||||
"-g",
|
||||
"install",
|
||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip",
|
||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip@5.8.2",
|
||||
"SomeLib=http://dl.platformio.org/libraries/archives/0/9540.tar.gz",
|
||||
"https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
|
||||
# incorrect requirements
|
||||
result = clirunner.invoke(cmd_lib, [
|
||||
"-g", "install",
|
||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip@1.2.3"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
[
|
||||
"-g",
|
||||
"install",
|
||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip@1.2.3",
|
||||
],
|
||||
)
|
||||
assert result.exit_code != 0
|
||||
|
||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
||||
@@ -80,8 +97,7 @@ def test_global_install_archive(clirunner, validate_cliresult,
|
||||
assert set(items1) >= set(items2)
|
||||
|
||||
|
||||
def test_global_install_repository(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
def test_global_install_repository(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
[
|
||||
@@ -93,24 +109,28 @@ def test_global_install_repository(clirunner, validate_cliresult,
|
||||
"https://gitlab.com/ivankravets/rs485-nodeproto.git",
|
||||
"https://github.com/platformio/platformio-libmirror.git",
|
||||
# "https://developer.mbed.org/users/simon/code/TextLCD/",
|
||||
"knolleary/pubsubclient#bef58148582f956dfa772687db80c44e2279a163"
|
||||
])
|
||||
"knolleary/pubsubclient#bef58148582f956dfa772687db80c44e2279a163",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
||||
items2 = [
|
||||
"PJON", "PJON@src-79de467ebe19de18287becff0a1fb42d",
|
||||
"ArduinoJson@src-69ebddd821f771debe7ee734d3c7fa81", "rs485-nodeproto",
|
||||
"platformio-libmirror", "PubSubClient"
|
||||
"PJON",
|
||||
"PJON@src-79de467ebe19de18287becff0a1fb42d",
|
||||
"ArduinoJson@src-69ebddd821f771debe7ee734d3c7fa81",
|
||||
"rs485-nodeproto",
|
||||
"platformio-libmirror",
|
||||
"PubSubClient",
|
||||
]
|
||||
assert set(items1) >= set(items2)
|
||||
|
||||
|
||||
def test_install_duplicates(clirunner, validate_cliresult, without_internet):
|
||||
# registry
|
||||
result = clirunner.invoke(cmd_lib, [
|
||||
"-g", "install",
|
||||
"http://dl.platformio.org/libraries/archives/0/9540.tar.gz"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
["-g", "install", "http://dl.platformio.org/libraries/archives/0/9540.tar.gz"],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
assert "is already installed" in result.output
|
||||
|
||||
@@ -120,18 +140,22 @@ def test_install_duplicates(clirunner, validate_cliresult, without_internet):
|
||||
assert "is already installed" in result.output
|
||||
|
||||
# archive
|
||||
result = clirunner.invoke(cmd_lib, [
|
||||
"-g", "install",
|
||||
"https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
[
|
||||
"-g",
|
||||
"install",
|
||||
"https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
assert "is already installed" in result.output
|
||||
|
||||
# repository
|
||||
result = clirunner.invoke(cmd_lib, [
|
||||
"-g", "install",
|
||||
"https://github.com/platformio/platformio-libmirror.git"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
["-g", "install", "https://github.com/platformio/platformio-libmirror.git"],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
assert "is already installed" in result.output
|
||||
|
||||
@@ -139,27 +163,48 @@ def test_install_duplicates(clirunner, validate_cliresult, without_internet):
|
||||
def test_global_lib_list(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cmd_lib, ["-g", "list"])
|
||||
validate_cliresult(result)
|
||||
assert all([
|
||||
n in result.output for n in
|
||||
("Source: https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip",
|
||||
"Version: 5.10.1",
|
||||
"Source: git+https://github.com/gioblu/PJON.git#3.0",
|
||||
"Version: 1fb26fd")
|
||||
])
|
||||
assert all(
|
||||
[
|
||||
n in result.output
|
||||
for n in (
|
||||
"Source: https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip",
|
||||
"Version: 5.10.1",
|
||||
"Source: git+https://github.com/gioblu/PJON.git#3.0",
|
||||
"Version: 1fb26fd",
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
result = clirunner.invoke(cmd_lib, ["-g", "list", "--json-output"])
|
||||
assert all([
|
||||
n in result.output for n in
|
||||
("__pkg_dir",
|
||||
'"__src_url": "git+https://gitlab.com/ivankravets/rs485-nodeproto.git"',
|
||||
'"version": "5.10.1"')
|
||||
])
|
||||
items1 = [i['name'] for i in json.loads(result.output)]
|
||||
assert all(
|
||||
[
|
||||
n in result.output
|
||||
for n in (
|
||||
"__pkg_dir",
|
||||
'"__src_url": "git+https://gitlab.com/ivankravets/rs485-nodeproto.git"',
|
||||
'"version": "5.10.1"',
|
||||
)
|
||||
]
|
||||
)
|
||||
items1 = [i["name"] for i in json.loads(result.output)]
|
||||
items2 = [
|
||||
"ESP32WebServer", "ArduinoJson", "ArduinoJson", "ArduinoJson",
|
||||
"ArduinoJson", "AsyncMqttClient", "AsyncTCP", "SomeLib", "ESPAsyncTCP",
|
||||
"NeoPixelBus", "OneWire", "PJON", "PJON", "PubSubClient", "RFcontrol",
|
||||
"platformio-libmirror", "rs485-nodeproto"
|
||||
"ESP32WebServer",
|
||||
"ArduinoJson",
|
||||
"ArduinoJson",
|
||||
"ArduinoJson",
|
||||
"ArduinoJson",
|
||||
"AsyncMqttClient",
|
||||
"AsyncTCP",
|
||||
"SomeLib",
|
||||
"ESPAsyncTCP",
|
||||
"NeoPixelBus",
|
||||
"OneWire",
|
||||
"PJON",
|
||||
"PJON",
|
||||
"PubSubClient",
|
||||
"RFcontrol",
|
||||
"platformio-libmirror",
|
||||
"rs485-nodeproto",
|
||||
]
|
||||
assert sorted(items1) == sorted(items2)
|
||||
|
||||
@@ -167,33 +212,37 @@ def test_global_lib_list(clirunner, validate_cliresult):
|
||||
"{name}@{version}".format(**item) for item in json.loads(result.output)
|
||||
]
|
||||
versions2 = [
|
||||
"ArduinoJson@5.8.2", "ArduinoJson@5.10.1", "AsyncMqttClient@0.8.2",
|
||||
"NeoPixelBus@2.2.4", "PJON@07fe9aa", "PJON@1fb26fd",
|
||||
"PubSubClient@bef5814", "RFcontrol@77d4eb3f8a"
|
||||
"ArduinoJson@5.8.2",
|
||||
"ArduinoJson@5.10.1",
|
||||
"AsyncMqttClient@0.8.2",
|
||||
"NeoPixelBus@2.2.4",
|
||||
"PJON@07fe9aa",
|
||||
"PJON@1fb26fd",
|
||||
"PubSubClient@bef5814",
|
||||
"RFcontrol@77d4eb3f8a",
|
||||
]
|
||||
assert set(versions1) >= set(versions2)
|
||||
|
||||
|
||||
def test_global_lib_update_check(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(
|
||||
cmd_lib, ["-g", "update", "--only-check", "--json-output"])
|
||||
cmd_lib, ["-g", "update", "--only-check", "--json-output"]
|
||||
)
|
||||
validate_cliresult(result)
|
||||
output = json.loads(result.output)
|
||||
assert set(["RFcontrol",
|
||||
"NeoPixelBus"]) == set([l['name'] for l in output])
|
||||
assert set(["RFcontrol", "NeoPixelBus"]) == set([l["name"] for l in output])
|
||||
|
||||
|
||||
def test_global_lib_update(clirunner, validate_cliresult):
|
||||
# update library using package directory
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
["-g", "update", "NeoPixelBus", "--only-check", "--json-output"])
|
||||
cmd_lib, ["-g", "update", "NeoPixelBus", "--only-check", "--json-output"]
|
||||
)
|
||||
validate_cliresult(result)
|
||||
oudated = json.loads(result.output)
|
||||
assert len(oudated) == 1
|
||||
assert "__pkg_dir" in oudated[0]
|
||||
result = clirunner.invoke(cmd_lib,
|
||||
["-g", "update", oudated[0]['__pkg_dir']])
|
||||
result = clirunner.invoke(cmd_lib, ["-g", "update", oudated[0]["__pkg_dir"]])
|
||||
validate_cliresult(result)
|
||||
assert "Uninstalling NeoPixelBus @ 2.2.4" in result.output
|
||||
|
||||
@@ -210,31 +259,43 @@ def test_global_lib_update(clirunner, validate_cliresult):
|
||||
assert isinstance(result.exception, exception.UnknownPackage)
|
||||
|
||||
|
||||
def test_global_lib_uninstall(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
def test_global_lib_uninstall(clirunner, validate_cliresult, isolated_pio_home):
|
||||
# uninstall using package directory
|
||||
result = clirunner.invoke(cmd_lib, ["-g", "list", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
items = json.loads(result.output)
|
||||
result = clirunner.invoke(cmd_lib,
|
||||
["-g", "uninstall", items[5]['__pkg_dir']])
|
||||
result = clirunner.invoke(cmd_lib, ["-g", "uninstall", items[5]["__pkg_dir"]])
|
||||
validate_cliresult(result)
|
||||
assert "Uninstalling AsyncTCP" in result.output
|
||||
|
||||
# uninstall the rest libraries
|
||||
result = clirunner.invoke(cmd_lib, [
|
||||
"-g", "uninstall", "1", "https://github.com/bblanchon/ArduinoJson.git",
|
||||
"ArduinoJson@!=5.6.7", "RFcontrol"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cmd_lib,
|
||||
[
|
||||
"-g",
|
||||
"uninstall",
|
||||
"1",
|
||||
"https://github.com/bblanchon/ArduinoJson.git",
|
||||
"ArduinoJson@!=5.6.7",
|
||||
"RFcontrol",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
|
||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
||||
items2 = [
|
||||
"rs485-nodeproto", "platformio-libmirror",
|
||||
"PubSubClient", "ArduinoJson@src-69ebddd821f771debe7ee734d3c7fa81",
|
||||
"ESPAsyncTCP_ID305", "SomeLib_ID54", "NeoPixelBus_ID547", "PJON",
|
||||
"AsyncMqttClient_ID346", "ArduinoJson_ID64",
|
||||
"PJON@src-79de467ebe19de18287becff0a1fb42d", "ESP32WebServer"
|
||||
"rs485-nodeproto",
|
||||
"platformio-libmirror",
|
||||
"PubSubClient",
|
||||
"ArduinoJson@src-69ebddd821f771debe7ee734d3c7fa81",
|
||||
"ESPAsyncTCP_ID305",
|
||||
"SomeLib_ID54",
|
||||
"NeoPixelBus_ID547",
|
||||
"PJON",
|
||||
"AsyncMqttClient_ID346",
|
||||
"ArduinoJson_ID64",
|
||||
"PJON@src-79de467ebe19de18287becff0a1fb42d",
|
||||
"ESP32WebServer",
|
||||
]
|
||||
assert set(items1) == set(items2)
|
||||
|
||||
@@ -247,8 +308,7 @@ def test_global_lib_uninstall(clirunner, validate_cliresult,
|
||||
def test_lib_show(clirunner, validate_cliresult):
|
||||
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", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
assert "OneWire" in result.output
|
||||
@@ -264,14 +324,23 @@ def test_lib_builtin(clirunner, validate_cliresult):
|
||||
def test_lib_stats(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cmd_lib, ["stats"])
|
||||
validate_cliresult(result)
|
||||
assert all([
|
||||
s in result.output
|
||||
for s in ("UPDATED", "POPULAR", "https://platformio.org/lib/show")
|
||||
])
|
||||
assert all(
|
||||
[
|
||||
s in result.output
|
||||
for s in ("UPDATED", "POPULAR", "https://platformio.org/lib/show")
|
||||
]
|
||||
)
|
||||
|
||||
result = clirunner.invoke(cmd_lib, ["stats", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
assert set([
|
||||
"dlweek", "added", "updated", "topkeywords", "dlmonth", "dlday",
|
||||
"lastkeywords"
|
||||
]) == set(json.loads(result.output).keys())
|
||||
assert set(
|
||||
[
|
||||
"dlweek",
|
||||
"added",
|
||||
"updated",
|
||||
"topkeywords",
|
||||
"dlmonth",
|
||||
"dlday",
|
||||
"lastkeywords",
|
||||
]
|
||||
) == set(json.loads(result.output).keys())
|
||||
@@ -19,13 +19,14 @@ from platformio.commands import platform as cli_platform
|
||||
|
||||
|
||||
def test_search_json_output(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_search,
|
||||
["arduino", "--json-output"])
|
||||
result = clirunner.invoke(
|
||||
cli_platform.platform_search, ["arduino", "--json-output"]
|
||||
)
|
||||
validate_cliresult(result)
|
||||
search_result = json.loads(result.output)
|
||||
assert isinstance(search_result, list)
|
||||
assert search_result
|
||||
platforms = [item['name'] for item in search_result]
|
||||
platforms = [item["name"] for item in search_result]
|
||||
assert "atmelsam" in platforms
|
||||
|
||||
|
||||
@@ -36,25 +37,22 @@ 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"])
|
||||
result = clirunner.invoke(cli_platform.platform_install, ["atmelavr@99.99.99"])
|
||||
assert result.exit_code != 0
|
||||
assert isinstance(result.exception, exception.UndefinedPackageVersion)
|
||||
|
||||
|
||||
def test_install_unknown_from_registry(clirunner):
|
||||
result = clirunner.invoke(cli_platform.platform_install,
|
||||
["unknown-platform"])
|
||||
result = clirunner.invoke(cli_platform.platform_install, ["unknown-platform"])
|
||||
assert result.exit_code != 0
|
||||
assert isinstance(result.exception, exception.UnknownPackage)
|
||||
|
||||
|
||||
def test_install_known_version(clirunner, validate_cliresult,
|
||||
isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_install, [
|
||||
"atmelavr@1.2.0", "--skip-default-package", "--with-package",
|
||||
"tool-avrdude"
|
||||
])
|
||||
def test_install_known_version(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(
|
||||
cli_platform.platform_install,
|
||||
["atmelavr@1.2.0", "--skip-default-package", "--with-package", "tool-avrdude"],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
assert "atmelavr @ 1.2.0" in result.output
|
||||
assert "Installing tool-avrdude @" in result.output
|
||||
@@ -62,10 +60,13 @@ def test_install_known_version(clirunner, validate_cliresult,
|
||||
|
||||
|
||||
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"
|
||||
])
|
||||
result = clirunner.invoke(
|
||||
cli_platform.platform_install,
|
||||
[
|
||||
"https://github.com/platformio/" "platform-espressif8266.git#feature/stage",
|
||||
"--skip-default-package",
|
||||
],
|
||||
)
|
||||
validate_cliresult(result)
|
||||
assert "espressif8266" in result.output
|
||||
assert len(isolated_pio_home.join("packages").listdir()) == 1
|
||||
@@ -77,24 +78,24 @@ def test_list_json_output(clirunner, validate_cliresult):
|
||||
list_result = json.loads(result.output)
|
||||
assert isinstance(list_result, list)
|
||||
assert list_result
|
||||
platforms = [item['name'] for item in list_result]
|
||||
platforms = [item["name"] for item in list_result]
|
||||
assert set(["atmelavr", "espressif8266"]) == set(platforms)
|
||||
|
||||
|
||||
def test_list_raw_output(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cli_platform.platform_list)
|
||||
validate_cliresult(result)
|
||||
assert all(
|
||||
[s in result.output for s in ("atmelavr", "espressif8266")])
|
||||
assert all([s in result.output for s in ("atmelavr", "espressif8266")])
|
||||
|
||||
|
||||
def test_update_check(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_update,
|
||||
["--only-check", "--json-output"])
|
||||
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"
|
||||
assert output[0]["name"] == "atmelavr"
|
||||
assert len(isolated_pio_home.join("packages").listdir()) == 1
|
||||
|
||||
|
||||
@@ -107,7 +108,8 @@ def test_update_raw(clirunner, validate_cliresult, isolated_pio_home):
|
||||
|
||||
|
||||
def test_uninstall(clirunner, validate_cliresult, isolated_pio_home):
|
||||
result = clirunner.invoke(cli_platform.platform_uninstall,
|
||||
["atmelavr", "espressif8266"])
|
||||
result = clirunner.invoke(
|
||||
cli_platform.platform_uninstall, ["atmelavr", "espressif8266"]
|
||||
)
|
||||
validate_cliresult(result)
|
||||
assert not isolated_pio_home.join("platforms").listdir()
|
||||
@@ -20,11 +20,18 @@ from platformio import util
|
||||
|
||||
|
||||
def test_local_env():
|
||||
result = util.exec_command([
|
||||
"platformio", "test", "-d",
|
||||
join("examples", "unit-testing", "calculator"), "-e", "native"
|
||||
])
|
||||
if result['returncode'] != 1:
|
||||
result = util.exec_command(
|
||||
[
|
||||
"platformio",
|
||||
"test",
|
||||
"-d",
|
||||
join("examples", "unit-testing", "calculator"),
|
||||
"-e",
|
||||
"native",
|
||||
]
|
||||
)
|
||||
if result["returncode"] != 1:
|
||||
pytest.fail(result)
|
||||
assert all([s in result['err']
|
||||
for s in ("PASSED", "IGNORED", "FAILED")]), result['out']
|
||||
assert all([s in result["err"] for s in ("PASSED", "IGNORED", "FAILED")]), result[
|
||||
"out"
|
||||
]
|
||||
+4
-7
@@ -22,12 +22,9 @@ from platformio import util
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def validate_cliresult():
|
||||
|
||||
def decorator(result):
|
||||
assert result.exit_code == 0, "{} => {}".format(
|
||||
result.exception, result.output)
|
||||
assert not result.exception, "{} => {}".format(result.exception,
|
||||
result.output)
|
||||
assert result.exit_code == 0, "{} => {}".format(result.exception, result.output)
|
||||
assert not result.exception, "{} => {}".format(result.exception, result.output)
|
||||
|
||||
return decorator
|
||||
|
||||
@@ -40,10 +37,10 @@ def clirunner():
|
||||
@pytest.fixture(scope="module")
|
||||
def isolated_pio_home(request, tmpdir_factory):
|
||||
home_dir = tmpdir_factory.mktemp(".platformio")
|
||||
os.environ['PLATFORMIO_CORE_DIR'] = str(home_dir)
|
||||
os.environ["PLATFORMIO_CORE_DIR"] = str(home_dir)
|
||||
|
||||
def fin():
|
||||
del os.environ['PLATFORMIO_CORE_DIR']
|
||||
del os.environ["PLATFORMIO_CORE_DIR"]
|
||||
|
||||
request.addfinalizer(fin)
|
||||
return home_dir
|
||||
|
||||
+35
-24
@@ -16,27 +16,34 @@ from platformio.commands.run import cli as cmd_run
|
||||
|
||||
|
||||
def test_build_flags(clirunner, validate_cliresult, tmpdir):
|
||||
build_flags = [("-D TEST_INT=13", "-DTEST_INT=13"),
|
||||
("-DTEST_SINGLE_MACRO", "-DTEST_SINGLE_MACRO"),
|
||||
('-DTEST_STR_SPACE="Andrew Smith"',
|
||||
'"-DTEST_STR_SPACE=Andrew Smith"')]
|
||||
build_flags = [
|
||||
("-D TEST_INT=13", "-DTEST_INT=13"),
|
||||
("-DTEST_SINGLE_MACRO", "-DTEST_SINGLE_MACRO"),
|
||||
('-DTEST_STR_SPACE="Andrew Smith"', '"-DTEST_STR_SPACE=Andrew Smith"'),
|
||||
]
|
||||
|
||||
tmpdir.join("platformio.ini").write("""
|
||||
tmpdir.join("platformio.ini").write(
|
||||
"""
|
||||
[env:native]
|
||||
platform = native
|
||||
extra_scripts = extra.py
|
||||
build_flags =
|
||||
; -DCOMMENTED_MACRO
|
||||
%s ; inline comment
|
||||
""" % " ".join([f[0] for f in build_flags]))
|
||||
"""
|
||||
% " ".join([f[0] for f in build_flags])
|
||||
)
|
||||
|
||||
tmpdir.join("extra.py").write("""
|
||||
tmpdir.join("extra.py").write(
|
||||
"""
|
||||
Import("projenv")
|
||||
|
||||
projenv.Append(CPPDEFINES="POST_SCRIPT_MACRO")
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
tmpdir.mkdir("src").join("main.cpp").write("""
|
||||
tmpdir.mkdir("src").join("main.cpp").write(
|
||||
"""
|
||||
#if !defined(TEST_INT) || TEST_INT != 13
|
||||
#error "TEST_INT"
|
||||
#endif
|
||||
@@ -55,26 +62,28 @@ projenv.Append(CPPDEFINES="POST_SCRIPT_MACRO")
|
||||
|
||||
int main() {
|
||||
}
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
result = clirunner.invoke(
|
||||
cmd_run, ["--project-dir", str(tmpdir), "--verbose"])
|
||||
result = clirunner.invoke(cmd_run, ["--project-dir", str(tmpdir), "--verbose"])
|
||||
validate_cliresult(result)
|
||||
build_output = result.output[result.output.find(
|
||||
"Scanning dependencies..."):]
|
||||
build_output = result.output[result.output.find("Scanning dependencies...") :]
|
||||
for flag in build_flags:
|
||||
assert flag[1] in build_output, flag
|
||||
|
||||
|
||||
def test_build_unflags(clirunner, validate_cliresult, tmpdir):
|
||||
tmpdir.join("platformio.ini").write("""
|
||||
tmpdir.join("platformio.ini").write(
|
||||
"""
|
||||
[env:native]
|
||||
platform = native
|
||||
build_unflags = -DTMP_MACRO1=45 -I. -DNON_EXISTING_MACRO -lunknownLib -Os
|
||||
extra_scripts = pre:extra.py
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
tmpdir.join("extra.py").write("""
|
||||
tmpdir.join("extra.py").write(
|
||||
"""
|
||||
Import("env")
|
||||
env.Append(CPPPATH="%s")
|
||||
env.Append(CPPDEFINES="TMP_MACRO1")
|
||||
@@ -82,22 +91,24 @@ env.Append(CPPDEFINES=["TMP_MACRO2"])
|
||||
env.Append(CPPDEFINES=("TMP_MACRO3", 13))
|
||||
env.Append(CCFLAGS=["-Os"])
|
||||
env.Append(LIBS=["unknownLib"])
|
||||
""" % str(tmpdir))
|
||||
"""
|
||||
% str(tmpdir)
|
||||
)
|
||||
|
||||
tmpdir.mkdir("src").join("main.c").write("""
|
||||
tmpdir.mkdir("src").join("main.c").write(
|
||||
"""
|
||||
#ifdef TMP_MACRO1
|
||||
#error "TMP_MACRO1 should be removed"
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
}
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
result = clirunner.invoke(
|
||||
cmd_run, ["--project-dir", str(tmpdir), "--verbose"])
|
||||
result = clirunner.invoke(cmd_run, ["--project-dir", str(tmpdir), "--verbose"])
|
||||
validate_cliresult(result)
|
||||
build_output = result.output[result.output.find(
|
||||
"Scanning dependencies..."):]
|
||||
build_output = result.output[result.output.find("Scanning dependencies...") :]
|
||||
assert "-DTMP_MACRO1" not in build_output
|
||||
assert "-Os" not in build_output
|
||||
assert str(tmpdir) not in build_output
|
||||
+9
-11
@@ -35,12 +35,12 @@ def pytest_generate_tests(metafunc):
|
||||
|
||||
# dev/platforms
|
||||
for manifest in PlatformManager().get_installed():
|
||||
p = PlatformFactory.newPlatform(manifest['__pkg_dir'])
|
||||
p = PlatformFactory.newPlatform(manifest["__pkg_dir"])
|
||||
ignore_conds = [
|
||||
not p.is_embedded(),
|
||||
p.name == "ststm8",
|
||||
# issue with "version `CXXABI_1.3.9' not found (required by sdcc)"
|
||||
"linux" in util.get_systype() and p.name == "intel_mcs51"
|
||||
"linux" in util.get_systype() and p.name == "intel_mcs51",
|
||||
]
|
||||
if any(ignore_conds):
|
||||
continue
|
||||
@@ -61,10 +61,9 @@ def pytest_generate_tests(metafunc):
|
||||
candidates[group] = []
|
||||
candidates[group].append(root)
|
||||
|
||||
project_dirs.extend([
|
||||
random.choice(examples) for examples in candidates.values()
|
||||
if examples
|
||||
])
|
||||
project_dirs.extend(
|
||||
[random.choice(examples) for examples in candidates.values() if examples]
|
||||
)
|
||||
|
||||
metafunc.parametrize("pioproject_dir", sorted(project_dirs))
|
||||
|
||||
@@ -76,12 +75,11 @@ def test_run(pioproject_dir):
|
||||
if isdir(build_dir):
|
||||
util.rmtree_(build_dir)
|
||||
|
||||
env_names = ProjectConfig(join(pioproject_dir,
|
||||
"platformio.ini")).envs()
|
||||
env_names = ProjectConfig(join(pioproject_dir, "platformio.ini")).envs()
|
||||
result = util.exec_command(
|
||||
["platformio", "run", "-e",
|
||||
random.choice(env_names)])
|
||||
if result['returncode'] != 0:
|
||||
["platformio", "run", "-e", random.choice(env_names)]
|
||||
)
|
||||
if result["returncode"] != 0:
|
||||
pytest.fail(str(result))
|
||||
|
||||
assert isdir(build_dir)
|
||||
|
||||
@@ -37,14 +37,10 @@ def test_example(clirunner, validate_cliresult, piotest_dir):
|
||||
|
||||
|
||||
def test_warning_line(clirunner, validate_cliresult):
|
||||
result = clirunner.invoke(cmd_ci,
|
||||
[join(INOTEST_DIR, "basic"), "-b", "uno"])
|
||||
result = clirunner.invoke(cmd_ci, [join(INOTEST_DIR, "basic"), "-b", "uno"])
|
||||
validate_cliresult(result)
|
||||
assert ('basic.ino:16:14: warning: #warning "Line number is 16"' in
|
||||
result.output)
|
||||
assert ('basic.ino:46:2: warning: #warning "Line number is 46"' in
|
||||
result.output)
|
||||
result = clirunner.invoke(
|
||||
cmd_ci, [join(INOTEST_DIR, "strmultilines"), "-b", "uno"])
|
||||
assert 'basic.ino:16:14: warning: #warning "Line number is 16"' in result.output
|
||||
assert 'basic.ino:46:2: warning: #warning "Line number is 46"' in result.output
|
||||
result = clirunner.invoke(cmd_ci, [join(INOTEST_DIR, "strmultilines"), "-b", "uno"])
|
||||
validate_cliresult(result)
|
||||
assert ('main.ino:75:2: warning: #warning "Line 75"' in result.output)
|
||||
assert 'main.ino:75:2: warning: #warning "Line 75"' in result.output
|
||||
+15
-22
@@ -23,7 +23,6 @@ from platformio.managers.platform import PlatformManager
|
||||
|
||||
|
||||
def test_check_pio_upgrade(clirunner, isolated_pio_home, validate_cliresult):
|
||||
|
||||
def _patch_pio_version(version):
|
||||
maintenance.__version__ = version
|
||||
cmd_upgrade.VERSION = version.split(".", 3)
|
||||
@@ -54,8 +53,7 @@ def test_check_pio_upgrade(clirunner, isolated_pio_home, validate_cliresult):
|
||||
|
||||
def test_check_lib_updates(clirunner, isolated_pio_home, validate_cliresult):
|
||||
# install obsolete library
|
||||
result = clirunner.invoke(cli_pio,
|
||||
["lib", "-g", "install", "ArduinoJson@<5.7"])
|
||||
result = clirunner.invoke(cli_pio, ["lib", "-g", "install", "ArduinoJson@<5.7"])
|
||||
validate_cliresult(result)
|
||||
|
||||
# reset check time
|
||||
@@ -65,15 +63,14 @@ def test_check_lib_updates(clirunner, isolated_pio_home, validate_cliresult):
|
||||
|
||||
result = clirunner.invoke(cli_pio, ["lib", "-g", "list"])
|
||||
validate_cliresult(result)
|
||||
assert ("There are the new updates for libraries (ArduinoJson)" in
|
||||
result.output)
|
||||
assert "There are the new updates for libraries (ArduinoJson)" in result.output
|
||||
|
||||
|
||||
def test_check_and_update_libraries(clirunner, isolated_pio_home,
|
||||
validate_cliresult):
|
||||
def test_check_and_update_libraries(clirunner, isolated_pio_home, validate_cliresult):
|
||||
# enable library auto-updates
|
||||
result = clirunner.invoke(
|
||||
cli_pio, ["settings", "set", "auto_update_libraries", "Yes"])
|
||||
cli_pio, ["settings", "set", "auto_update_libraries", "Yes"]
|
||||
)
|
||||
|
||||
# reset check time
|
||||
interval = int(app.get_setting("check_libraries_interval")) * 3600 * 24
|
||||
@@ -89,27 +86,23 @@ def test_check_and_update_libraries(clirunner, isolated_pio_home,
|
||||
# initiate auto-updating
|
||||
result = clirunner.invoke(cli_pio, ["lib", "-g", "show", "ArduinoJson"])
|
||||
validate_cliresult(result)
|
||||
assert ("There are the new updates for libraries (ArduinoJson)" in
|
||||
result.output)
|
||||
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 ArduinoJson\s+@ 5.6.7\s+\[[\d\.]+\]",
|
||||
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"])
|
||||
validate_cliresult(result)
|
||||
assert prev_data[0]['version'] != json.loads(result.output)[0]['version']
|
||||
assert prev_data[0]["version"] != json.loads(result.output)[0]["version"]
|
||||
|
||||
|
||||
def test_check_platform_updates(clirunner, isolated_pio_home,
|
||||
validate_cliresult):
|
||||
def test_check_platform_updates(clirunner, isolated_pio_home, validate_cliresult):
|
||||
# install obsolete platform
|
||||
result = clirunner.invoke(cli_pio, ["platform", "install", "native"])
|
||||
validate_cliresult(result)
|
||||
manifest_path = isolated_pio_home.join("platforms", "native",
|
||||
"platform.json")
|
||||
manifest_path = isolated_pio_home.join("platforms", "native", "platform.json")
|
||||
manifest = json.loads(manifest_path.read())
|
||||
manifest['version'] = "0.0.0"
|
||||
manifest["version"] = "0.0.0"
|
||||
manifest_path.write(json.dumps(manifest))
|
||||
# reset cached manifests
|
||||
PlatformManager().cache_reset()
|
||||
@@ -124,11 +117,11 @@ def test_check_platform_updates(clirunner, isolated_pio_home,
|
||||
assert "There are the new updates for platforms (native)" in result.output
|
||||
|
||||
|
||||
def test_check_and_update_platforms(clirunner, isolated_pio_home,
|
||||
validate_cliresult):
|
||||
def test_check_and_update_platforms(clirunner, isolated_pio_home, validate_cliresult):
|
||||
# enable library auto-updates
|
||||
result = clirunner.invoke(
|
||||
cli_pio, ["settings", "set", "auto_update_platforms", "Yes"])
|
||||
cli_pio, ["settings", "set", "auto_update_platforms", "Yes"]
|
||||
)
|
||||
|
||||
# reset check time
|
||||
interval = int(app.get_setting("check_platforms_interval")) * 3600 * 24
|
||||
@@ -151,4 +144,4 @@ def test_check_and_update_platforms(clirunner, isolated_pio_home,
|
||||
# check updated version
|
||||
result = clirunner.invoke(cli_pio, ["platform", "list", "--json-output"])
|
||||
validate_cliresult(result)
|
||||
assert prev_data[0]['version'] != json.loads(result.output)[0]['version']
|
||||
assert prev_data[0]["version"] != json.loads(result.output)[0]["version"]
|
||||
+83
-82
@@ -29,126 +29,134 @@ def test_pkg_input_parser():
|
||||
["id=13@~1.2.3", ("id=13", "~1.2.3", None)],
|
||||
[
|
||||
get_project_core_dir(),
|
||||
(".platformio", None, "file://" + get_project_core_dir())
|
||||
(".platformio", None, "file://" + get_project_core_dir()),
|
||||
],
|
||||
[
|
||||
"LocalName=" + get_project_core_dir(),
|
||||
("LocalName", None, "file://" + get_project_core_dir())
|
||||
("LocalName", None, "file://" + get_project_core_dir()),
|
||||
],
|
||||
[
|
||||
"LocalName=%s@>2.3.0" % get_project_core_dir(),
|
||||
("LocalName", ">2.3.0", "file://" + get_project_core_dir())
|
||||
("LocalName", ">2.3.0", "file://" + get_project_core_dir()),
|
||||
],
|
||||
[
|
||||
"https://github.com/user/package.git",
|
||||
("package", None, "git+https://github.com/user/package.git")
|
||||
("package", None, "git+https://github.com/user/package.git"),
|
||||
],
|
||||
[
|
||||
"MyPackage=https://gitlab.com/user/package.git",
|
||||
("MyPackage", None, "git+https://gitlab.com/user/package.git")
|
||||
("MyPackage", None, "git+https://gitlab.com/user/package.git"),
|
||||
],
|
||||
[
|
||||
"MyPackage=https://gitlab.com/user/package.git@3.2.1,!=2",
|
||||
("MyPackage", "3.2.1,!=2",
|
||||
"git+https://gitlab.com/user/package.git")
|
||||
("MyPackage", "3.2.1,!=2", "git+https://gitlab.com/user/package.git"),
|
||||
],
|
||||
[
|
||||
"https://somedomain.com/path/LibraryName-1.2.3.zip",
|
||||
("LibraryName-1.2.3", None,
|
||||
"https://somedomain.com/path/LibraryName-1.2.3.zip")
|
||||
(
|
||||
"LibraryName-1.2.3",
|
||||
None,
|
||||
"https://somedomain.com/path/LibraryName-1.2.3.zip",
|
||||
),
|
||||
],
|
||||
[
|
||||
"https://github.com/user/package/archive/branch.zip",
|
||||
("branch", None,
|
||||
"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.zip@~1.2.3",
|
||||
("branch", "~1.2.3",
|
||||
"https://github.com/user/package/archive/branch.zip")
|
||||
("branch", "~1.2.3", "https://github.com/user/package/archive/branch.zip"),
|
||||
],
|
||||
[
|
||||
"https://github.com/user/package/archive/branch.tar.gz",
|
||||
("branch.tar", None,
|
||||
"https://github.com/user/package/archive/branch.tar.gz")
|
||||
(
|
||||
"branch.tar",
|
||||
None,
|
||||
"https://github.com/user/package/archive/branch.tar.gz",
|
||||
),
|
||||
],
|
||||
[
|
||||
"https://github.com/user/package/archive/branch.tar.gz@!=5",
|
||||
("branch.tar", "!=5",
|
||||
"https://github.com/user/package/archive/branch.tar.gz")
|
||||
(
|
||||
"branch.tar",
|
||||
"!=5",
|
||||
"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/")
|
||||
("package", None, "hg+https://developer.mbed.org/users/user/code/package/"),
|
||||
],
|
||||
[
|
||||
"https://os.mbed.com/users/user/code/package/",
|
||||
("package", None,
|
||||
"hg+https://os.mbed.com/users/user/code/package/")
|
||||
("package", None, "hg+https://os.mbed.com/users/user/code/package/"),
|
||||
],
|
||||
[
|
||||
"https://github.com/user/package#v1.2.3",
|
||||
("package", None, "git+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")
|
||||
("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")
|
||||
],
|
||||
[
|
||||
"user/package",
|
||||
("package", None, "git+https://github.com/user/package")
|
||||
("PkgName", None, "git+https://github.com/user/package.git#a13d344fg56"),
|
||||
],
|
||||
["user/package", ("package", None, "git+https://github.com/user/package")],
|
||||
[
|
||||
"PkgName=user/package",
|
||||
("PkgName", None, "git+https://github.com/user/package")
|
||||
("PkgName", None, "git+https://github.com/user/package"),
|
||||
],
|
||||
[
|
||||
"PkgName=user/package#master",
|
||||
("PkgName", None, "git+https://github.com/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")
|
||||
("package", None, "git+https://github.com/user/package"),
|
||||
],
|
||||
[
|
||||
"hg+https://example.com/user/package",
|
||||
("package", None, "hg+https://example.com/user/package")
|
||||
("package", None, "hg+https://example.com/user/package"),
|
||||
],
|
||||
[
|
||||
"git@github.com:user/package.git",
|
||||
("package", None, "git+git@github.com:user/package.git")
|
||||
("package", None, "git+git@github.com:user/package.git"),
|
||||
],
|
||||
[
|
||||
"git@github.com:user/package.git#v1.2.0",
|
||||
("package", None, "git+git@github.com:user/package.git#v1.2.0")
|
||||
("package", None, "git+git@github.com:user/package.git#v1.2.0"),
|
||||
],
|
||||
[
|
||||
"LocalName=git@github.com:user/package.git#v1.2.0@~1.2.0",
|
||||
("LocalName", "~1.2.0",
|
||||
"git+git@github.com:user/package.git#v1.2.0")
|
||||
("LocalName", "~1.2.0", "git+git@github.com:user/package.git#v1.2.0"),
|
||||
],
|
||||
[
|
||||
"git+ssh://git@gitlab.private-server.com/user/package#1.2.0",
|
||||
("package", None,
|
||||
"git+ssh://git@gitlab.private-server.com/user/package#1.2.0")
|
||||
(
|
||||
"package",
|
||||
None,
|
||||
"git+ssh://git@gitlab.private-server.com/user/package#1.2.0",
|
||||
),
|
||||
],
|
||||
[
|
||||
"git+ssh://user@gitlab.private-server.com:1234/package#1.2.0",
|
||||
("package", None,
|
||||
"git+ssh://user@gitlab.private-server.com:1234/package#1.2.0")
|
||||
(
|
||||
"package",
|
||||
None,
|
||||
"git+ssh://user@gitlab.private-server.com:1234/package#1.2.0",
|
||||
),
|
||||
],
|
||||
[
|
||||
"LocalName=git+ssh://user@gitlab.private-server.com:1234"
|
||||
"/package#1.2.0@!=13",
|
||||
("LocalName", "!=13",
|
||||
"git+ssh://user@gitlab.private-server.com:1234/package#1.2.0")
|
||||
]
|
||||
(
|
||||
"LocalName",
|
||||
"!=13",
|
||||
"git+ssh://user@gitlab.private-server.com:1234/package#1.2.0",
|
||||
),
|
||||
],
|
||||
]
|
||||
for params, result in items:
|
||||
if isinstance(params, tuple):
|
||||
@@ -165,62 +173,55 @@ def test_install_packages(isolated_pio_home, tmpdir):
|
||||
dict(id=1, name="name_1", version="1.2"),
|
||||
dict(id=1, name="name_1", version="1.0.0"),
|
||||
dict(name="name_2", version="1.0.0"),
|
||||
dict(name="name_2",
|
||||
version="2.0.0",
|
||||
__src_url="git+https://github.com"),
|
||||
dict(name="name_2",
|
||||
version="3.0.0",
|
||||
__src_url="git+https://github2.com"),
|
||||
dict(name="name_2",
|
||||
version="4.0.0",
|
||||
__src_url="git+https://github2.com")
|
||||
dict(name="name_2", version="2.0.0", __src_url="git+https://github.com"),
|
||||
dict(name="name_2", version="3.0.0", __src_url="git+https://github2.com"),
|
||||
dict(name="name_2", version="4.0.0", __src_url="git+https://github2.com"),
|
||||
]
|
||||
|
||||
pm = PackageManager(join(get_project_core_dir(), "packages"))
|
||||
for package in packages:
|
||||
tmp_dir = tmpdir.mkdir("tmp-package")
|
||||
tmp_dir.join("package.json").write(json.dumps(package))
|
||||
pm._install_from_url(package['name'], "file://%s" % str(tmp_dir))
|
||||
pm._install_from_url(package["name"], "file://%s" % str(tmp_dir))
|
||||
tmp_dir.remove(rec=1)
|
||||
|
||||
assert len(pm.get_installed()) == len(packages) - 1
|
||||
|
||||
pkg_dirnames = [
|
||||
'name_1_ID1', 'name_1_ID1@1.0.0', 'name_1_ID1@1.2', 'name_1_ID1@2.0.0',
|
||||
'name_1_ID1@shasum', 'name_2',
|
||||
'name_2@src-177cbce1f0705580d17790fda1cc2ef5',
|
||||
'name_2@src-f863b537ab00f4c7b5011fc44b120e1f'
|
||||
"name_1_ID1",
|
||||
"name_1_ID1@1.0.0",
|
||||
"name_1_ID1@1.2",
|
||||
"name_1_ID1@2.0.0",
|
||||
"name_1_ID1@shasum",
|
||||
"name_2",
|
||||
"name_2@src-177cbce1f0705580d17790fda1cc2ef5",
|
||||
"name_2@src-f863b537ab00f4c7b5011fc44b120e1f",
|
||||
]
|
||||
assert set([
|
||||
p.basename for p in isolated_pio_home.join("packages").listdir()
|
||||
]) == set(pkg_dirnames)
|
||||
assert set(
|
||||
[p.basename for p in isolated_pio_home.join("packages").listdir()]
|
||||
) == set(pkg_dirnames)
|
||||
|
||||
|
||||
def test_get_package():
|
||||
tests = [
|
||||
[("unknown", ), None],
|
||||
[("1", ), None],
|
||||
[("id=1", "shasum"),
|
||||
dict(id=1, name="name_1", version="shasum")],
|
||||
[("id=1", "*"),
|
||||
dict(id=1, name="name_1", version="2.1.0")],
|
||||
[("id=1", "^1"),
|
||||
dict(id=1, name="name_1", version="1.2")],
|
||||
[("id=1", "^1"),
|
||||
dict(id=1, name="name_1", version="1.2")],
|
||||
[("name_1", "<2"),
|
||||
dict(id=1, name="name_1", version="1.2")],
|
||||
[("unknown",), None],
|
||||
[("1",), None],
|
||||
[("id=1", "shasum"), dict(id=1, name="name_1", version="shasum")],
|
||||
[("id=1", "*"), dict(id=1, name="name_1", version="2.1.0")],
|
||||
[("id=1", "^1"), dict(id=1, name="name_1", version="1.2")],
|
||||
[("id=1", "^1"), dict(id=1, name="name_1", version="1.2")],
|
||||
[("name_1", "<2"), dict(id=1, name="name_1", version="1.2")],
|
||||
[("name_1", ">2"), None],
|
||||
[("name_1", "2-0-0"), None],
|
||||
[("name_2", ), dict(name="name_2", version="4.0.0")],
|
||||
[("url_has_higher_priority", None, "git+https://github.com"),
|
||||
dict(name="name_2",
|
||||
version="2.0.0",
|
||||
__src_url="git+https://github.com")],
|
||||
[("name_2", None, "git+https://github.com"),
|
||||
dict(name="name_2",
|
||||
version="2.0.0",
|
||||
__src_url="git+https://github.com")],
|
||||
[("name_2",), dict(name="name_2", version="4.0.0")],
|
||||
[
|
||||
("url_has_higher_priority", None, "git+https://github.com"),
|
||||
dict(name="name_2", version="2.0.0", __src_url="git+https://github.com"),
|
||||
],
|
||||
[
|
||||
("name_2", None, "git+https://github.com"),
|
||||
dict(name="name_2", version="2.0.0", __src_url="git+https://github.com"),
|
||||
],
|
||||
]
|
||||
|
||||
pm = PackageManager(join(get_project_core_dir(), "packages"))
|
||||
|
||||
+3
-3
@@ -20,8 +20,8 @@ from platformio import exception, util
|
||||
|
||||
def test_platformio_cli():
|
||||
result = util.exec_command(["pio", "--help"])
|
||||
assert result['returncode'] == 0
|
||||
assert "Usage: pio [OPTIONS] COMMAND [ARGS]..." in result['out']
|
||||
assert result["returncode"] == 0
|
||||
assert "Usage: pio [OPTIONS] COMMAND [ARGS]..." in result["out"]
|
||||
|
||||
|
||||
def test_ping_internet_ips():
|
||||
@@ -38,5 +38,5 @@ def test_api_cache(monkeypatch, isolated_pio_home):
|
||||
api_kwargs = {"url": "/stats", "cache_valid": "10s"}
|
||||
result = util.get_api_result(**api_kwargs)
|
||||
assert result and "boards" in result
|
||||
monkeypatch.setattr(util, '_internet_on', lambda: False)
|
||||
monkeypatch.setattr(util, "_internet_on", lambda: False)
|
||||
assert util.get_api_result(**api_kwargs) == result
|
||||
@@ -18,14 +18,14 @@ import requests
|
||||
|
||||
def validate_response(r):
|
||||
assert r.status_code == 200, r.url
|
||||
assert int(r.headers['Content-Length']) > 0, r.url
|
||||
assert r.headers['Content-Type'] in ("application/gzip",
|
||||
"application/octet-stream")
|
||||
assert int(r.headers["Content-Length"]) > 0, r.url
|
||||
assert r.headers["Content-Type"] in ("application/gzip", "application/octet-stream")
|
||||
|
||||
|
||||
def test_packages():
|
||||
pkgs_manifest = requests.get(
|
||||
"https://dl.bintray.com/platformio/dl-packages/manifest.json").json()
|
||||
"https://dl.bintray.com/platformio/dl-packages/manifest.json"
|
||||
).json()
|
||||
assert isinstance(pkgs_manifest, dict)
|
||||
items = []
|
||||
for _, variants in pkgs_manifest.items():
|
||||
@@ -33,12 +33,12 @@ def test_packages():
|
||||
items.append(item)
|
||||
|
||||
for item in items:
|
||||
assert item['url'].endswith(".tar.gz"), item
|
||||
assert item["url"].endswith(".tar.gz"), item
|
||||
|
||||
r = requests.head(item['url'], allow_redirects=True)
|
||||
r = requests.head(item["url"], allow_redirects=True)
|
||||
validate_response(r)
|
||||
|
||||
if "X-Checksum-Sha1" not in r.headers:
|
||||
return pytest.skip("X-Checksum-Sha1 is not provided")
|
||||
|
||||
assert item['sha1'] == r.headers.get("X-Checksum-Sha1")[0:40], item
|
||||
assert item["sha1"] == r.headers.get("X-Checksum-Sha1")[0:40], item
|
||||
+35
-11
@@ -117,8 +117,16 @@ def test_sections(config):
|
||||
config.getraw("unknown_section", "unknown_option")
|
||||
|
||||
assert config.sections() == [
|
||||
"platformio", "env", "strict_ldf", "monitor_custom", "strict_settings",
|
||||
"custom", "env:base", "env:test_extends", "env:extra_1", "env:extra_2"
|
||||
"platformio",
|
||||
"env",
|
||||
"strict_ldf",
|
||||
"monitor_custom",
|
||||
"strict_settings",
|
||||
"custom",
|
||||
"env:base",
|
||||
"env:test_extends",
|
||||
"env:extra_1",
|
||||
"env:extra_2",
|
||||
]
|
||||
|
||||
|
||||
@@ -129,11 +137,20 @@ def test_envs(config):
|
||||
|
||||
def test_options(config):
|
||||
assert config.options(env="base") == [
|
||||
"build_flags", "targets", "monitor_speed", "lib_deps", "lib_ignore"
|
||||
"build_flags",
|
||||
"targets",
|
||||
"monitor_speed",
|
||||
"lib_deps",
|
||||
"lib_ignore",
|
||||
]
|
||||
assert config.options(env="test_extends") == [
|
||||
"extends", "build_flags", "lib_ldf_mode", "lib_compat_mode",
|
||||
"monitor_speed", "lib_deps", "lib_ignore"
|
||||
"extends",
|
||||
"build_flags",
|
||||
"lib_ldf_mode",
|
||||
"lib_compat_mode",
|
||||
"monitor_speed",
|
||||
"lib_deps",
|
||||
"lib_ignore",
|
||||
]
|
||||
|
||||
|
||||
@@ -154,15 +171,22 @@ def test_sysenv_options(config):
|
||||
os.environ["__PIO_TEST_CNF_EXTRA_FLAGS"] = "-L /usr/local/lib"
|
||||
assert config.get("custom", "extra_flags") == "-L /usr/local/lib"
|
||||
assert config.get("env:base", "build_flags") == [
|
||||
"-D DEBUG=1 -L /usr/local/lib", "-DSYSENVDEPS1 -DSYSENVDEPS2"
|
||||
"-D DEBUG=1 -L /usr/local/lib",
|
||||
"-DSYSENVDEPS1 -DSYSENVDEPS2",
|
||||
]
|
||||
assert config.get("env:base", "upload_port") == "/dev/sysenv/port"
|
||||
assert config.get("env:extra_2", "upload_port") == "/dev/extra_2/port"
|
||||
|
||||
# env var as option
|
||||
assert config.options(env="test_extends") == [
|
||||
"extends", "build_flags", "lib_ldf_mode", "lib_compat_mode",
|
||||
"monitor_speed", "lib_deps", "lib_ignore", "upload_port"
|
||||
"extends",
|
||||
"build_flags",
|
||||
"lib_ldf_mode",
|
||||
"lib_compat_mode",
|
||||
"monitor_speed",
|
||||
"lib_deps",
|
||||
"lib_ignore",
|
||||
"upload_port",
|
||||
]
|
||||
|
||||
# sysenv
|
||||
@@ -208,7 +232,7 @@ def test_items(config):
|
||||
("debug_flags", "-D DEBUG=1"),
|
||||
("lib_flags", "-lc -lm"),
|
||||
("extra_flags", None),
|
||||
("lib_ignore", "LibIgnoreCustom")
|
||||
("lib_ignore", "LibIgnoreCustom"),
|
||||
] # yapf: disable
|
||||
assert config.items(env="base") == [
|
||||
("build_flags", ["-D DEBUG=1"]),
|
||||
@@ -228,7 +252,7 @@ def test_items(config):
|
||||
("lib_ignore", ["LibIgnoreCustom", "Lib3"]),
|
||||
("upload_port", "/dev/extra_2/port"),
|
||||
("monitor_speed", "115200"),
|
||||
("lib_deps", ["Lib1", "Lib2"])
|
||||
("lib_deps", ["Lib1", "Lib2"]),
|
||||
] # yapf: disable
|
||||
assert config.items(env="test_extends") == [
|
||||
("extends", ["strict_settings"]),
|
||||
@@ -237,5 +261,5 @@ def test_items(config):
|
||||
("lib_compat_mode", "strict"),
|
||||
("monitor_speed", "9600"),
|
||||
("lib_deps", ["Lib1", "Lib2"]),
|
||||
("lib_ignore", ["LibIgnoreCustom"])
|
||||
("lib_ignore", ["LibIgnoreCustom"]),
|
||||
] # yapf: disable
|
||||
Reference in new issue
Block a user