Skip to content

Commit

Permalink
Addressed an issue where passing a relative path to the `pio project …
Browse files Browse the repository at this point in the history
…init` // Resolve #4847
  • Loading branch information
ivankravets committed Feb 7, 2024
1 parent 3e9ca48 commit 353f440
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ test-driven methodologies, and modern toolchains for unrivaled success.

* Broadened version support for the ``pyelftools`` dependency, enabling compatibility with lower versions and facilitating integration with a wider range of third-party tools (`issue #4834 <https://github.com/platformio/platformio-core/issues/4834>`_)
* Resolved an issue related to the relative package path in the `pio pkg publish <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_publish.html>`__ command
* Addressed an issue where passing a relative path (``--project-dir``) to the `pio project init <https://docs.platformio.org/en/latest/core/userguide/project/cmd_init.html>`__ command resulted in an error (`issue #4847 <https://github.com/platformio/platformio-core/issues/4847>`_)

6.1.13 (2024-01-12)
~~~~~~~~~~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions platformio/project/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def project_init_cmd(
env_prefix,
silent,
):
project_dir = os.path.abspath(project_dir)
is_new_project = not is_platformio_project(project_dir)
if is_new_project:
if not silent:
Expand Down
42 changes: 22 additions & 20 deletions tests/commands/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import json
import os

from platformio import fs
from platformio.commands.boards import cli as cmd_boards
from platformio.project.commands.init import project_init_cmd
from platformio.project.config import ProjectConfig
Expand All @@ -36,27 +37,28 @@ def test_init_default(clirunner, validate_cliresult):
validate_pioproject(os.getcwd())


def test_init_ext_folder(clirunner, validate_cliresult):
with clirunner.isolated_filesystem():
ext_folder_name = "ext_folder"
os.makedirs(ext_folder_name)
result = clirunner.invoke(project_init_cmd, ["-d", ext_folder_name])
validate_cliresult(result)
validate_pioproject(os.path.join(os.getcwd(), ext_folder_name))


def test_init_duplicated_boards(clirunner, validate_cliresult, tmpdir):
with tmpdir.as_cwd():
for _ in range(2):
result = clirunner.invoke(
project_init_cmd,
["-b", "uno", "-b", "uno", "--no-install-dependencies"],
)
validate_cliresult(result)
validate_pioproject(str(tmpdir))
config = ProjectConfig(os.path.join(os.getcwd(), "platformio.ini"))
config.validate()
assert set(config.sections()) == set(["env:uno"])
project_dir = str(tmpdir.join("ext_folder"))
os.makedirs(project_dir)

with fs.cd(os.path.dirname(project_dir)):
result = clirunner.invoke(
project_init_cmd,
[
"-d",
os.path.basename(project_dir),
"-b",
"uno",
"-b",
"uno",
"--no-install-dependencies",
],
)
validate_cliresult(result)
validate_pioproject(project_dir)
config = ProjectConfig(os.path.join(project_dir, "platformio.ini"))
config.validate()
assert set(config.sections()) == set(["env:uno"])


def test_init_ide_without_board(clirunner, tmpdir):
Expand Down

0 comments on commit 353f440

Please sign in to comment.