diff --git a/HISTORY.rst b/HISTORY.rst index 84ee3562..32e2aa8d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,11 @@ Release Notes PlatformIO 3.0 -------------- +3.6.6 (2019-??-??) +~~~~~~~~~~~~~~~~~~ + +* Fixed "FileExistsError" when `platformio ci `__ command is used in pair with ``--keep-build-dir`` option + 3.6.5 (2019-03-07) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/commands/ci.py b/platformio/commands/ci.py index 0b5b3e4e..13224fac 100644 --- a/platformio/commands/ci.py +++ b/platformio/commands/ci.py @@ -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, @@ -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) diff --git a/tests/commands/test_ci.py b/tests/commands/test_ci.py index ec4077ba..67ff4420 100644 --- a/tests/commands/test_ci.py +++ b/tests/commands/test_ci.py @@ -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 @@ -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, [