Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run tools.unix_path only in Windows #6935

Merged
merged 2 commits into from Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions conans/client/tools/win.py
Expand Up @@ -577,6 +577,9 @@ def unix_path(path, path_flavor=None):
if not path:
return None

if not OSInfo().is_windows:
return path

if os.path.exists(path):
path = get_cased_path(path) # if the path doesn't exist (and abs) we cannot guess the casing

Expand Down
12 changes: 12 additions & 0 deletions conans/test/unittests/util/unix_path_test.py
Expand Up @@ -41,18 +41,30 @@ def test_case_partial_exists(self):

class UnixPathTest(unittest.TestCase):

def test_none(self):
self.assertEqual(None, tools.unix_path(path=None))

@unittest.skipIf(platform.system() == "Windows", "All but Windows")
def test_not_windows(self):
path = 'C:\\Windows\\System32'
self.assertEqual(path, tools.unix_path(path))

@unittest.skipUnless(platform.system() == "Windows", "Only windows")
def test_msys_path(self):
self.assertEqual('/c/windows/system32', tools.unix_path('C:\\Windows\\System32',
path_flavor=tools.MSYS2))

@unittest.skipUnless(platform.system() == "Windows", "Only windows")
def test_cygwin_path(self):
self.assertEqual('/cygdrive/c/windows/system32', tools.unix_path('C:\\Windows\\System32',
path_flavor=tools.CYGWIN))

@unittest.skipUnless(platform.system() == "Windows", "Only windows")
def test_wsl_path(self):
self.assertEqual('/mnt/c/Windows/System32', tools.unix_path('C:\\Windows\\System32',
path_flavor=tools.WSL))

@unittest.skipUnless(platform.system() == "Windows", "Only windows")
def test_sfu_path(self):
self.assertEqual('/dev/fs/C/windows/system32', tools.unix_path('C:\\Windows\\System32',
path_flavor=tools.SFU))