Skip to content

Commit

Permalink
Fix issue when build profile is not present and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
perseoGI committed Feb 4, 2025
1 parent 6231e3d commit f080d12
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
10 changes: 5 additions & 5 deletions conan/internal/runner/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,16 @@ def _copy_profiles(self):
if not self.remote_conn.check_file_exists(remote_profile_path.as_posix()):
self.remote_conn.mkdir(remote_profile_path.as_posix())
# Iterate over all profiles and copy using sftp
for profile in set(self.args.profile_host + self.args.profile_build):
for profile in set(self.args.profile_host + (self.args.profile_build or [])):
dest_filename = remote_profile_path / profile
profile_path = self.conan_api.profiles.get_path(profile)
self.logger.verbose(f"Copying profile '{profile}': {profile_path} -> {dest_filename}")
self.remote_conn.put(profile_path, dest_filename.as_posix())
if not self.args.profile_host:
if not self.args.profile_build:
dest_filename = remote_profile_path / "default" # in remote use "default" profile
default_host_profile = self.conan_api.profiles.get_default_host()
self.logger.verbose(f"Copying default profile: {default_host_profile} -> {dest_filename}")
self.remote_conn.put(default_host_profile, dest_filename.as_posix())
default_build_profile = self.conan_api.profiles.get_default_build()
self.logger.verbose(f"Copying default profile: {default_build_profile} -> {dest_filename}")
self.remote_conn.put(default_build_profile, dest_filename.as_posix())

def _copy_working_conanfile_path(self):
resolved_path = Path(self.args.path).resolve()
Expand Down
34 changes: 33 additions & 1 deletion test/functional/command/ssh_runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_create_ssh_runner_only_host():
@pytest.mark.skipif(ssh_skip(), reason="SSH environment have to be configured")
def test_create_ssh_runner_with_config():
"""
Tests the ``conan create . ``
Tests the ``conan create . `` with ssh config file
"""
client = TestClient()

Expand Down Expand Up @@ -125,3 +125,35 @@ def test_create_ssh_runner_with_config():
assert "Restore: pkg/2.0 in pkgc6abef0178849" in client.out
assert "Restore: pkg/2.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe" in client.out
assert "Restore: pkg/2.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe metadata" in client.out

@pytest.mark.ssh_runner
@pytest.mark.skipif(ssh_skip(), reason="SSH environment have to be configured")
def test_create_ssh_runner_default_profile():
"""
Tests the ``conan create . `` without build profile
"""
client = TestClient()

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=ssh
ssh.host=localhost
""")

client.save({"host": profile_host, "build": profile_host})
client.run("new cmake_lib -d name=pkg -d version=2.0")
client.run("create . -pr:h host -pr:b build -vverbose")

assert "Copying default profile: " in client.out
assert "[100%] Built target example" in client.out
assert "Restore: pkg/2.0 in pkgc6abef0178849" in client.out
assert "Restore: pkg/2.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe" in client.out
assert "Restore: pkg/2.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe metadata" in client.out

0 comments on commit f080d12

Please sign in to comment.