Skip to content

Commit

Permalink
no-op if not Windows in tools.vcvars() (conan-io#2608)
Browse files Browse the repository at this point in the history
* no-op if not Windows in tools.vcvars() and test

* use platform.system() instead of settings

* Removed profiles from test

* fix profiles delete

* review
  • Loading branch information
danimtb authored and memsharded committed Mar 15, 2018
1 parent 2afdefb commit c14201a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
7 changes: 5 additions & 2 deletions conans/client/tools/win.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,11 @@ def relevant_path(path):

@contextmanager
def vcvars(*args, **kwargs):
new_env = vcvars_dict(*args, **kwargs)
with environment_append(new_env):
if platform.system() == "Windows":
new_env = vcvars_dict(*args, **kwargs)
with environment_append(new_env):
yield
else:
yield


Expand Down
23 changes: 23 additions & 0 deletions conans/test/util/tools_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,29 @@ def vcvars_constrained_test(self):
# Not raising
tools.vcvars_command(settings, force=True)

def vcvars_context_manager_test(self):
conanfile = """
from conans import ConanFile, tools
class MyConan(ConanFile):
name = "MyConan"
version = "0.1"
settings = "os", "compiler"
def build(self):
with tools.vcvars(self.settings):
self.output.info("VCINSTALLDIR set to: " + str(tools.get_env("VCINSTALLDIR")))
"""
client = TestClient()
client.save({"conanfile.py": conanfile})

if platform.system() == "Windows":
client.run("create . conan/testing")
self.assertNotIn("VCINSTALLDIR set to: None", client.out)
else:
client.run("create . conan/testing")
self.assertIn("VCINSTALLDIR set to: None", client.out)

def run_in_bash_test(self):
if platform.system() != "Windows":
return
Expand Down

0 comments on commit c14201a

Please sign in to comment.