From bc930cc9d3c2500fd0b0d015a496d92d2223adae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Mon, 16 Sep 2024 15:36:46 +0200 Subject: [PATCH 1/2] Always quote raw args --- conan/internal/runner/docker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conan/internal/runner/docker.py b/conan/internal/runner/docker.py index b9f9ab8f1e4..215425a682d 100644 --- a/conan/internal/runner/docker.py +++ b/conan/internal/runner/docker.py @@ -112,7 +112,7 @@ def __init__(self, conan_api, command, host_profile, build_profile, args, raw_ar # Update conan command and some paths to run inside the container raw_args[raw_args.index(args.path)] = self.abs_docker_path - self.command = ' '.join([f'conan {command}'] + [f'"{raw_arg}"' if ' ' in raw_arg else raw_arg for raw_arg in raw_args] + ['-f json > create.json']) + self.command = ' '.join([f'conan {command}'] + [f'"{raw_arg}"' for raw_arg in raw_args] + ['-f json > create.json']) def run(self): """ From 0c4c10ba6e9bf574313131104f514843c6676a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Mon, 2 Dec 2024 18:12:43 +0100 Subject: [PATCH 2/2] Breaking test --- test/functional/command/runner_test.py | 59 ++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/test/functional/command/runner_test.py b/test/functional/command/runner_test.py index b385873c74a..77d68fd3f8d 100644 --- a/test/functional/command/runner_test.py +++ b/test/functional/command/runner_test.py @@ -2,6 +2,8 @@ import os import pytest import docker + +from conan.test.assets.genconanfile import GenConanfile from conan.test.utils.tools import TestClient from conan.test.assets.cmake import gen_cmakelists from conan.test.assets.sources import gen_function_h, gen_function_cpp @@ -541,3 +543,60 @@ def test_create_docker_runner_default_build_profile(): assert "Restore: pkg/0.2:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe" in client.out assert "Restore: pkg/0.2:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe metadata" in client.out assert "Removing container" in client.out + +@pytest.mark.docker_runner +@pytest.mark.skipif(docker_skip('ubuntu:22.04'), reason="Only docker running") +def test_create_docker_runner_special_chars(): + """ + Tests the ``conan create . `` with special characters + """ + client = TestClient() + profile_build = textwrap.dedent(f"""\ + [settings] + arch={{{{ detect_api.detect_arch() }}}} + build_type=Release + compiler=gcc + compiler.cppstd=gnu17 + compiler.libcxx=libstdc++11 + compiler.version=11 + os=Linux + """) + + profile_host = textwrap.dedent(f"""\ + [settings] + arch={{{{ detect_api.detect_arch() }}}} + build_type=Release + compiler=gcc + compiler.cppstd=gnu17 + compiler.libcxx=libstdc++11 + compiler.version=11 + os=Linux + [runner] + type=docker + dockerfile={dockerfile_path()} + build_context={conan_base_path()} + image=conan-runner-default-test + cache=shared + remove=True + """) + + client.save({"host": profile_host, "build": profile_build}) + client.save({"conanfile.py": GenConanfile("lib", "0.1") + .with_option("shared", [True, False], False) + .with_option("special", [None, "ANY"]) + .with_option("special2", [None, "ANY"]) + .with_option("special3", [None, "ANY"]) + .with_option("special4", [None, "ANY"]) + .with_package("self.output.info(f'special={self.options.special}')", + "self.output.info(f'special2={self.options.special2}')", + "self.output.info(f'special3={self.options.special3}')", + "self.output.info(f'special4={self.options.special4}')")}) + client.run("create . -pr:h host -pr:b build -o=&:shared=True " + """-o special='1 2' -o"special2='3 4'" -o special3="5 6" -o="special4=7 8" """) + + assert ":shared=True: command not found" not in client.out + assert "special=1 2" in client.out + assert "special2=3 4" in client.out + assert "special3=5 6" in client.out + assert "special4=7 8" in client.out + assert "Removing container" in client.out