Commit 05934953 authored by Edward Lesmes's avatar Edward Lesmes Committed by Commit Bot

gclient: Make smoketests run on Windows.

Bug: 1024683
Change-Id: I1c30473699c1bd6b198188b53b632e3617fed335
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1929653Reviewed-by: 's avatarAnthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent a892219c
......@@ -70,7 +70,6 @@ def CommonChecks(input_api, output_api, tests_to_black_list, run_on_python3):
print('Warning: skipping most unit tests on Windows')
tests_to_black_list = [
r'.*auth_test\.py$',
r'.*gclient_smoketest\.py$',
r'.*git_cl_test\.py$',
r'.*git_common_test\.py$',
r'.*git_hyper_blame_test\.py$',
......
......@@ -84,6 +84,10 @@ def fix_win_sys_argv(encoding):
if _SYS_ARGV_PROCESSED:
return False
if sys.version_info.major == 3:
_SYS_ARGV_PROCESSED = True
return True
# These types are available on linux but not Mac.
# pylint: disable=no-name-in-module,F0401
from ctypes import byref, c_int, POINTER, windll, WINFUNCTYPE
......@@ -269,6 +273,9 @@ class WinUnicodeOutput(WinUnicodeOutputBase):
if sys.version_info.major == 2 and isinstance(text, unicode):
# Replace characters that cannot be printed instead of failing.
text = text.encode(self.encoding, 'replace')
if sys.version_info.major == 3 and isinstance(text, bytes):
# Replace characters that cannot be printed instead of failing.
text = text.decode(self.encoding, 'replace')
self._stream.write(text)
except Exception as e:
complain('%s.write: %r' % (self.name, e))
......
......@@ -1042,8 +1042,8 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
if isinstance(value, basestring):
value = gclient_eval.EvaluateCondition(value, variables)
lines.append('%s = %s' % (arg, ToGNString(value)))
with open(os.path.join(self.root.root_dir, self._gn_args_file), 'w') as f:
f.write('\n'.join(lines))
with open(os.path.join(self.root.root_dir, self._gn_args_file), 'wb') as f:
f.write('\n'.join(lines).encode('utf-8', 'replace'))
@gclient_utils.lockedmethod
def _run_is_done(self, file_list):
......@@ -1322,10 +1322,10 @@ class GClient(GitDependency):
DEFAULT_CLIENT_FILE_TEXT = ("""\
solutions = [
{ "name" : "%(solution_name)s",
"url" : "%(solution_url)s",
"deps_file" : "%(deps_file)s",
"managed" : %(managed)s,
{ "name" : %(solution_name)r,
"url" : %(solution_url)r,
"deps_file" : %(deps_file)r,
"managed" : %(managed)r,
"custom_deps" : {
},
"custom_vars": %(custom_vars)r,
......
......@@ -1475,15 +1475,16 @@ class CipdRoot(object):
@contextlib.contextmanager
def _create_ensure_file(self):
try:
contents = '$ParanoidMode CheckPresence\n\n'
for subdir, packages in sorted(self._packages_by_subdir.items()):
contents += '@Subdir %s\n' % subdir
for package in sorted(packages, key=lambda p: p.name):
contents += '%s %s\n' % (package.name, package.version)
contents += '\n'
ensure_file = None
with tempfile.NamedTemporaryFile(
suffix='.ensure', delete=False, mode='w') as ensure_file:
ensure_file.write('$ParanoidMode CheckPresence\n\n')
for subdir, packages in sorted(self._packages_by_subdir.items()):
ensure_file.write('@Subdir %s\n' % subdir)
for package in sorted(packages, key=lambda p: p.name):
ensure_file.write('%s %s\n' % (package.name, package.version))
ensure_file.write('\n')
suffix='.ensure', delete=False, mode='wb') as ensure_file:
ensure_file.write(contents.encode('utf-8', 'replace'))
yield ensure_file.name
finally:
if ensure_file is not None and os.path.exists(ensure_file.name):
......
......@@ -40,8 +40,8 @@ def main():
for path, packages in new_content.items():
if not os.path.exists(path):
os.makedirs(path)
with open(os.path.join(path, '_cipd'), 'w') as f:
f.write('\n'.join(packages))
with open(os.path.join(path, '_cipd'), 'wb') as f:
f.write('\n'.join(packages).encode('utf-8', 'replace'))
# Save the ensure file that we got
shutil.copy(args.ensure_file, os.path.join(args.root, '_cipd'))
......
......@@ -249,7 +249,7 @@ gclient_gn_args = [
]
deps = {
'src/repo2': {
'url': '%(git_base)srepo_2',
'url': %(git_base)r + 'repo_2',
'condition': 'True',
},
'src/repo2/repo3': '/' + Var('DummyVariable') + '_3@%(hash3)s',
......@@ -305,7 +305,7 @@ deps = {
self._commit_git('repo_1', {
'DEPS': """
deps = {
'src/repo2': '%(git_base)srepo_2@%(hash)s',
'src/repo2': %(git_base)r + 'repo_2@%(hash)s',
'src/repo2/repo_renamed': '/repo_3',
'src/should_not_process': {
'url': '/repo_4',
......@@ -341,8 +341,8 @@ hooks = [
self._commit_git('repo_5', {
'DEPS': """
deps = {
'src/repo1': '%(git_base)srepo_1@%(hash1)s',
'src/repo2': '%(git_base)srepo_2@%(hash2)s',
'src/repo1': %(git_base)r + 'repo_1@%(hash1)s',
'src/repo2': %(git_base)r + 'repo_2@%(hash2)s',
}
# Hooks to run after a project is processed but before its dependencies are
......@@ -363,8 +363,8 @@ pre_deps_hooks = [
self._commit_git('repo_5', {
'DEPS': """
deps = {
'src/repo1': '%(git_base)srepo_1@%(hash1)s',
'src/repo2': '%(git_base)srepo_2@%(hash2)s',
'src/repo1': %(git_base)r + 'repo_1@%(hash1)s',
'src/repo2': %(git_base)r + 'repo_2@%(hash2)s',
}
# Hooks to run after a project is processed but before its dependencies are
......@@ -390,7 +390,7 @@ pre_deps_hooks = [
'DEPS': """
vars = {
'DummyVariable': 'repo',
'git_base': '%(git_base)s',
'git_base': %(git_base)r,
'hook1_contents': 'git_hooked1',
'repo5_var': '/repo_5',
......@@ -413,7 +413,7 @@ gclient_gn_args = [
]
allowed_hosts = [
'%(git_base)s',
%(git_base)r,
]
deps = {
'src/repo2': {
......@@ -718,13 +718,13 @@ class FakeRepoSkiaDEPS(FakeReposBase):
NB_GIT_REPOS = 5
DEPS_git_pre = """deps = {
'src/third_party/skia/gyp': '%(git_base)srepo_3',
'src/third_party/skia/include': '%(git_base)srepo_4',
'src/third_party/skia/src': '%(git_base)srepo_5',
'src/third_party/skia/gyp': %(git_base)r + 'repo_3',
'src/third_party/skia/include': %(git_base)r + 'repo_4',
'src/third_party/skia/src': %(git_base)r + 'repo_5',
}"""
DEPS_post = """deps = {
'src/third_party/skia': '%(git_base)srepo_1',
'src/third_party/skia': %(git_base)r + 'repo_1',
}"""
def populateGit(self):
......
This diff is collapsed.
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