Repository: conan-io/conan
Pull request #15577 (2024-02-01 10:01:54)

Visual Studio test check
Waiting for CI

RubenRBS: Rebuilding after @davidsanfal installed the new verison in the machines, thanks! :)

Patch:
diff --git a/conan/api/subapi/cache.py b/conan/api/subapi/cache.py
index 0875f6fb2..1fcb49219 100644
--- a/conan/api/subapi/cache.py
+++ b/conan/api/subapi/cache.py
@@ -155,6 +155,8 @@ class CacheAPI:
             tgz.close()
 
     def restore(self, path):
+        if not os.path.isfile(path):
+            raise ConanException(f"Restore archive doesn't exist in {path}")
         with open(path, mode='rb') as file_handler:
             the_tar = tarfile.open(fileobj=file_handler)
             fileobj = the_tar.extractfile("pkglist.json")
diff --git a/conan/cli/commands/version.py b/conan/cli/commands/version.py
index 507f0f7d1..b2509afef 100644
--- a/conan/cli/commands/version.py
+++ b/conan/cli/commands/version.py
@@ -12,10 +12,22 @@ def version(conan_api, parser, *args):
     Give information about the Conan client version.
     """
 
-    return {'version': str(conan_version),
+    return {
+            'version': str(conan_version),
+            'conan_path': sys.argv[0],
             'python': {
                 'version': platform.python_version().replace('\n', ''),
                 'sys_version': sys.version.replace('\n', ''),
+                'sys_executable': sys.executable,
+                'is_frozen': getattr(sys, 'frozen', False),
+                'architecture': platform.machine(),
+                },
+            'system': {
+                'version': platform.version(),
+                'platform': platform.platform(),
+                'system': platform.system(),
+                'release': platform.release(),
+                'cpu': platform.processor(),
                 }
             }
 


Test patch:
diff --git a/conans/test/conftest.py b/conans/test/conftest.py
index 080b111b5..07b35c85b 100644
--- a/conans/test/conftest.py
+++ b/conans/test/conftest.py
@@ -52,7 +52,7 @@ tools_locations = {
     'visual_studio': {"default": "15",
                       "15": {},
                       "16": {"disabled": True},
-                      "17": {"disabled": True}},
+                      "17": {}},
     'pkg_config': {
         "exe": "pkg-config",
         "default": "0.28",
diff --git a/conans/test/functional/test_profile_detect_api.py b/conans/test/functional/test_profile_detect_api.py
index 820e41599..b33d1cb30 100644
--- a/conans/test/functional/test_profile_detect_api.py
+++ b/conans/test/functional/test_profile_detect_api.py
@@ -8,6 +8,7 @@ from conans.test.utils.tools import TestClient
 
 
 class TestProfileDetectAPI:
+    @pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows")
     @pytest.mark.tool("visual_studio", "17")
     def test_profile_detect_compiler(self):
 
diff --git a/conans/test/functional/toolchains/cmake/test_cmake_toolchain_win_clang.py b/conans/test/functional/toolchains/cmake/test_cmake_toolchain_win_clang.py
index 1261ea731..2b0a03695 100644
--- a/conans/test/functional/toolchains/cmake/test_cmake_toolchain_win_clang.py
+++ b/conans/test/functional/toolchains/cmake/test_cmake_toolchain_win_clang.py
@@ -9,7 +9,6 @@ from conans.test.assets.cmake import gen_cmakelists
 from conans.test.assets.sources import gen_function_cpp, gen_function_c
 from conans.test.functional.utils import check_vs_runtime, check_exe_run
 from conans.test.utils.tools import TestClient
-from conans.util.env import environment_update
 
 
 @pytest.fixture
@@ -65,7 +64,7 @@ def client():
 
 
 @pytest.mark.tool("cmake")
-@pytest.mark.tool("clang", "13")
+@pytest.mark.tool("clang", "16")
 @pytest.mark.skipif(platform.system() != "Windows", reason="requires Win")
 class TestLLVMClang:
     """ External LLVM/clang, with different CMake generators
@@ -74,7 +73,7 @@ class TestLLVMClang:
 
     @pytest.mark.tool("mingw64")
     @pytest.mark.tool("visual_studio", "17")
-    @pytest.mark.tool("clang", "13")  # repeated, for priority over the mingw64 clang
+    @pytest.mark.tool("clang", "16")  # repeated, for priority over the mingw64 clang
     @pytest.mark.parametrize("runtime", ["static", "dynamic"])
     def test_clang_mingw(self, client, runtime):
         """ compiling with an LLVM-clang installed, which uses by default the
@@ -86,7 +85,7 @@ class TestLLVMClang:
         # clang compilations in Windows will use MinGW Makefiles by default
         assert 'cmake -G "MinGW Makefiles"' in client.out
         assert "GNU-like command-line" in client.out
-        assert "main __clang_major__13" in client.out
+        assert "main __clang_major__16" in client.out
         assert "main _MSC_VER193" in client.out
         assert "main _MSVC_LANG2014" in client.out
         assert "main _M_X64 defined" in client.out
@@ -107,7 +106,7 @@ class TestLLVMClang:
 
         assert 'cmake -G "{}"'.format(generator) in client.out
         assert "GNU-like command-line" in client.out
-        assert "main __clang_major__13" in client.out
+        assert "main __clang_major__16" in client.out
         assert "main _MSC_VER193" in client.out
         assert "main _MSVC_LANG2014" in client.out
         assert "main _M_X64 defined" in client.out
@@ -117,7 +116,7 @@ class TestLLVMClang:
         check_vs_runtime(cmd, client, "17", build_type="Release", static_runtime=False)
 
     @pytest.mark.tool("visual_studio", "16")
-    @pytest.mark.tool("clang", "13")  # repeated, for priority over the mingw64 clang
+    @pytest.mark.tool("clang", "16")  # repeated, for priority over the mingw64 clang
     def test_clang_cmake_runtime_version(self, client):
         generator = "Ninja"
         # Make sure that normal CMakeLists with verify=False works
@@ -129,7 +128,7 @@ class TestLLVMClang:
 
         assert 'cmake -G "{}"'.format(generator) in client.out
         assert "GNU-like command-line" in client.out
-        assert "main __clang_major__13" in client.out
+        assert "main __clang_major__16" in client.out
         # Check this! Clang compiler in Windows is reporting MSC_VER and MSVC_LANG!
         assert "main _MSC_VER192" in client.out
         assert "main _MSVC_LANG2017" in client.out
@@ -155,7 +154,8 @@ class TestVSClangCL:
                    '-c tools.cmake.cmaketoolchain:generator="{}"'.format(generator))
         assert 'cmake -G "{}"'.format(generator) in client.out
         assert "MSVC-like command-line" in client.out
-        assert "main __clang_major__17" in client.out
+        # My local is 17, but CI ClangCL still 16
+        assert "main __clang_major__16" in client.out
         # Check this! Clang compiler in Windows is reporting MSC_VER and MSVC_LANG!
         assert "main _MSC_VER193" in client.out
         assert "main _MSVC_LANG2017" in client.out
@@ -164,7 +164,7 @@ class TestVSClangCL:
         assert "-m64" not in client.out
         cmd = re.search(r"MYCMD=(.*)!", str(client.out)).group(1)
         cmd = cmd + ".exe"
-        check_vs_runtime(cmd, client, "16", build_type="Release", static_runtime=False)
+        check_vs_runtime(cmd, client, "17", build_type="Release", static_runtime=False)
 
 
 @pytest.mark.tool("cmake")
@@ -182,7 +182,7 @@ class TestMsysClang:
         # clang compilations in Windows will use MinGW Makefiles by default
         assert 'cmake -G "MinGW Makefiles"' in client.out
         # TODO: Version is still not controlled
-        assert "main __clang_major__14" in client.out
+        assert "main __clang_major__15" in client.out
         # Not using libstdc++
         assert "_GLIBCXX_USE_CXX11_ABI" not in client.out
         assert "main __cplusplus2014" in client.out
@@ -212,7 +212,7 @@ class TestMsysClang:
         # clang compilations in Windows will use MinGW Makefiles by default
         assert 'cmake -G "MinGW Makefiles"' in client.out
         # TODO: Version is still not controlled
-        assert "main __clang_major__14" in client.out
+        assert "main __clang_major__15" in client.out
         assert "main _GLIBCXX_USE_CXX11_ABI 0" in client.out
         assert "main __cplusplus2014" in client.out
         assert "main __GNUC__" in client.out
@@ -241,7 +241,7 @@ class TestMsysClang:
         client.run(f"create . --name=pkg --version=0.1 -pr=clang")
         # clang compilations in Windows will use MinGW Makefiles by default
         assert 'cmake -G "MinGW Makefiles"' in client.out
-        assert "main __clang_major__14" in client.out
+        assert "main __clang_major__15" in client.out
         assert "GLIBCXX" not in client.out
         assert "cplusplus" not in client.out
         assert "main __GNUC__" in client.out
@@ -260,27 +260,22 @@ class TestMsysClang:
 
 
 @pytest.mark.tool("cmake")
-@pytest.mark.tool("clang", "12")
+@pytest.mark.tool("ninja")
+@pytest.mark.tool("clang", "16")
 @pytest.mark.skipif(platform.system() != "Windows", reason="requires Win")
 def test_error_clang_cmake_ninja_custom_cxx(client):
-    with environment_update({"CXX": "/no/exist/clang++"}):
-        client.run("create . --name=pkg --version=0.1 -pr=clang -c tools.cmake.cmaketoolchain:generator=Ninja",
-                   assert_error=True)
-        assert 'Could not find compiler' in client.out
-        assert '/no/exist/clang++' in client.out
-
     clang_profile = textwrap.dedent("""
         [settings]
         os=Windows
         arch=x86_64
         build_type=Release
         compiler=clang
-        compiler.version=12
+        compiler.version=16
         [buildenv]
         CXX=/no/exist/clang++
         """)
     client.save({"clang":     clang_profile})
-    client.run("create . --name=pkg --version=0.1 -pr=clang -c tools.cmake.cmaketoolchain:generator=Ninja",
-               assert_error=True)
+    client.run("create . --name=pkg --version=0.1 -pr=clang "
+               "-c tools.cmake.cmaketoolchain:generator=Ninja", assert_error=True)
     assert 'Could not find compiler' in client.out
     assert '/no/exist/clang++' in client.out
diff --git a/conans/test/functional/toolchains/microsoft/test_msbuild.py b/conans/test/functional/toolchains/microsoft/test_msbuild.py
index fd90b06d3..104813008 100644
--- a/conans/test/functional/toolchains/microsoft/test_msbuild.py
+++ b/conans/test/functional/toolchains/microsoft/test_msbuild.py
@@ -426,7 +426,7 @@ class TestWin:
     def test_toolchain_win_vs2017(self, compiler, version, runtime, cppstd):
         self.check_toolchain_win(compiler, version, runtime, cppstd, ide_version=15)
 
-    @pytest.mark.tool("cmake", "3.21")
+    @pytest.mark.tool("cmake", "3.23")
     @pytest.mark.tool("visual_studio", "17")
     @pytest.mark.parametrize("compiler,version,runtime,cppstd",
                              [("msvc", "193", "static", "17")])
diff --git a/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py b/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py
index c71e536a5..5551f171c 100644
--- a/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py
+++ b/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py
@@ -713,7 +713,7 @@ def test_build_vs_project_with_a_vs2017():
 
 
 @pytest.mark.tool("visual_studio", "17")
-@pytest.mark.tool("cmake")
+@pytest.mark.tool("cmake", "3.23")
 @pytest.mark.skipif(platform.system() != "Windows", reason="Requires MSBuild")
 def test_build_vs_project_with_a_vs2022():
     check_build_vs_project_with_a("193")
@@ -782,10 +782,16 @@ def check_build_vs_project_with_a(vs_version):
     main_cpp = gen_function_cpp(name="main", includes=["hello"], calls=["hello"])
     files["MyProject/main.cpp"] = main_cpp
     files["conanfile.py"] = consumer
+    # INJECT PROPS FILES
     props = os.path.join(client.current_folder, "conandeps.props")
-    old = r'<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />'
-    new = old + '<Import Project="{props}" />'.format(props=props)
+    old = r'<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />'
+    new = old + f'<Import Project="{props}" />'
+    files["MyProject/MyProject.vcxproj"] = files["MyProject/MyProject.vcxproj"].replace(old, new)
+    old = r'<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />'
+    toolchain = os.path.join(client.current_folder, "conantoolchain.props")
+    new = f'<Import Project="{toolchain}" />' + old
     files["MyProject/MyProject.vcxproj"] = files["MyProject/MyProject.vcxproj"].replace(old, new)
+
     client.save(files, clean_first=True)
     client.run('build . -s compiler=msvc'
                ' -s compiler.version={vs_version}'.format(vs_version=vs_version))
@@ -803,7 +809,7 @@ def test_build_vs_project_with_test_requires_vs2017():
 
 
 @pytest.mark.tool("visual_studio", "17")
-@pytest.mark.tool("cmake")
+@pytest.mark.tool("cmake", "3.23")
 @pytest.mark.skipif(platform.system() != "Windows", reason="Requires MSBuild")
 def test_build_vs_project_with_test_requires_vs2022():
     check_build_vs_project_with_test_requires("193")
@@ -837,10 +843,17 @@ def check_build_vs_project_with_test_requires(vs_version):
     main_cpp = gen_function_cpp(name="main", includes=["mydep_pkg_team"], calls=["mydep_pkg_team"])
     files["MyProject/main.cpp"] = main_cpp
     files["conanfile.py"] = consumer
+
+    # INJECT PROPS FILES
     props = os.path.join(client.current_folder, "conandeps.props")
-    old = r'<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />'
-    new = old + '<Import Project="{props}" />'.format(props=props)
+    old = r'<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />'
+    new = old + f'<Import Project="{props}" />'
+    files["MyProject/MyProject.vcxproj"] = files["MyProject/MyProject.vcxproj"].replace(old, new)
+    old = r'<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />'
+    toolchain = os.path.join(client.current_folder, "conantoolchain.props")
+    new = f'<Import Project="{toolchain}" />' + old
     files["MyProject/MyProject.vcxproj"] = files["MyProject/MyProject.vcxproj"].replace(old, new)
+
     client.save(files, clean_first=True)
     client.run('build .  -s compiler.version={vs_version}'.format(vs_version=vs_version))
     client.run_command(r"x64\Release\MyProject.exe")
diff --git a/conans/test/functional/utils.py b/conans/test/functional/utils.py
index 611fb8bab..7d92a89d1 100644
--- a/conans/test/functional/utils.py
+++ b/conans/test/functional/utils.py
@@ -46,7 +46,8 @@ def check_vs_runtime(artifact, client, vs_version, build_type, architecture="amd
                     assert "libunwind.dll" not in client.out
                     assert "libc++.dll" not in client.out
                 else:
-                    assert "libunwind.dll" in client.out
+                    # Latest clangs from subsystems no longer depend on libunwind
+                    assert "libunwind.dll" not in client.out
                     assert "libc++.dll" in client.out
             else:
                 raise Exception("unknown {}".format(subsystem))
diff --git a/conans/test/integration/command_v2/test_cache_save_restore.py b/conans/test/integration/command_v2/test_cache_save_restore.py
index 046e0fb0e..2d5301b60 100644
--- a/conans/test/integration/command_v2/test_cache_save_restore.py
+++ b/conans/test/integration/command_v2/test_cache_save_restore.py
@@ -211,3 +211,9 @@ def test_cache_save_subfolder():
     c.run("export .")
     c.run("cache save * --file=subfolder/cache.tgz")
     assert os.path.exists(os.path.join(c.current_folder, "subfolder", "cache.tgz"))
+
+
+def test_error_restore_not_existing():
+    c = TestClient()
+    c.run("cache restore potato.tgz", assert_error=True)
+    assert "ERROR: Restore archive doesn't exist in " in c.out
diff --git a/conans/test/integration/command_v2/test_version.py b/conans/test/integration/command_v2/test_version.py
index 6ddc7aff1..3f397d105 100644
--- a/conans/test/integration/command_v2/test_version.py
+++ b/conans/test/integration/command_v2/test_version.py
@@ -21,8 +21,17 @@ def test_version_json():
     t.run("version --format=json")
     js = json.loads(t.stdout)
     assert js["version"] == __version__
+    assert js["conan_path"] == sys.argv[0]
     assert js["python"]["version"] == _python_version()
     assert js["python"]["sys_version"] == _sys_version()
+    assert js["python"]["sys_executable"] == sys.executable
+    assert js["python"]["is_frozen"] == getattr(sys, 'frozen', False)
+    assert js["python"]["architecture"] == platform.machine()
+    assert js["system"]["version"] == platform.version()
+    assert js["system"]["platform"] == platform.platform()
+    assert js["system"]["system"] == platform.system()
+    assert js["system"]["release"] == platform.release()
+    assert js["system"]["cpu"] == platform.processor()
 
 
 def test_version_text():
@@ -47,6 +56,16 @@ def test_version_raw():
 def _validate_text_output(output):
     lines = output.splitlines()
     assert f'version: {__version__}' in lines
+    assert f'conan_path: {sys.argv[0]}' in lines
     assert 'python' in lines
     assert f'  version: {_python_version()}' in lines
     assert f'  sys_version: {_sys_version()}' in lines
+    assert f'  sys_executable: {sys.executable}' in lines
+    assert f'  is_frozen: {getattr(sys, "frozen", False)}' in lines
+    assert f'  architecture: {platform.machine()}' in lines
+    assert 'system' in lines
+    assert f'  version: {platform.version()}' in lines
+    assert f'  platform: {platform.platform()}' in lines
+    assert f'  system: {platform.system()}' in lines
+    assert f'  release: {platform.release()}' in lines
+    assert f'  cpu: {platform.processor()}' in lines