From c99a1b8beefe72a49ba8df1e8c749d84be675793 Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Thu, 24 Oct 2024 07:52:32 +0200 Subject: [PATCH] wip --- .../toolchains/cmake/test_cmake_toolchain.py | 2 + .../functional/toolchains/cmake/test_ninja.py | 1 + .../toolchains/microsoft/test_vcvars.py | 41 +++++++++++++++++++ .../command_v2/test_cache_save_restore.py | 3 ++ .../toolchains/microsoft/vcvars_test.py | 34 --------------- 5 files changed, 47 insertions(+), 34 deletions(-) create mode 100644 test/functional/toolchains/microsoft/test_vcvars.py diff --git a/test/functional/toolchains/cmake/test_cmake_toolchain.py b/test/functional/toolchains/cmake/test_cmake_toolchain.py index bedbf7ecc6a..efb07d37514 100644 --- a/test/functional/toolchains/cmake/test_cmake_toolchain.py +++ b/test/functional/toolchains/cmake/test_cmake_toolchain.py @@ -620,6 +620,8 @@ def test_cmake_toolchain_runtime_types_cmake_older_than_3_15(): @pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows") class TestWinSDKVersion: + + @pytest.mark.tool("visual_studio", "17") def test_cmake_toolchain_winsdk_version(self): # This test passes also with CMake 3.28, as long as cmake_minimum_required(VERSION 3.27) # is not defined diff --git a/test/functional/toolchains/cmake/test_ninja.py b/test/functional/toolchains/cmake/test_ninja.py index 8c354d1a82c..7c34c142e8e 100644 --- a/test/functional/toolchains/cmake/test_ninja.py +++ b/test/functional/toolchains/cmake/test_ninja.py @@ -86,6 +86,7 @@ def test_locally_build_linux(build_type, shared, client): @pytest.mark.skipif(platform.system() != "Windows", reason="Only windows") @pytest.mark.parametrize("build_type,shared", [("Release", False), ("Debug", True)]) +@pytest.mark.tool("visual_studio", "15") @pytest.mark.tool("ninja") def test_locally_build_msvc(build_type, shared, client): msvc_version = "15" diff --git a/test/functional/toolchains/microsoft/test_vcvars.py b/test/functional/toolchains/microsoft/test_vcvars.py new file mode 100644 index 00000000000..6a48a340976 --- /dev/null +++ b/test/functional/toolchains/microsoft/test_vcvars.py @@ -0,0 +1,41 @@ +import platform +import textwrap + +import pytest + +from conan.test.utils.tools import TestClient + + +@pytest.mark.skipif(platform.system() != "Windows", reason="Requires Windows") +@pytest.mark.tool("visual_studio", "17") +def test_deactivate_vcvars_message(): + client = TestClient() + conanfile = textwrap.dedent(""" + from conan import ConanFile + class TestConan(ConanFile): + generators = "VCVars" + settings = "os", "compiler", "arch", "build_type" + """) + client.save({"conanfile.py": conanfile}) + client.run('install . -s compiler.version=193') + client.run_command(r'conanbuild.bat') + assert "[vcvarsall.bat] Environment initialized" in client.out + client.run_command(r'deactivate_conanvcvars.bat') + assert "vcvars env cannot be deactivated" in client.out + + +@pytest.mark.skipif(platform.system() != "Windows", reason="Requires Windows Powershell") +def test_deactivate_vcvars_with_powershell(): + client = TestClient() + conanfile = textwrap.dedent(""" + from conan import ConanFile + class TestConan(ConanFile): + generators = "VCVars" + settings = "os", "compiler", "arch", "build_type" + """) + client.save({"conanfile.py": conanfile}) + client.run('install . -c tools.env.virtualenv:powershell=True') + client.run_command(r'powershell.exe ".\conanbuild.ps1"') + assert "conanvcvars.ps1: Activated environment" in client.out + client.run_command(r'powershell.exe ".\deactivate_conanvcvars.ps1"') + assert "vcvars env cannot be deactivated" in client.out diff --git a/test/integration/command_v2/test_cache_save_restore.py b/test/integration/command_v2/test_cache_save_restore.py index cc4fb30b127..3d6009e36ee 100644 --- a/test/integration/command_v2/test_cache_save_restore.py +++ b/test/integration/command_v2/test_cache_save_restore.py @@ -2,6 +2,7 @@ import os import shutil import tarfile +import time import pytest @@ -157,9 +158,11 @@ def test_cache_save_restore_multiple_revisions(): c = TestClient() c.save({"conanfile.py": GenConanfile("pkg", "0.1")}) c.run("create .") + time.sleep(0.01) rrev1 = c.exported_recipe_revision() c.save({"conanfile.py": GenConanfile("pkg", "0.1").with_class_attribute("var=42")}) c.run("create .") + time.sleep(0.01) rrev2 = c.exported_recipe_revision() c.save({"conanfile.py": GenConanfile("pkg", "0.1").with_class_attribute("var=123")}) c.run("create .") diff --git a/test/integration/toolchains/microsoft/vcvars_test.py b/test/integration/toolchains/microsoft/vcvars_test.py index 12f95f1bc9b..25d2ae571c4 100644 --- a/test/integration/toolchains/microsoft/vcvars_test.py +++ b/test/integration/toolchains/microsoft/vcvars_test.py @@ -161,37 +161,3 @@ class TestConan(ConanFile): vcvars = client.load("conanvcvars.bat") assert 'vcvarsall.bat" amd64 -vcvars_ver=14.33' in vcvars - - -@pytest.mark.skipif(platform.system() != "Windows", reason="Requires Windows") -def test_deactivate_vcvars_message(): - client = TestClient() - conanfile = textwrap.dedent(""" - from conan import ConanFile - class TestConan(ConanFile): - generators = "VCVars" - settings = "os", "compiler", "arch", "build_type" - """) - client.save({"conanfile.py": conanfile}) - client.run('install . -s compiler.version=193') - client.run_command(r'conanbuild.bat') - assert "[vcvarsall.bat] Environment initialized" in client.out - client.run_command(r'deactivate_conanvcvars.bat') - assert "vcvars env cannot be deactivated" in client.out - - -@pytest.mark.skipif(platform.system() != "Windows", reason="Requires Windows Powershell") -def test_deactivate_vcvars_with_powershell(): - client = TestClient() - conanfile = textwrap.dedent(""" - from conan import ConanFile - class TestConan(ConanFile): - generators = "VCVars" - settings = "os", "compiler", "arch", "build_type" - """) - client.save({"conanfile.py": conanfile}) - client.run('install . -c tools.env.virtualenv:powershell=True') - client.run_command(r'powershell.exe ".\conanbuild.ps1"') - assert "conanvcvars.ps1: Activated environment" in client.out - client.run_command(r'powershell.exe ".\deactivate_conanvcvars.ps1"') - assert "vcvars env cannot be deactivated" in client.out