mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Enable PIO Core tests on Python 3.8
This commit is contained in:
2
.github/workflows/core.yml
vendored
2
.github/workflows/core.yml
vendored
@ -8,7 +8,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
python-version: [2.7, 3.7]
|
python-version: [2.7, 3.7, 3.8]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# pylint: disable=too-many-arguments,too-many-locals, too-many-branches
|
# pylint: disable=too-many-arguments,too-many-locals,too-many-branches,line-too-long
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -238,7 +238,6 @@ https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
|||||||
|
|
||||||
|
|
||||||
def init_lib_readme(lib_dir):
|
def init_lib_readme(lib_dir):
|
||||||
# pylint: disable=line-too-long
|
|
||||||
with open(os.path.join(lib_dir, "README"), "w") as fp:
|
with open(os.path.join(lib_dir, "README"), "w") as fp:
|
||||||
fp.write(
|
fp.write(
|
||||||
"""
|
"""
|
||||||
|
@ -62,7 +62,7 @@ def test_prepare():
|
|||||||
|
|
||||||
|
|
||||||
def test_account_register(
|
def test_account_register(
|
||||||
clirunner, validate_cliresult, receive_email, isolated_pio_home
|
clirunner, validate_cliresult, receive_email, isolated_pio_core
|
||||||
):
|
):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_account,
|
cmd_account,
|
||||||
@ -97,14 +97,14 @@ def test_account_register(
|
|||||||
|
|
||||||
|
|
||||||
def test_account_login(
|
def test_account_login(
|
||||||
clirunner, validate_cliresult, isolated_pio_home,
|
clirunner, validate_cliresult, isolated_pio_core,
|
||||||
):
|
):
|
||||||
result = clirunner.invoke(cmd_account, ["login", "-u", username, "-p", password],)
|
result = clirunner.invoke(cmd_account, ["login", "-u", username, "-p", password],)
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
|
|
||||||
|
|
||||||
def test_account_summary(
|
def test_account_summary(
|
||||||
clirunner, validate_cliresult, isolated_pio_home,
|
clirunner, validate_cliresult, isolated_pio_core,
|
||||||
):
|
):
|
||||||
result = clirunner.invoke(cmd_account, ["show", "--json-output", "--offline"])
|
result = clirunner.invoke(cmd_account, ["show", "--json-output", "--offline"])
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
@ -156,7 +156,7 @@ def test_account_summary(
|
|||||||
assert json_result.get("subscriptions") is not None
|
assert json_result.get("subscriptions") is not None
|
||||||
|
|
||||||
|
|
||||||
def test_account_token(clirunner, validate_cliresult, isolated_pio_home):
|
def test_account_token(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(cmd_account, ["token", "--password", password,],)
|
result = clirunner.invoke(cmd_account, ["token", "--password", password,],)
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
assert "Personal Authentication Token:" in result.output
|
assert "Personal Authentication Token:" in result.output
|
||||||
@ -198,7 +198,7 @@ def test_account_token(clirunner, validate_cliresult, isolated_pio_home):
|
|||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
|
|
||||||
|
|
||||||
def test_account_change_password(clirunner, validate_cliresult, isolated_pio_home):
|
def test_account_change_password(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
new_password = "Testpassword123"
|
new_password = "Testpassword123"
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_account,
|
cmd_account,
|
||||||
@ -222,7 +222,7 @@ def test_account_change_password(clirunner, validate_cliresult, isolated_pio_hom
|
|||||||
|
|
||||||
|
|
||||||
def test_account_update(
|
def test_account_update(
|
||||||
clirunner, validate_cliresult, receive_email, isolated_pio_home
|
clirunner, validate_cliresult, receive_email, isolated_pio_core
|
||||||
):
|
):
|
||||||
global username
|
global username
|
||||||
global email
|
global email
|
||||||
@ -281,7 +281,7 @@ def test_account_update(
|
|||||||
|
|
||||||
|
|
||||||
# def test_account_destroy_with_linked_resources(
|
# def test_account_destroy_with_linked_resources(
|
||||||
# clirunner, validate_cliresult, receive_email, isolated_pio_home, tmpdir_factory
|
# clirunner, validate_cliresult, receive_email, isolated_pio_core, tmpdir_factory
|
||||||
# ):
|
# ):
|
||||||
# package_url = "https://github.com/bblanchon/ArduinoJson/archive/v6.11.0.tar.gz"
|
# package_url = "https://github.com/bblanchon/ArduinoJson/archive/v6.11.0.tar.gz"
|
||||||
#
|
#
|
||||||
@ -312,14 +312,14 @@ def test_account_update(
|
|||||||
# validate_cliresult(result)
|
# validate_cliresult(result)
|
||||||
|
|
||||||
|
|
||||||
def test_org_create(clirunner, validate_cliresult, isolated_pio_home):
|
def test_org_create(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_org, ["create", "--email", email, "--displayname", display_name, orgname],
|
cmd_org, ["create", "--email", email, "--displayname", display_name, orgname],
|
||||||
)
|
)
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
|
|
||||||
|
|
||||||
def test_org_list(clirunner, validate_cliresult, isolated_pio_home):
|
def test_org_list(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
# pio org list
|
# pio org list
|
||||||
result = clirunner.invoke(cmd_org, ["list", "--json-output"])
|
result = clirunner.invoke(cmd_org, ["list", "--json-output"])
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
@ -336,7 +336,7 @@ def test_org_list(clirunner, validate_cliresult, isolated_pio_home):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_org_add_owner(clirunner, validate_cliresult, isolated_pio_home):
|
def test_org_add_owner(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(cmd_org, ["add", orgname, second_username])
|
result = clirunner.invoke(cmd_org, ["add", orgname, second_username])
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ def test_org_add_owner(clirunner, validate_cliresult, isolated_pio_home):
|
|||||||
assert second_username in result.output
|
assert second_username in result.output
|
||||||
|
|
||||||
|
|
||||||
def test_org_remove_owner(clirunner, validate_cliresult, isolated_pio_home):
|
def test_org_remove_owner(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(cmd_org, ["remove", orgname, second_username])
|
result = clirunner.invoke(cmd_org, ["remove", orgname, second_username])
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
|
|
||||||
@ -354,7 +354,7 @@ def test_org_remove_owner(clirunner, validate_cliresult, isolated_pio_home):
|
|||||||
assert second_username not in result.output
|
assert second_username not in result.output
|
||||||
|
|
||||||
|
|
||||||
def test_org_update(clirunner, validate_cliresult, isolated_pio_home):
|
def test_org_update(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
new_orgname = "neworg-piocore-%s" % str(random.randint(0, 100000))
|
new_orgname = "neworg-piocore-%s" % str(random.randint(0, 100000))
|
||||||
new_display_name = "Test Org for PIO Core"
|
new_display_name = "Test Org for PIO Core"
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ def test_org_update(clirunner, validate_cliresult, isolated_pio_home):
|
|||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
|
|
||||||
|
|
||||||
def test_team_create(clirunner, validate_cliresult, isolated_pio_home):
|
def test_team_create(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_team,
|
cmd_team,
|
||||||
["create", "%s:%s" % (orgname, teamname), "--description", team_description,],
|
["create", "%s:%s" % (orgname, teamname), "--description", team_description,],
|
||||||
@ -407,7 +407,7 @@ def test_team_create(clirunner, validate_cliresult, isolated_pio_home):
|
|||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
|
|
||||||
|
|
||||||
def test_team_list(clirunner, validate_cliresult, isolated_pio_home):
|
def test_team_list(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(cmd_team, ["list", "%s" % orgname, "--json-output"],)
|
result = clirunner.invoke(cmd_team, ["list", "%s" % orgname, "--json-output"],)
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
json_result = json.loads(result.output.strip())
|
json_result = json.loads(result.output.strip())
|
||||||
@ -418,7 +418,7 @@ def test_team_list(clirunner, validate_cliresult, isolated_pio_home):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_team_add_member(clirunner, validate_cliresult, isolated_pio_home):
|
def test_team_add_member(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_team, ["add", "%s:%s" % (orgname, teamname), second_username],
|
cmd_team, ["add", "%s:%s" % (orgname, teamname), second_username],
|
||||||
)
|
)
|
||||||
@ -429,7 +429,7 @@ def test_team_add_member(clirunner, validate_cliresult, isolated_pio_home):
|
|||||||
assert second_username in result.output
|
assert second_username in result.output
|
||||||
|
|
||||||
|
|
||||||
def test_team_remove(clirunner, validate_cliresult, isolated_pio_home):
|
def test_team_remove(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_team, ["remove", "%s:%s" % (orgname, teamname), second_username],
|
cmd_team, ["remove", "%s:%s" % (orgname, teamname), second_username],
|
||||||
)
|
)
|
||||||
@ -440,7 +440,7 @@ def test_team_remove(clirunner, validate_cliresult, isolated_pio_home):
|
|||||||
assert second_username not in result.output
|
assert second_username not in result.output
|
||||||
|
|
||||||
|
|
||||||
def test_team_update(clirunner, validate_cliresult, receive_email, isolated_pio_home):
|
def test_team_update(clirunner, validate_cliresult, receive_email, isolated_pio_core):
|
||||||
new_teamname = "new-" + str(random.randint(0, 100000))
|
new_teamname = "new-" + str(random.randint(0, 100000))
|
||||||
newteam_description = "Updated Description"
|
newteam_description = "Updated Description"
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
@ -479,7 +479,7 @@ def test_team_update(clirunner, validate_cliresult, receive_email, isolated_pio_
|
|||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
|
|
||||||
|
|
||||||
def test_cleanup(clirunner, validate_cliresult, receive_email, isolated_pio_home):
|
def test_cleanup(clirunner, validate_cliresult, receive_email, isolated_pio_core):
|
||||||
result = clirunner.invoke(cmd_team, ["destroy", "%s:%s" % (orgname, teamname)], "y")
|
result = clirunner.invoke(cmd_team, ["destroy", "%s:%s" % (orgname, teamname)], "y")
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
result = clirunner.invoke(cmd_org, ["destroy", orgname], "y")
|
result = clirunner.invoke(cmd_org, ["destroy", orgname], "y")
|
||||||
|
@ -357,7 +357,7 @@ int main() {
|
|||||||
assert low_result.exit_code != 0
|
assert low_result.exit_code != 0
|
||||||
|
|
||||||
|
|
||||||
def test_check_pvs_studio_free_license(clirunner, tmpdir):
|
def test_check_pvs_studio_free_license(clirunner, isolated_pio_core, tmpdir):
|
||||||
config = """
|
config = """
|
||||||
[env:test]
|
[env:test]
|
||||||
platform = teensy
|
platform = teensy
|
||||||
|
@ -24,7 +24,7 @@ def test_ci_empty(clirunner):
|
|||||||
assert "Invalid value: Missing argument 'src'" in result.output
|
assert "Invalid value: Missing argument 'src'" in result.output
|
||||||
|
|
||||||
|
|
||||||
def test_ci_boards(clirunner, validate_cliresult):
|
def test_ci_boards(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_ci,
|
cmd_ci,
|
||||||
[
|
[
|
||||||
@ -38,7 +38,7 @@ def test_ci_boards(clirunner, validate_cliresult):
|
|||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
|
|
||||||
|
|
||||||
def test_ci_build_dir(clirunner, tmpdir_factory, validate_cliresult):
|
def test_ci_build_dir(clirunner, tmpdir_factory, validate_cliresult, isolated_pio_core):
|
||||||
build_dir = str(tmpdir_factory.mktemp("ci_build_dir"))
|
build_dir = str(tmpdir_factory.mktemp("ci_build_dir"))
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_ci,
|
cmd_ci,
|
||||||
@ -54,7 +54,9 @@ def test_ci_build_dir(clirunner, tmpdir_factory, validate_cliresult):
|
|||||||
assert not isfile(join(build_dir, "platformio.ini"))
|
assert not isfile(join(build_dir, "platformio.ini"))
|
||||||
|
|
||||||
|
|
||||||
def test_ci_keep_build_dir(clirunner, tmpdir_factory, validate_cliresult):
|
def test_ci_keep_build_dir(
|
||||||
|
clirunner, tmpdir_factory, validate_cliresult, isolated_pio_core
|
||||||
|
):
|
||||||
build_dir = str(tmpdir_factory.mktemp("ci_build_dir"))
|
build_dir = str(tmpdir_factory.mktemp("ci_build_dir"))
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_ci,
|
cmd_ci,
|
||||||
@ -88,7 +90,7 @@ def test_ci_keep_build_dir(clirunner, tmpdir_factory, validate_cliresult):
|
|||||||
assert "board: metro" in result.output
|
assert "board: metro" in result.output
|
||||||
|
|
||||||
|
|
||||||
def test_ci_project_conf(clirunner, validate_cliresult):
|
def test_ci_project_conf(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
project_dir = join("examples", "wiring-blink")
|
project_dir = join("examples", "wiring-blink")
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_ci,
|
cmd_ci,
|
||||||
@ -102,7 +104,9 @@ def test_ci_project_conf(clirunner, validate_cliresult):
|
|||||||
assert "uno" in result.output
|
assert "uno" in result.output
|
||||||
|
|
||||||
|
|
||||||
def test_ci_lib_and_board(clirunner, tmpdir_factory, validate_cliresult):
|
def test_ci_lib_and_board(
|
||||||
|
clirunner, tmpdir_factory, validate_cliresult, isolated_pio_core
|
||||||
|
):
|
||||||
storage_dir = str(tmpdir_factory.mktemp("lib"))
|
storage_dir = str(tmpdir_factory.mktemp("lib"))
|
||||||
result = clirunner.invoke(
|
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"]
|
||||||
|
@ -34,7 +34,7 @@ def test_search(clirunner, validate_cliresult):
|
|||||||
assert int(match.group(1)) > 1
|
assert int(match.group(1)) > 1
|
||||||
|
|
||||||
|
|
||||||
def test_global_install_registry(clirunner, validate_cliresult, isolated_pio_home):
|
def test_global_install_registry(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_lib,
|
cmd_lib,
|
||||||
[
|
[
|
||||||
@ -54,7 +54,7 @@ def test_global_install_registry(clirunner, validate_cliresult, isolated_pio_hom
|
|||||||
assert result.exit_code != 0
|
assert result.exit_code != 0
|
||||||
assert isinstance(result.exception, exception.LibNotFound)
|
assert isinstance(result.exception, exception.LibNotFound)
|
||||||
|
|
||||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
items1 = [d.basename for d in isolated_pio_core.join("lib").listdir()]
|
||||||
items2 = [
|
items2 = [
|
||||||
"ArduinoJson_ID64",
|
"ArduinoJson_ID64",
|
||||||
"ArduinoJson_ID64@5.10.1",
|
"ArduinoJson_ID64@5.10.1",
|
||||||
@ -68,7 +68,7 @@ def test_global_install_registry(clirunner, validate_cliresult, isolated_pio_hom
|
|||||||
assert set(items1) == set(items2)
|
assert set(items1) == set(items2)
|
||||||
|
|
||||||
|
|
||||||
def test_global_install_archive(clirunner, validate_cliresult, isolated_pio_home):
|
def test_global_install_archive(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_lib,
|
cmd_lib,
|
||||||
[
|
[
|
||||||
@ -93,12 +93,12 @@ def test_global_install_archive(clirunner, validate_cliresult, isolated_pio_home
|
|||||||
)
|
)
|
||||||
assert result.exit_code != 0
|
assert result.exit_code != 0
|
||||||
|
|
||||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
items1 = [d.basename for d in isolated_pio_core.join("lib").listdir()]
|
||||||
items2 = ["ArduinoJson", "SomeLib_ID54", "OneWire_ID1", "ESP32WebServer"]
|
items2 = ["ArduinoJson", "SomeLib_ID54", "OneWire_ID1", "ESP32WebServer"]
|
||||||
assert set(items1) >= set(items2)
|
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_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_lib,
|
cmd_lib,
|
||||||
[
|
[
|
||||||
@ -114,7 +114,7 @@ def test_global_install_repository(clirunner, validate_cliresult, isolated_pio_h
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
items1 = [d.basename for d in isolated_pio_core.join("lib").listdir()]
|
||||||
items2 = [
|
items2 = [
|
||||||
"PJON",
|
"PJON",
|
||||||
"PJON@src-79de467ebe19de18287becff0a1fb42d",
|
"PJON@src-79de467ebe19de18287becff0a1fb42d",
|
||||||
@ -260,7 +260,7 @@ def test_global_lib_update(clirunner, validate_cliresult):
|
|||||||
assert isinstance(result.exception, exception.UnknownPackage)
|
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_core):
|
||||||
# uninstall using package directory
|
# uninstall using package directory
|
||||||
result = clirunner.invoke(cmd_lib, ["-g", "list", "--json-output"])
|
result = clirunner.invoke(cmd_lib, ["-g", "list", "--json-output"])
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
@ -284,7 +284,7 @@ def test_global_lib_uninstall(clirunner, validate_cliresult, isolated_pio_home):
|
|||||||
)
|
)
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
|
|
||||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
items1 = [d.basename for d in isolated_pio_core.join("lib").listdir()]
|
||||||
items2 = [
|
items2 = [
|
||||||
"rs485-nodeproto",
|
"rs485-nodeproto",
|
||||||
"platformio-libmirror",
|
"platformio-libmirror",
|
||||||
|
@ -18,7 +18,7 @@ from platformio import exception
|
|||||||
from platformio.commands import platform as cli_platform
|
from platformio.commands import platform as cli_platform
|
||||||
|
|
||||||
|
|
||||||
def test_search_json_output(clirunner, validate_cliresult, isolated_pio_home):
|
def test_search_json_output(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cli_platform.platform_search, ["arduino", "--json-output"]
|
cli_platform.platform_search, ["arduino", "--json-output"]
|
||||||
)
|
)
|
||||||
@ -48,7 +48,7 @@ def test_install_unknown_from_registry(clirunner):
|
|||||||
assert isinstance(result.exception, exception.UnknownPackage)
|
assert isinstance(result.exception, exception.UnknownPackage)
|
||||||
|
|
||||||
|
|
||||||
def test_install_known_version(clirunner, validate_cliresult, isolated_pio_home):
|
def test_install_known_version(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cli_platform.platform_install,
|
cli_platform.platform_install,
|
||||||
["atmelavr@1.2.0", "--skip-default-package", "--with-package", "tool-avrdude"],
|
["atmelavr@1.2.0", "--skip-default-package", "--with-package", "tool-avrdude"],
|
||||||
@ -56,10 +56,10 @@ def test_install_known_version(clirunner, validate_cliresult, isolated_pio_home)
|
|||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
assert "atmelavr @ 1.2.0" in result.output
|
assert "atmelavr @ 1.2.0" in result.output
|
||||||
assert "Installing tool-avrdude @" in result.output
|
assert "Installing tool-avrdude @" in result.output
|
||||||
assert len(isolated_pio_home.join("packages").listdir()) == 1
|
assert len(isolated_pio_core.join("packages").listdir()) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_install_from_vcs(clirunner, validate_cliresult, isolated_pio_home):
|
def test_install_from_vcs(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cli_platform.platform_install,
|
cli_platform.platform_install,
|
||||||
[
|
[
|
||||||
@ -69,7 +69,7 @@ def test_install_from_vcs(clirunner, validate_cliresult, isolated_pio_home):
|
|||||||
)
|
)
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
assert "espressif8266" in result.output
|
assert "espressif8266" in result.output
|
||||||
assert len(isolated_pio_home.join("packages").listdir()) == 1
|
assert len(isolated_pio_core.join("packages").listdir()) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_list_json_output(clirunner, validate_cliresult):
|
def test_list_json_output(clirunner, validate_cliresult):
|
||||||
@ -88,7 +88,7 @@ def test_list_raw_output(clirunner, validate_cliresult):
|
|||||||
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):
|
def test_update_check(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cli_platform.platform_update, ["--only-check", "--json-output"]
|
cli_platform.platform_update, ["--only-check", "--json-output"]
|
||||||
)
|
)
|
||||||
@ -96,20 +96,20 @@ def test_update_check(clirunner, validate_cliresult, isolated_pio_home):
|
|||||||
output = json.loads(result.output)
|
output = json.loads(result.output)
|
||||||
assert len(output) == 1
|
assert len(output) == 1
|
||||||
assert output[0]["name"] == "atmelavr"
|
assert output[0]["name"] == "atmelavr"
|
||||||
assert len(isolated_pio_home.join("packages").listdir()) == 1
|
assert len(isolated_pio_core.join("packages").listdir()) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_update_raw(clirunner, validate_cliresult, isolated_pio_home):
|
def test_update_raw(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(cli_platform.platform_update)
|
result = clirunner.invoke(cli_platform.platform_update)
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
assert "Uninstalling atmelavr @ 1.2.0:" in result.output
|
assert "Uninstalling atmelavr @ 1.2.0:" in result.output
|
||||||
assert "PlatformManager: Installing atmelavr @" in result.output
|
assert "PlatformManager: Installing atmelavr @" in result.output
|
||||||
assert len(isolated_pio_home.join("packages").listdir()) == 1
|
assert len(isolated_pio_core.join("packages").listdir()) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_uninstall(clirunner, validate_cliresult, isolated_pio_home):
|
def test_uninstall(clirunner, validate_cliresult, isolated_pio_core):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cli_platform.platform_uninstall, ["atmelavr", "espressif8266"]
|
cli_platform.platform_uninstall, ["atmelavr", "espressif8266"]
|
||||||
)
|
)
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
assert not isolated_pio_home.join("platforms").listdir()
|
assert not isolated_pio_core.join("platforms").listdir()
|
||||||
|
@ -20,7 +20,7 @@ from platformio import util
|
|||||||
from platformio.commands.test.command import cli as cmd_test
|
from platformio.commands.test.command import cli as cmd_test
|
||||||
|
|
||||||
|
|
||||||
def test_local_env():
|
def test_local_env(isolated_pio_core):
|
||||||
result = util.exec_command(
|
result = util.exec_command(
|
||||||
[
|
[
|
||||||
"platformio",
|
"platformio",
|
||||||
@ -38,7 +38,7 @@ def test_local_env():
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_multiple_env_build(clirunner, validate_cliresult, tmpdir):
|
def test_multiple_env_build(clirunner, validate_cliresult, isolated_pio_core, tmpdir):
|
||||||
|
|
||||||
project_dir = tmpdir.mkdir("project")
|
project_dir = tmpdir.mkdir("project")
|
||||||
project_dir.join("platformio.ini").write(
|
project_dir.join("platformio.ini").write(
|
||||||
@ -80,7 +80,9 @@ int main() {
|
|||||||
assert "Multiple ways to build" not in result.output
|
assert "Multiple ways to build" not in result.output
|
||||||
|
|
||||||
|
|
||||||
def test_setup_teardown_are_compilable(clirunner, validate_cliresult, tmpdir):
|
def test_setup_teardown_are_compilable(
|
||||||
|
clirunner, validate_cliresult, isolated_pio_core, tmpdir
|
||||||
|
):
|
||||||
|
|
||||||
project_dir = tmpdir.mkdir("project")
|
project_dir = tmpdir.mkdir("project")
|
||||||
project_dir.join("platformio.ini").write(
|
project_dir.join("platformio.ini").write(
|
||||||
|
@ -42,15 +42,28 @@ def clirunner():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def isolated_pio_home(request, tmpdir_factory):
|
def isolated_pio_core(request, tmpdir_factory):
|
||||||
home_dir = tmpdir_factory.mktemp(".platformio")
|
core_dir = tmpdir_factory.mktemp(".platformio")
|
||||||
os.environ["PLATFORMIO_CORE_DIR"] = str(home_dir)
|
backup_env_vars = {
|
||||||
|
"PLATFORMIO_CORE_DIR": {"new": str(core_dir)},
|
||||||
|
"PLATFORMIO_WORKSPACE_DIR": {"new": None},
|
||||||
|
}
|
||||||
|
for key, item in backup_env_vars.items():
|
||||||
|
backup_env_vars[key]["old"] = os.environ.get(key)
|
||||||
|
if item["new"] is not None:
|
||||||
|
os.environ[key] = item["new"]
|
||||||
|
elif key in os.environ:
|
||||||
|
del os.environ[key]
|
||||||
|
|
||||||
def fin():
|
def fin():
|
||||||
del os.environ["PLATFORMIO_CORE_DIR"]
|
for key, item in backup_env_vars.items():
|
||||||
|
if item["old"] is None:
|
||||||
|
del os.environ[key]
|
||||||
|
else:
|
||||||
|
os.environ[key] = item["old"]
|
||||||
|
|
||||||
request.addfinalizer(fin)
|
request.addfinalizer(fin)
|
||||||
return home_dir
|
return core_dir
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
|
@ -83,7 +83,7 @@ def test_library_json_parser():
|
|||||||
},
|
},
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{"name": "deps1", "version": "1.0.0"},
|
{"name": "deps1", "version": "1.0.0"},
|
||||||
{"name": "@owner/deps2", "version": "1.0.0", "frameworks": "arduino, espidf"},
|
{"name": "@owner/deps2", "version": "1.0.0", "platforms": "atmelavr, espressif32", "frameworks": "arduino, espidf"},
|
||||||
{"name": "deps3", "version": "1.0.0", "platforms": ["ststm32", "sifive"]}
|
{"name": "deps3", "version": "1.0.0", "platforms": ["ststm32", "sifive"]}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -101,6 +101,7 @@ def test_library_json_parser():
|
|||||||
{
|
{
|
||||||
"name": "@owner/deps2",
|
"name": "@owner/deps2",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
"platforms": ["atmelavr", "espressif32"],
|
||||||
"frameworks": ["arduino", "espidf"],
|
"frameworks": ["arduino", "espidf"],
|
||||||
},
|
},
|
||||||
{"name": "deps1", "version": "1.0.0"},
|
{"name": "deps1", "version": "1.0.0"},
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
from platformio.commands.run.command import cli as cmd_run
|
from platformio.commands.run.command import cli as cmd_run
|
||||||
|
|
||||||
|
|
||||||
def test_build_flags(clirunner, validate_cliresult, tmpdir):
|
def test_build_flags(clirunner, isolated_pio_core, validate_cliresult, tmpdir):
|
||||||
build_flags = [
|
build_flags = [
|
||||||
("-D TEST_INT=13", "-DTEST_INT=13"),
|
("-D TEST_INT=13", "-DTEST_INT=13"),
|
||||||
("-DTEST_SINGLE_MACRO", "-DTEST_SINGLE_MACRO"),
|
("-DTEST_SINGLE_MACRO", "-DTEST_SINGLE_MACRO"),
|
||||||
|
@ -31,12 +31,12 @@ def pytest_generate_tests(metafunc):
|
|||||||
metafunc.parametrize("piotest_dir", test_dirs)
|
metafunc.parametrize("piotest_dir", test_dirs)
|
||||||
|
|
||||||
|
|
||||||
def test_example(clirunner, validate_cliresult, piotest_dir):
|
def test_example(clirunner, isolated_pio_core, validate_cliresult, piotest_dir):
|
||||||
result = clirunner.invoke(cmd_ci, [piotest_dir, "-b", "uno"])
|
result = clirunner.invoke(cmd_ci, [piotest_dir, "-b", "uno"])
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
|
|
||||||
|
|
||||||
def test_warning_line(clirunner, validate_cliresult):
|
def test_warning_line(clirunner, isolated_pio_core, 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)
|
validate_cliresult(result)
|
||||||
assert 'basic.ino:16:14: warning: #warning "Line number is 16"' in result.output
|
assert 'basic.ino:16:14: warning: #warning "Line number is 16"' in result.output
|
||||||
|
@ -22,7 +22,7 @@ from platformio.commands import upgrade as cmd_upgrade
|
|||||||
from platformio.managers.platform import PlatformManager
|
from platformio.managers.platform import PlatformManager
|
||||||
|
|
||||||
|
|
||||||
def test_check_pio_upgrade(clirunner, isolated_pio_home, validate_cliresult):
|
def test_check_pio_upgrade(clirunner, isolated_pio_core, validate_cliresult):
|
||||||
def _patch_pio_version(version):
|
def _patch_pio_version(version):
|
||||||
maintenance.__version__ = version
|
maintenance.__version__ = version
|
||||||
cmd_upgrade.VERSION = version.split(".", 3)
|
cmd_upgrade.VERSION = version.split(".", 3)
|
||||||
@ -51,7 +51,7 @@ def test_check_pio_upgrade(clirunner, isolated_pio_home, validate_cliresult):
|
|||||||
_patch_pio_version(origin_version)
|
_patch_pio_version(origin_version)
|
||||||
|
|
||||||
|
|
||||||
def test_check_lib_updates(clirunner, isolated_pio_home, validate_cliresult):
|
def test_check_lib_updates(clirunner, isolated_pio_core, validate_cliresult):
|
||||||
# install obsolete library
|
# install obsolete library
|
||||||
result = clirunner.invoke(cli_pio, ["lib", "-g", "install", "ArduinoJson@<6.13"])
|
result = clirunner.invoke(cli_pio, ["lib", "-g", "install", "ArduinoJson@<6.13"])
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
@ -66,7 +66,7 @@ def test_check_lib_updates(clirunner, isolated_pio_home, validate_cliresult):
|
|||||||
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_core, validate_cliresult):
|
||||||
# enable library auto-updates
|
# enable library auto-updates
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cli_pio, ["settings", "set", "auto_update_libraries", "Yes"]
|
cli_pio, ["settings", "set", "auto_update_libraries", "Yes"]
|
||||||
@ -96,11 +96,11 @@ def test_check_and_update_libraries(clirunner, isolated_pio_home, validate_clire
|
|||||||
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_core, validate_cliresult):
|
||||||
# install obsolete platform
|
# install obsolete platform
|
||||||
result = clirunner.invoke(cli_pio, ["platform", "install", "native"])
|
result = clirunner.invoke(cli_pio, ["platform", "install", "native"])
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
manifest_path = isolated_pio_home.join("platforms", "native", "platform.json")
|
manifest_path = isolated_pio_core.join("platforms", "native", "platform.json")
|
||||||
manifest = json.loads(manifest_path.read())
|
manifest = json.loads(manifest_path.read())
|
||||||
manifest["version"] = "0.0.0"
|
manifest["version"] = "0.0.0"
|
||||||
manifest_path.write(json.dumps(manifest))
|
manifest_path.write(json.dumps(manifest))
|
||||||
@ -117,7 +117,7 @@ def test_check_platform_updates(clirunner, isolated_pio_home, validate_cliresult
|
|||||||
assert "There are the new updates for platforms (native)" in result.output
|
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_core, validate_cliresult):
|
||||||
# enable library auto-updates
|
# enable library auto-updates
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cli_pio, ["settings", "set", "auto_update_platforms", "Yes"]
|
cli_pio, ["settings", "set", "auto_update_platforms", "Yes"]
|
||||||
|
@ -165,7 +165,7 @@ def test_pkg_input_parser():
|
|||||||
assert PackageManager.parse_pkg_uri(params) == result
|
assert PackageManager.parse_pkg_uri(params) == result
|
||||||
|
|
||||||
|
|
||||||
def test_install_packages(isolated_pio_home, tmpdir):
|
def test_install_packages(isolated_pio_core, tmpdir):
|
||||||
packages = [
|
packages = [
|
||||||
dict(id=1, name="name_1", version="shasum"),
|
dict(id=1, name="name_1", version="shasum"),
|
||||||
dict(id=1, name="name_1", version="2.0.0"),
|
dict(id=1, name="name_1", version="2.0.0"),
|
||||||
@ -198,7 +198,7 @@ def test_install_packages(isolated_pio_home, tmpdir):
|
|||||||
"name_2@src-f863b537ab00f4c7b5011fc44b120e1f",
|
"name_2@src-f863b537ab00f4c7b5011fc44b120e1f",
|
||||||
]
|
]
|
||||||
assert set(
|
assert set(
|
||||||
[p.basename for p in isolated_pio_home.join("packages").listdir()]
|
[p.basename for p in isolated_pio_core.join("packages").listdir()]
|
||||||
) == set(pkg_dirnames)
|
) == set(pkg_dirnames)
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,12 +29,12 @@ def test_ping_internet_ips():
|
|||||||
requests.get("http://%s" % host, allow_redirects=False, timeout=2)
|
requests.get("http://%s" % host, allow_redirects=False, timeout=2)
|
||||||
|
|
||||||
|
|
||||||
def test_api_internet_offline(without_internet, isolated_pio_home):
|
def test_api_internet_offline(without_internet, isolated_pio_core):
|
||||||
with pytest.raises(exception.InternetIsOffline):
|
with pytest.raises(exception.InternetIsOffline):
|
||||||
util.get_api_result("/stats")
|
util.get_api_result("/stats")
|
||||||
|
|
||||||
|
|
||||||
def test_api_cache(monkeypatch, isolated_pio_home):
|
def test_api_cache(monkeypatch, isolated_pio_core):
|
||||||
api_kwargs = {"url": "/stats", "cache_valid": "10s"}
|
api_kwargs = {"url": "/stats", "cache_valid": "10s"}
|
||||||
result = util.get_api_result(**api_kwargs)
|
result = util.get_api_result(**api_kwargs)
|
||||||
assert result and "boards" in result
|
assert result and "boards" in result
|
||||||
|
Reference in New Issue
Block a user