Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Missing more tests * Added tests * Removed comment * None is activated by default * Hide write_conanvcvars * Fixed call to vcvars
- Loading branch information
Showing
9 changed files
with
125 additions
and
60 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from conan.tools.microsoft.toolchain import MSBuildToolchain | ||
from conan.tools.microsoft.msbuild import MSBuild | ||
from conan.tools.microsoft.msbuilddeps import MSBuildDeps | ||
from conan.tools.microsoft.visual import msvc_runtime_flag | ||
from conan.tools.microsoft.visual import msvc_runtime_flag, VCVars | ||
from conan.tools.microsoft.subsystems import unix_path |
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
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
Empty file.
53 changes: 53 additions & 0 deletions
53
conans/test/integration/toolchains/microsoft/vcvars_test.py
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,53 @@ | ||
import platform | ||
import textwrap | ||
import os | ||
|
||
import pytest | ||
|
||
from conans.test.utils.tools import TestClient | ||
|
||
|
||
@pytest.mark.skipif(platform.system() not in ["Windows"], reason="Requires Windows") | ||
@pytest.mark.parametrize("auto_activate", [False, True, None]) | ||
def test_vcvars_generator(auto_activate): | ||
client = TestClient(path_with_spaces=False) | ||
|
||
conanfile = textwrap.dedent(""" | ||
from conans import ConanFile | ||
from conan.tools.microsoft import VCVars | ||
class TestConan(ConanFile): | ||
settings = "os", "compiler", "arch", "build_type" | ||
def generate(self): | ||
VCVars(self).generate({}) | ||
""".format("True" if auto_activate else "False" if auto_activate is False else "")) | ||
|
||
client.save({"conanfile.py": conanfile}) | ||
client.run('install . -s os=Windows -s compiler="msvc" -s compiler.version=19.1 ' | ||
'-s compiler.cppstd=14 -s compiler.runtime=static') | ||
|
||
assert os.path.exists(os.path.join(client.current_folder, "conanvcvars.bat")) | ||
|
||
if auto_activate is True or auto_activate is None: | ||
bat_contents = client.load("conanenv.bat") | ||
assert "conanvcvars.bat" in bat_contents | ||
else: | ||
assert not os.path.exists(os.path.join(client.current_folder, "conanenv.bat")) | ||
|
||
|
||
@pytest.mark.skipif(platform.system() not in ["Windows"], reason="Requires Windows") | ||
def test_vcvars_generator_string(): | ||
client = TestClient(path_with_spaces=False) | ||
|
||
conanfile = textwrap.dedent(""" | ||
from conans import ConanFile | ||
class TestConan(ConanFile): | ||
generators = "VCVars" | ||
settings = "os", "compiler", "arch", "build_type" | ||
""") | ||
client.save({"conanfile.py": conanfile}) | ||
client.run('install . -s os=Windows -s compiler="msvc" -s compiler.version=19.1 ' | ||
'-s compiler.cppstd=14 -s compiler.runtime=static') | ||
|
||
assert os.path.exists(os.path.join(client.current_folder, "conanvcvars.bat")) |