Skip to content

Commit

Permalink
add test_requires (#11415)
Browse files Browse the repository at this point in the history
  • Loading branch information
czoido committed Jun 7, 2022
1 parent 1b96011 commit 83cdb71
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion conan/tools/apple/xcodedeps.py
Expand Up @@ -245,7 +245,9 @@ def _content(self):
# Generate the config files for each component with name conan_pkgname_compname.xcconfig
# If a package has no components the name is conan_pkgname_pkgname.xcconfig
# Then all components are included in the conan_pkgname.xcconfig file
for dep in self._conanfile.dependencies.host.values():
host_req = self._conanfile.dependencies.host
test_req = self._conanfile.dependencies.test
for dep in list(host_req.values()) + list(test_req.values()):
dep_name = _format_name(dep.ref.name)

include_components_names = []
Expand Down
Expand Up @@ -202,3 +202,28 @@ def package_info(self):
assert "tcp/1.0: Hello World Release!" in client.out
assert "client/1.0: Hello World Release!" in client.out
assert "chat/1.0: Hello World Release!" in client.out


@pytest.mark.skipif(platform.system() != "Darwin", reason="Only for MacOS")
@pytest.mark.tool_cmake
def test_xcodedeps_test_require():
client = TestClient()
client.run("new gtest/1.0 -m cmake_lib")
# client.run("new cmake_lib -d name=app -d version=1.0")
client.run("create . -tf=None")

# Create library having build and test requires
conanfile = textwrap.dedent(r'''
from conan import ConanFile
class HelloLib(ConanFile):
settings = "os", "compiler", "build_type", "arch"
def build_requirements(self):
self.test_requires('gtest/1.0')
''')
client.save({"conanfile.py": conanfile}, clean_first=True)
client.run("install . -g XcodeDeps")
assert os.path.isfile(os.path.join(client.current_folder, "conan_gtest.xcconfig"))
assert os.path.isfile(os.path.join(client.current_folder, "conan_gtest_gtest.xcconfig"))
assert os.path.isfile(os.path.join(client.current_folder, "conan_gtest_gtest_release_x86_64.xcconfig"))
assert os.path.isfile(os.path.join(client.current_folder, "conan_gtest_gtest_vars_release_x86_64.xcconfig"))
assert '#include "conan_gtest.xcconfig"' in client.load("conandeps.xcconfig")

0 comments on commit 83cdb71

Please sign in to comment.