Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #3455 from jgsogo/fix/tests/osinfo_bash_path
[fix] Issues related to OSInfo.bash_path()
  • Loading branch information
memsharded committed Sep 3, 2018
2 parents 38a8787 + b38179f commit 8c9ea8d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions conans/test/util/tools_test.py
Expand Up @@ -827,10 +827,11 @@ def __call__(self, command, output, log_filepath=None,
self._runner = MyRun()

conanfile = MockConanfile()
tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin")
self.assertIn("bash", conanfile._runner.command)
self.assertIn("--login -c", conanfile._runner.command)
self.assertIn("^&^& a_command.bat ^", conanfile._runner.command)
with patch.object(OSInfo, "bash_path", return_value='bash'):
tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin")
self.assertIn("bash", conanfile._runner.command)
self.assertIn("--login -c", conanfile._runner.command)
self.assertIn("^&^& a_command.bat ^", conanfile._runner.command)

with tools.environment_append({"CONAN_BASH_PATH": "path\\to\\mybash.exe"}):
tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin")
Expand All @@ -842,10 +843,11 @@ def __call__(self, command, output, log_filepath=None,

# try to append more env vars
conanfile = MockConanfile()
tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin", env={"PATH": "/other/path",
"MYVAR": "34"})
self.assertIn('^&^& PATH=\\^"/cygdrive/other/path:/cygdrive/path/to/somewhere:$PATH\\^" '
'^&^& MYVAR=34 ^&^& a_command.bat ^', conanfile._runner.command)
with patch.object(OSInfo, "bash_path", return_value='bash'):
tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin",
env={"PATH": "/other/path", "MYVAR": "34"})
self.assertIn('^&^& PATH=\\^"/cygdrive/other/path:/cygdrive/path/to/somewhere:$PATH\\^" '
'^&^& MYVAR=34 ^&^& a_command.bat ^', conanfile._runner.command)

def download_retries_test(self):
http_server = StoppableThreadBottle()
Expand Down Expand Up @@ -1044,7 +1046,7 @@ def get_values(this_os, this_arch, setting_os, setting_arch, compiler=None):
def detect_windows_subsystem_test(self):
# Dont raise test
result = tools.os_info.detect_windows_subsystem()
if not tools.os_info.bash_path or platform.system() != "Windows":
if not tools.os_info.bash_path() or platform.system() != "Windows":
self.assertEqual(None, result)
else:
self.assertEqual(str, type(result))
Expand Down

0 comments on commit 8c9ea8d

Please sign in to comment.