Fix "FileExistsError" when "platformio ci" command is used in pair with "--keep-build-dir" option

This commit is contained in:
Ivan Kravets
2019-03-14 20:12:18 +02:00
parent e37d34b92f
commit 326eb4a681
3 changed files with 38 additions and 3 deletions

View File

@ -4,6 +4,11 @@ Release Notes
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)
~~~~~~~~~~~~~~~~~~

View File

@ -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)

View File

@ -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, [