From b349ddd114d6238d59c50480d778668286f7f362 Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Fri, 8 Mar 2024 09:28:46 +0100 Subject: [PATCH 1/2] Added failing test --- .../test_packaging_static_shared.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test_hooks/conan-center/test_packaging_static_shared.py b/tests/test_hooks/conan-center/test_packaging_static_shared.py index bebf9a39..4cb6e7b9 100644 --- a/tests/test_hooks/conan-center/test_packaging_static_shared.py +++ b/tests/test_hooks/conan-center/test_packaging_static_shared.py @@ -68,6 +68,26 @@ def package_info(self): self.cpp_info.libs = ["foo"] """) + conanfile_test_shared_windows = textwrap.dedent("""\ + from conan import ConanFile + import os + + class AConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + options = {"shared": [True, False]} + default_options = {"shared": True} + + def package(self): + libdir = os.path.join(self.package_folder, "lib") + bindir = os.path.join(self.package_folder, "bin") + os.makedirs(libdir) + # Issue related: https://github.com/conan-io/hooks/issues/528 + open(os.path.join(libdir, "libfoo.dll.lib"), "w") + open(os.path.join(bindir, "libfoo.dll"), "w") + + def package_info(self): + self.cpp_info.libs = ["foo"] + """) def _get_environ(self, **kwargs): kwargs = super(TestPackagingStaticSharedLibraries, self)._get_environ(**kwargs) kwargs.update({ @@ -106,3 +126,9 @@ def test_either_shared_or_static(self, shared, hook_ok): self.assertIn("[EITHER STATIC OR SHARED OF EACH LIB (KB-H076)] OK", output) else: self.assertIn("ERROR: [EITHER STATIC OR SHARED OF EACH LIB (KB-H076)] Package contains both shared and static flavors of these libraries: libfoo, libfoobar", output) + + def test_shared_windows(self): + tools.save("conanfile.py", content=self.conanfile_test_shared_windows) + output = self.conan([ + "create", ".", "name/version@user/test"]) + self.assertNotIn("[LIBRARY DOES NOT EXIST (KB-H054)]", output) From 783140601fc38b4c9c0203b0864c7e412b99451e Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Fri, 8 Mar 2024 10:43:53 +0100 Subject: [PATCH 2/2] Fixed failing test --- hooks/yaml_linter.py | 2 -- .../conan-center/test_packaging_static_shared.py | 8 +++++--- tests/utils/test_cases/conan_client_v2.py | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/hooks/yaml_linter.py b/hooks/yaml_linter.py index efca1e43..bc31a40c 100644 --- a/hooks/yaml_linter.py +++ b/hooks/yaml_linter.py @@ -5,8 +5,6 @@ import subprocess from conans.errors import ConanException -from conans.tools import logger - CONAN_HOOK_YAMLLINT_WERR = "CONAN_YAMLLINT_WERR" diff --git a/tests/test_hooks/conan-center/test_packaging_static_shared.py b/tests/test_hooks/conan-center/test_packaging_static_shared.py index 4cb6e7b9..5503367a 100644 --- a/tests/test_hooks/conan-center/test_packaging_static_shared.py +++ b/tests/test_hooks/conan-center/test_packaging_static_shared.py @@ -75,12 +75,13 @@ def package_info(self): class AConan(ConanFile): settings = "os", "arch", "compiler", "build_type" options = {"shared": [True, False]} - default_options = {"shared": True} + default_options = {"shared": False} def package(self): libdir = os.path.join(self.package_folder, "lib") bindir = os.path.join(self.package_folder, "bin") os.makedirs(libdir) + os.makedirs(bindir) # Issue related: https://github.com/conan-io/hooks/issues/528 open(os.path.join(libdir, "libfoo.dll.lib"), "w") open(os.path.join(bindir, "libfoo.dll"), "w") @@ -130,5 +131,6 @@ def test_either_shared_or_static(self, shared, hook_ok): def test_shared_windows(self): tools.save("conanfile.py", content=self.conanfile_test_shared_windows) output = self.conan([ - "create", ".", "name/version@user/test"]) - self.assertNotIn("[LIBRARY DOES NOT EXIST (KB-H054)]", output) + "create", ".", "name/version@user/test", "-o", "shared=True"]) + self.assertNotIn("[LIBRARY DOES NOT EXIST (KB-H054)] Component name::name library 'foo' is listed in the " + "recipe, but not found installed at self.cpp_info.libdirs", output) diff --git a/tests/utils/test_cases/conan_client_v2.py b/tests/utils/test_cases/conan_client_v2.py index 500ec176..1ec39599 100644 --- a/tests/utils/test_cases/conan_client_v2.py +++ b/tests/utils/test_cases/conan_client_v2.py @@ -6,7 +6,8 @@ import uuid import subprocess -from conan.cli.exit_codes import SUCCESS +from conans.cli.exit_codes import SUCCESS + from tests.utils.environ_vars import context_env