Skip to content

Commit

Permalink
Fix "FileExistsError" when "platformio ci" command is used in pair wi…
Browse files Browse the repository at this point in the history
…th "--keep-build-dir" option
  • Loading branch information
ivankravets committed Mar 14, 2019
1 parent b3ac567 commit 0d904ad
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ PlatformIO 4.0
PlatformIO 3.0
--------------

3.6.6 (2019-??-??)
~~~~~~~~~~~~~~~~~~

* Fixed "FileExistsError" when `platformio ci <https://docs.platformio.org/en/latest/userguide/cmd_ci.html>`__ command is used in pair with ``--keep-build-dir`` option

3.6.5 (2019-03-07)
~~~~~~~~~~~~~~~~~~

Expand Down
4 changes: 2 additions & 2 deletions platformio/commands/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def validate_path(ctx, param, value): # pylint: disable=unused-argument
"--build-dir",
default=mkdtemp,
type=click.Path(
exists=True,
file_okay=False,
dir_okay=True,
writable=True,
Expand Down Expand Up @@ -134,7 +133,8 @@ def _copy_contents(dst_dir, contents):
if dst_dir_name == "src" and len(items['dirs']) == 1:
copytree(list(items['dirs']).pop(), dst_dir, symlinks=True)
else:
makedirs(dst_dir)
if not isdir(dst_dir):
makedirs(dst_dir)
for d in items['dirs']:
copytree(d, join(dst_dir, basename(d)), symlinks=True)

Expand Down
32 changes: 31 additions & 1 deletion tests/commands/test_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from os.path import join
from os.path import isfile, join

from platformio.commands.ci import cli as cmd_ci
from platformio.commands.lib import cli as cmd_lib
Expand All @@ -32,6 +32,36 @@ def test_ci_boards(clirunner, validate_cliresult):
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
])
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"
])
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"
])
validate_cliresult(result)

assert "board: uno" in result.output
assert "board: metro" in result.output


def test_ci_project_conf(clirunner, validate_cliresult):
project_dir = join("examples", "wiring-blink")
result = clirunner.invoke(cmd_ci, [
Expand Down

0 comments on commit 0d904ad

Please sign in to comment.