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

Add support for test_requires in XcodeDeps #11415

Merged
merged 1 commit into from Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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")