Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update powershell conf to select from powershell and pwsh #17416

Merged
merged 30 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix concatenation
  • Loading branch information
czoido committed Dec 5, 2024
commit ae00de8789fb46e12bd161c2ce19e70e70571e64
4 changes: 2 additions & 2 deletions conan/tools/env/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def environment_wrap_command(conanfile, env_filenames, env_folder, cmd, subsyste
if bats:
launchers = " && ".join('"{}"'.format(b) for b in bats)
if ps1s:
ps1_launchers = " ; ".join('{} -Command "&\'{}\'"'.format(powershell, f) for f in ps1s)
ps1_launchers = f'{powershell} -Command "' + " ; ".join('&\'{}\''.format(f) for f in ps1s) + '"'
cmd = cmd.replace('"', "'")
return '{} && {} ; cmd /c {}'.format(launchers, ps1_launchers, cmd)
else:
Expand All @@ -72,7 +72,7 @@ def environment_wrap_command(conanfile, env_filenames, env_folder, cmd, subsyste
launchers = " && ".join('. "{}"'.format(f) for f in shs)
return '{} && {}'.format(launchers, cmd)
elif ps1s:
ps1_launchers = " ; ".join('{} -Command "&\'{}\'"'.format(powershell, f) for f in ps1s)
ps1_launchers = f'{powershell} -Command "' + " ; ".join('&\'{}\''.format(f) for f in ps1s) + '"'
cmd = cmd.replace('"', "'")
return '{} ; cmd /c {}'.format(ps1_launchers, cmd)
else:
Expand Down
9 changes: 5 additions & 4 deletions test/functional/toolchains/env/test_virtualenv_powershell.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def build(self):
def test_concatenate_build_and_run_env(powershell):
# this tests that if we have both build and run env, they are concatenated correctly when using
# powershell
client = TestClient(path_with_spaces=False)
client = TestClient(path_with_spaces=True)
compiler_bat = "@echo off\necho MYTOOL {}!!\n"
conanfile = textwrap.dedent("""\
import os
Expand Down Expand Up @@ -200,13 +200,14 @@ class Pkg(ConanFile):

client.save({"conanfile.py": conanfile}, clean_first=True)
client.run(f"install . -c tools.env.virtualenv:powershell={powershell}")

cmd = environment_wrap_command(ConanFileMock(),["conanrunenv", "conanbuildenv"],
conanfile = ConanFileMock()
conanfile.conf.define("tools.env.virtualenv:powershell", powershell)
cmd = environment_wrap_command(conanfile,["conanrunenv", "conanbuildenv"],
client.current_folder,"mycompiler0.bat")
client.run_command(cmd)
assert "MYTOOL 0!!" in client.out

cmd = environment_wrap_command(ConanFileMock(),["conanrunenv", "conanbuildenv"],
cmd = environment_wrap_command(conanfile,["conanrunenv", "conanbuildenv"],
client.current_folder,"mycompiler1.bat")
client.run_command(cmd)
assert "MYTOOL 1!!" in client.out
Loading