Skip to content

Fix CMake.test() target for Ninja Multi-Config - #11594

Merged
memsharded merged 3 commits into
conan-io:developfrom
Naufragous:fix/cmake-test-with-ninja-multi-config
Jul 9, 2022
Merged

memsharded merged 3 commits into
conan-io:developfrom
Naufragous:fix/cmake-test-with-ninja-multi-config

Conversation

@Naufragous

@Naufragous Naufragous commented Jul 8, 2022

Copy link
Copy Markdown
Contributor

Changelog: Bugfix: Use correct build target in CMake.test() for the Ninja Multi-Config generator.
Docs: omit
Fixes #11405

@CLAassistant

CLAassistant commented Jul 8, 2022

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Naufragous

Copy link
Copy Markdown
Contributor Author

I used the test_run_tests test case from conans/test/unittests/client/build/cmake_test.py as basis for this new test. Unfortunately there seem to be not that many tests for the new CMake tool. Please advise if something is off.

@memsharded memsharded left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing this fix.

write_cmake_presets(conanfile, "toolchain", generator, {})
cmake = CMake(conanfile)
cmake.test()
assert "'--target' '%s'" % target in conanfile.command

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert "'--target' '%s'" % target in conanfile.command
if platform.system() == "Windows":
assert "--target %s" % target in conanfile.command
else:
assert "'--target' '%s'" % target in conanfile.command

There is a small difference atm in the command in Windows, the args are not quoted.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc/ @lasote This is one of the things related to #11553, that seems a bit weird to me, that the commands quoting is different in different systems.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestion. I added the platform import and made the search pattern conditional on the platform.

@memsharded memsharded added this to the 1.51 milestone Jul 8, 2022
@memsharded
memsharded merged commit 5ae2626 into conan-io:develop Jul 9, 2022
@memsharded

Copy link
Copy Markdown
Member

Merged, this will be released in 1.51.
Thanks again for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] cmake.test() cannot execute

3 participants