Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix CMake.test() target for Ninja Multi-Config (#11594)
* Fix bug in CMake.test() when using Ninja Multi-Config (#11405) * Add unit test for the CMake.test() helper * Fix unit test for Windows platform
- Loading branch information
1 parent
3507c09
commit 5ae2626
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import platform | ||
import pytest | ||
|
||
from conan.tools.cmake import CMake | ||
from conan.tools.cmake.presets import write_cmake_presets | ||
from conans.client.conf import get_default_settings_yml | ||
from conans.model.conf import Conf | ||
from conans.model.settings import Settings | ||
from conans.test.utils.mocks import ConanFileMock | ||
from conans.test.utils.test_files import temp_folder | ||
|
||
|
||
@pytest.mark.parametrize("generator,target", [ | ||
("NMake Makefiles", "test"), | ||
("Ninja Makefiles", "test"), | ||
("Ninja Multi-Config", "test"), | ||
("Unix Makefiles", "test"), | ||
("Visual Studio 14 2015", "RUN_TESTS"), | ||
("Xcode", "RUN_TESTS"), | ||
]) | ||
def test_run_tests(generator, target): | ||
""" | ||
Testing that the proper test target is picked for different generators, especially multi-config ones. | ||
Issue related: https://github.com/conan-io/conan/issues/11405 | ||
""" | ||
settings = Settings.loads(get_default_settings_yml()) | ||
settings.os = "Windows" | ||
settings.arch = "x86" | ||
settings.build_type = "Release" | ||
settings.compiler = "Visual Studio" | ||
settings.compiler.runtime = "MDd" | ||
settings.compiler.version = "14" | ||
|
||
conanfile = ConanFileMock() | ||
conanfile.conf = Conf() | ||
conanfile.folders.generators = "." | ||
conanfile.folders.set_base_generators(temp_folder()) | ||
conanfile.settings = settings | ||
|
||
write_cmake_presets(conanfile, "toolchain", generator, {}) | ||
cmake = CMake(conanfile) | ||
cmake.test() | ||
|
||
search_pattern = "--target {}" if platform.system() == "Windows" else "'--target' '{}'" | ||
assert search_pattern.format(target) in conanfile.command |