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
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
wip
  • Loading branch information
czoido committed Dec 4, 2024
commit d72091a55b5dda6f8f3ae22df5210928c89a8635
16 changes: 9 additions & 7 deletions test/functional/toolchains/env/test_virtualenv_powershell.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def build(self):


@pytest.mark.skipif(platform.system() != "Windows", reason="Requires Windows powershell")
def test_virtualenv_test_package():
@pytest.mark.parametrize("powershell", ["powershell", "pwsh"])
def test_virtualenv_test_package(powershell):
""" The test_package could crash if not cleaning correctly the test_package
output folder. This will still crassh if the layout is not creating different build folders
https://github.com/conan-io/conan/issues/12764
Expand Down Expand Up @@ -110,15 +111,16 @@ def test(self):
assert "MYVC_CUSTOMVAR1=PATATA1" in client.out
assert "MYVC_CUSTOMVAR2=PATATA2" in client.out
# This was crashing because the .ps1 of test_package was not being cleaned
client.run("create . -c tools.env.virtualenv:powershell=True")
client.run(f"create . -c tools.env.virtualenv:powershell={powershell}")
assert "hello world" in client.out
assert "MYENV!!!" in client.out
assert "MYPS1!!!!" in client.out
assert "MYVC_CUSTOMVAR1=PATATA1" in client.out
assert "MYVC_CUSTOMVAR2=PATATA2" in client.out

@pytest.mark.skipif(platform.system() != "Windows", reason="Requires Windows powershell")
def test_vcvars():
@pytest.mark.parametrize("powershell", ["powershell", "pwsh"])
def test_vcvars(powershell):
client = TestClient()
conanfile = textwrap.dedent(r"""
from conan import ConanFile
Expand All @@ -141,15 +143,15 @@ def build(self):
hello_cpp = gen_function_cpp(name="main")
cmakelists = gen_cmakelists(appname="hello", appsources=["hello.cpp"])
client.save({"conanfile.py": conanfile, "hello.cpp": hello_cpp, "CMakeLists.txt": cmakelists})

client.run("build . -c tools.env.virtualenv:powershell=True -c tools.cmake.cmaketoolchain:generator=Ninja")
client.run_command(r'powershell.exe ".\build\Release\generators\conanbuild.ps1; dir env:"')
powershell_exe = "powershell.exe" if powershell == "powershell" else "pwsh"
client.run(f"build . -c tools.env.virtualenv:powershell={powershell} -c tools.cmake.cmaketoolchain:generator=Ninja")
client.run_command(rf'{powershell_exe} ".\build\Release\generators\conanbuild.ps1; dir env:"')
#check the conanbuid.ps1 activation message
assert "conanvcvars.ps1: Activated environment" in client.out
#check that the new env variables are set
assert "VSCMD_ARG_VCVARS_VER" in client.out

client.run_command(r'powershell.exe ".\build\Release\generators\conanvcvars.ps1"')
client.run_command(rf'{powershell_exe} ".\build\Release\generators\conanvcvars.ps1"')
assert client.out.strip() == "conanvcvars.ps1: Activated environment"

conanbuild = client.load(r".\build\Release\generators\conanbuild.ps1")
Expand Down