Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* - allow vcvars for clang-cl Signed-off-by: SSE4 <tomskside@gmail.com> * - move _visual_compiler_last from detect.py into win.py, renaming to the latest_visual_studio_version_installed Signed-off-by: SSE4 <tomskside@gmail.com> * - look from the latest to oldest Signed-off-by: SSE4 <tomskside@gmail.com> * - add negative test case Signed-off-by: SSE4 <tomskside@gmail.com> * - handle latest_visual_studio_version_installed returns None Signed-off-by: SSE4 <tomskside@gmail.com> * - add system_registry_key context manager, ensure key is always closed Signed-off-by: SSE4 <tomskside@gmail.com> * - make system_registry_key private Signed-off-by: SSE4 <tomskside@gmail.com> * - return just Visual Studio version Signed-off-by: SSE4 <tomskside@gmail.com> * - simplify _system_registry_key Signed-off-by: SSE4 <tomskside@gmail.com> * - remove decorator Signed-off-by: SSE4 <tomskside@gmail.com> * try/catch for openKey and for QueryValue * - set detected compiler tuple properly Signed-off-by: SSE4 <tomskside@gmail.com>
- Loading branch information
Showing
3 changed files
with
153 additions
and
92 deletions.
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
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,49 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 | ||
|
||
import platform | ||
import unittest | ||
from nose.plugins.attrib import attr | ||
from conans.model.settings import Settings | ||
from conans.client.conf import default_settings_yml | ||
from conans.errors import ConanException | ||
from conans import tools | ||
from mock import mock | ||
|
||
|
||
@attr('visual_studio') | ||
@unittest.skipUnless(platform.system() == "Windows", "Requires Windows") | ||
class VCVarsClangClTest(unittest.TestCase): | ||
|
||
def test_simple(self): | ||
settings = Settings.loads(default_settings_yml) | ||
settings.compiler = 'clang' | ||
settings.compiler.version = '5.0' | ||
settings.arch = 'x86' | ||
settings.os = 'Windows' | ||
|
||
command = tools.vcvars_command(settings) | ||
self.assertIn('vcvarsall.bat', command) | ||
self.assertIn('x86', command) | ||
|
||
def test_no_version(self): | ||
settings = Settings.loads(default_settings_yml) | ||
settings.compiler = 'clang' | ||
settings.arch = 'x86_64' | ||
settings.os = 'Windows' | ||
|
||
command = tools.vcvars_command(settings) | ||
self.assertIn('vcvarsall.bat', command) | ||
self.assertIn('amd64', command) | ||
|
||
def test_no_msvc(self): | ||
settings = Settings.loads(default_settings_yml) | ||
settings.compiler = 'clang' | ||
settings.arch = 'x86_64' | ||
settings.os = 'Windows' | ||
|
||
with mock.patch('conans.client.tools.win.latest_visual_studio_version_installed', | ||
mock.MagicMock(return_value=None)): | ||
with self.assertRaises(ConanException): | ||
tools.vcvars_command(settings) |