Commit 4099daa9 authored by John Budorick's avatar John Budorick Committed by Commit Bot

gclient: Use posixpath-style separators for cipd subdirs on all platforms.

Bug: 854219
Change-Id: Ibd83135dcb96979f8ab989a248e3e2cf59b9dd43
Reviewed-on: https://chromium-review.googlesource.com/1106698
Commit-Queue: John Budorick <jbudorick@chromium.org>
Reviewed-by: 's avatarAaron Gable <agable@chromium.org>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
parent 04925ac3
...@@ -1810,8 +1810,10 @@ class CipdDependency(Dependency): ...@@ -1810,8 +1810,10 @@ class CipdDependency(Dependency):
'Relative CIPD dependencies are not currently supported.') 'Relative CIPD dependencies are not currently supported.')
self._cipd_package = None self._cipd_package = None
self._cipd_root = cipd_root self._cipd_root = cipd_root
self._cipd_subdir = os.path.relpath( # CIPD wants /-separated paths, even on Windows.
native_subdir_path = os.path.relpath(
os.path.join(self.root.root_dir, name), cipd_root.root_dir) os.path.join(self.root.root_dir, name), cipd_root.root_dir)
self._cipd_subdir = posixpath.join(*native_subdir_path.split(os.sep))
self._package_name = package self._package_name = package
self._package_version = version self._package_version = version
...@@ -1869,7 +1871,9 @@ class CipdDependency(Dependency): ...@@ -1869,7 +1871,9 @@ class CipdDependency(Dependency):
' "%s": {' % (self.name.split(':')[0],), ' "%s": {' % (self.name.split(':')[0],),
' "packages": [', ' "packages": [',
]) ])
for p in self._cipd_root.packages(self._cipd_subdir): for p in sorted(
self._cipd_root.packages(self._cipd_subdir),
cmp=lambda x, y: cmp(x.name, y.name)):
s.extend([ s.extend([
' {', ' {',
' "package": "%s",' % p.name, ' "package": "%s",' % p.name,
......
...@@ -11,6 +11,7 @@ See gclient_smoketest.py for integration tests. ...@@ -11,6 +11,7 @@ See gclient_smoketest.py for integration tests.
import Queue import Queue
import copy import copy
import logging import logging
import ntpath
import os import os
import sys import sys
import unittest import unittest
...@@ -21,6 +22,7 @@ import gclient ...@@ -21,6 +22,7 @@ import gclient
import gclient_utils import gclient_utils
import gclient_scm import gclient_scm
from testing_support import trial_dir from testing_support import trial_dir
from third_party import mock
def write(filename, content): def write(filename, content):
...@@ -1078,6 +1080,36 @@ class GclientTest(trial_dir.TestCase): ...@@ -1078,6 +1080,36 @@ class GclientTest(trial_dir.TestCase):
self.assertEquals('https://example.com/foo_package@foo_version', dep0.url) self.assertEquals('https://example.com/foo_package@foo_version', dep0.url)
self.assertEquals('https://example.com/bar_package@bar_version', dep1.url) self.assertEquals('https://example.com/bar_package@bar_version', dep1.url)
def _testPosixpathImpl(self):
parser = gclient.OptionParser()
options, _ = parser.parse_args([])
obj = gclient.GClient('src', options)
cipd_root = obj.GetCipdRoot()
cipd_dep = gclient.CipdDependency(
parent=obj,
name='src/foo/bar/baz',
dep_value={
'package': 'baz_package',
'version': 'baz_version',
},
cipd_root=cipd_root,
custom_vars=None,
should_process=True,
relative=False,
condition=None)
self.assertEquals(cipd_dep._cipd_subdir, 'src/foo/bar/baz')
def testPosixpathCipdSubdir(self):
self._testPosixpathImpl()
# CIPD wants posixpath separators for subdirs, even on windows.
# See crbug.com/854219.
def testPosixpathCipdSubdirOnWindows(self):
with mock.patch('os.path', new=ntpath), (
mock.patch('os.sep', new=ntpath.sep)):
self._testPosixpathImpl()
def testFuzzyMatchUrlByURL(self): def testFuzzyMatchUrlByURL(self):
write( write(
'.gclient', '.gclient',
......
...@@ -1979,7 +1979,7 @@ class CannedChecksUnittest(PresubmitTestsBase): ...@@ -1979,7 +1979,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
input_api = self.MockInputApi(change1, False) input_api = self.MockInputApi(change1, False)
affected_files = (affected_file1, affected_file2) affected_files = (affected_file1, affected_file2)
input_api.AffectedFiles = lambda: affected_files input_api.AffectedFiles = lambda **_: affected_files
self.mox.ReplayAll() self.mox.ReplayAll()
...@@ -2389,7 +2389,7 @@ class CannedChecksUnittest(PresubmitTestsBase): ...@@ -2389,7 +2389,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
affected_file.Action = lambda: 'M' affected_file.Action = lambda: 'M'
change = self.mox.CreateMock(presubmit.Change) change = self.mox.CreateMock(presubmit.Change)
change.AffectedFiles = lambda: [affected_file] change.AffectedFiles = lambda **_: [affected_file]
input_api = self.MockInputApi(None, False) input_api = self.MockInputApi(None, False)
input_api.change = change input_api.change = change
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment