Skip to content

Commit 918f18f

Browse files
committed
Fix issue when build profile is not present and added tests
1 parent 6231e3d commit 918f18f

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

conan/internal/runner/ssh.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,16 @@ def _copy_profiles(self):
184184
if not self.remote_conn.check_file_exists(remote_profile_path.as_posix()):
185185
self.remote_conn.mkdir(remote_profile_path.as_posix())
186186
# Iterate over all profiles and copy using sftp
187-
for profile in set(self.args.profile_host + self.args.profile_build):
187+
for profile in set(self.args.profile_host + (self.args.profile_build or [])):
188188
dest_filename = remote_profile_path / profile
189189
profile_path = self.conan_api.profiles.get_path(profile)
190190
self.logger.verbose(f"Copying profile '{profile}': {profile_path} -> {dest_filename}")
191191
self.remote_conn.put(profile_path, dest_filename.as_posix())
192-
if not self.args.profile_host:
192+
if not self.args.profile_build:
193193
dest_filename = remote_profile_path / "default" # in remote use "default" profile
194-
default_host_profile = self.conan_api.profiles.get_default_host()
195-
self.logger.verbose(f"Copying default profile: {default_host_profile} -> {dest_filename}")
196-
self.remote_conn.put(default_host_profile, dest_filename.as_posix())
194+
default_build_profile = self.conan_api.profiles.get_default_build()
195+
self.logger.verbose(f"Copying default profile: {default_build_profile} -> {dest_filename}")
196+
self.remote_conn.put(default_build_profile, dest_filename.as_posix())
197197

198198
def _copy_working_conanfile_path(self):
199199
resolved_path = Path(self.args.path).resolve()

test/functional/command/ssh_runner_test.py

+33-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_create_ssh_runner_only_host():
5757
@pytest.mark.skipif(ssh_skip(), reason="SSH environment have to be configured")
5858
def test_create_ssh_runner_with_config():
5959
"""
60-
Tests the ``conan create . ``
60+
Tests the ``conan create . `` with ssh config file
6161
"""
6262
client = TestClient()
6363

@@ -125,3 +125,35 @@ def test_create_ssh_runner_with_config():
125125
assert "Restore: pkg/2.0 in pkgc6abef0178849" in client.out
126126
assert "Restore: pkg/2.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe" in client.out
127127
assert "Restore: pkg/2.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe metadata" in client.out
128+
129+
@pytest.mark.ssh_runner
130+
@pytest.mark.skipif(ssh_skip(), reason="SSH environment have to be configured")
131+
def test_create_ssh_runner_default_profile():
132+
"""
133+
Tests the ``conan create . `` without build profile
134+
"""
135+
client = TestClient()
136+
137+
profile_host = textwrap.dedent(f"""\
138+
[settings]
139+
arch={{{{ detect_api.detect_arch() }}}}
140+
build_type=Release
141+
compiler=gcc
142+
compiler.cppstd=gnu17
143+
compiler.libcxx=libstdc++11
144+
compiler.version=11
145+
os=Linux
146+
[runner]
147+
type=ssh
148+
ssh.host=localhost
149+
""")
150+
151+
client.save({"host": profile_host, "build": profile_host})
152+
client.run("new cmake_lib -d name=pkg -d version=2.0")
153+
client.run("create . -pr:h host -vverbose")
154+
155+
assert "Copying default profile: " in client.out
156+
assert "[100%] Built target example" in client.out
157+
assert "Restore: pkg/2.0 in pkgc6abef0178849" in client.out
158+
assert "Restore: pkg/2.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe" in client.out
159+
assert "Restore: pkg/2.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe metadata" in client.out

0 commit comments

Comments
 (0)