From 0ddbf022831475ffbe56f1465961c54a19f178ef Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Fri, 28 Apr 2023 22:07:56 +0000 Subject: [PATCH] [py3] Run gclient git test with py3 R=gavinmak@google.com Bug: 1376538 Change-Id: I742bc767cb6d7164921a481658517ae148127d47 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4491345 Commit-Queue: Josip Sokcevic Reviewed-by: Gavin Mak --- testing_support/fake_repos.py | 26 +++++++++++++------------- tests/gclient_git_smoketest.py | 33 ++++++++++++++++----------------- 2 files changed, 29 insertions(+), 30 deletions(-) mode change 100644 => 100755 tests/gclient_git_smoketest.py diff --git a/testing_support/fake_repos.py b/testing_support/fake_repos.py index ad83db109..0c9797d90 100755 --- a/testing_support/fake_repos.py +++ b/testing_support/fake_repos.py @@ -325,13 +325,13 @@ deps = { hooks = [ { 'pattern': '.', - 'action': ['python', '-c', + 'action': ['python3', '-c', 'open(\\'src/git_hooked1\\', \\'w\\').write(\\'git_hooked1\\')'], }, { # Should not be run. 'pattern': 'nonexistent', - 'action': ['python', '-c', + 'action': ['python3', '-c', 'open(\\'src/git_hooked2\\', \\'w\\').write(\\'git_hooked2\\')'], }, ] @@ -357,7 +357,7 @@ deps = { # processed. pre_deps_hooks = [ { - 'action': ['python', '-c', + 'action': ['python3', '-c', 'print("pre-deps hook"); open(\\'src/git_pre_deps_hooked\\', \\'w\\').write(\\'git_pre_deps_hooked\\')'], } ] @@ -379,11 +379,11 @@ deps = { # processed. pre_deps_hooks = [ { - 'action': ['python', '-c', + 'action': ['python3', '-c', 'print("pre-deps hook"); open(\\'src/git_pre_deps_hooked\\', \\'w\\').write(\\'git_pre_deps_hooked\\')'], }, { - 'action': ['python', '-c', 'import sys; sys.exit(1)'], + 'action': ['python3', '-c', 'import sys; sys.exit(1)'], } ] """ % { @@ -463,13 +463,13 @@ hooks = [ { 'pattern': '.', 'condition': 'True', - 'action': ['python', '-c', + 'action': ['python3', '-c', 'open(\\'src/git_hooked1\\', \\'w\\').write(\\'{hook1_contents}\\')'], }, { # Should not be run. 'pattern': 'nonexistent', - 'action': ['python', '-c', + 'action': ['python3', '-c', 'open(\\'src/git_hooked2\\', \\'w\\').write(\\'git_hooked2\\')'], }, ] @@ -477,7 +477,7 @@ hooks_os = { 'mac': [ { 'pattern': '.', - 'action': ['python', '-c', + 'action': ['python3', '-c', 'open(\\'src/git_hooked_mac\\', \\'w\\').write(' '\\'git_hooked_mac\\')'], }, @@ -503,12 +503,12 @@ vars = { } hooks = [ { - 'action': ['python', '-c', + 'action': ['python3', '-c', 'open(\\'src/should_run\\', \\'w\\').write(\\'should_run\\')'], 'condition': 'true_var or True', }, { - 'action': ['python', '-c', + 'action': ['python3', '-c', 'open(\\'src/should_not_run\\', \\'w\\').write(\\'should_not_run\\')'], 'condition': 'false_var', }, @@ -651,7 +651,7 @@ deps = { } hooks = [{ # make sure src/repo12 exists and is a CIPD dir. - 'action': ['python', '-c', 'with open("src/repo12/_cipd"): pass'], + 'action': ['python3', '-c', 'with open("src/repo12/_cipd"): pass'], }] """, 'origin': 'git/repo_13@3\n' @@ -702,7 +702,7 @@ hooks = [{ hooks = [{ "name": "absolute_cwd", "pattern": ".", - "action": ["python", "-c", "pass"] + "action": ["python3", "-c", "pass"] }]"""), 'origin': 'git/repo_15@2\n' }) @@ -713,7 +713,7 @@ hooks = [{ hooks = [{ "name": "relative_cwd", "pattern": ".", - "action": ["python", "relative.py"] + "action": ["python3", "relative.py"] }]"""), 'relative.py': 'pass', 'origin': 'git/repo_16@2\n' diff --git a/tests/gclient_git_smoketest.py b/tests/gclient_git_smoketest.py old mode 100644 new mode 100755 index 6f270e15d..a50086b0c --- a/tests/gclient_git_smoketest.py +++ b/tests/gclient_git_smoketest.py @@ -427,10 +427,9 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase): ('running', self.root_dir), # pre-deps hook ('running', self.root_dir), # pre-deps hook (fails) ] - vpython = 'vpython.bat' if sys.platform == 'win32' else 'vpython' - expected_stderr = ("Error: Command '%s -c import sys; " - "sys.exit(1)' returned non-zero exit status 1 in %s\n" - % (vpython, self.root_dir)) + expected_stderr = ("Error: Command 'python3 -c import sys; " + "sys.exit(1)' returned non-zero exit status 1 in %s\n" % + (self.root_dir)) stdout, stderr, retcode = self.gclient( ['sync', '--deps', 'mac', '--jobs=1', '--revision', 'src@' + self.githash('repo_5', 3)], error_ok=True) @@ -603,7 +602,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase): 'hooks = [{', ' "name": "uses_builtin_var",', ' "pattern": ".",', - ' "action": ["python", "fake.py",', + ' "action": ["python3", "fake.py",', ' "--with-android={checkout_android}"],', '}]', ])) @@ -629,7 +628,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase): 'hooks = [{', ' "name": "uses_builtin_var",', ' "pattern": ".",', - ' "action": ["python", "fake.py",', + ' "action": ["python3", "fake.py",', ' "--with-android={checkout_android}"],', '}]', ], contents) @@ -678,7 +677,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase): 'hooks = [{', ' "name": "uses_builtin_var",', ' "pattern": ".",', - ' "action": ["python", "fake.py",', + ' "action": ["python3", "fake.py",', ' "--with-android={checkout_android}"],', '}]', ])) @@ -803,7 +802,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase): ' "condition": \'True\',', ' "cwd": ".",', ' "action": [', - ' "python",', + ' "python3",', ' "-c",', ' "open(\'src/git_hooked1\', \'w\')' '.write(\'git_hooked1\')",', @@ -815,7 +814,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase): ' "pattern": "nonexistent",', ' "cwd": ".",', ' "action": [', - ' "python",', + ' "python3",', ' "-c",', ' "open(\'src/git_hooked2\', \'w\').write(\'git_hooked2\')",', ' ]', @@ -827,7 +826,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase): ' "condition": \'checkout_mac\',', ' "cwd": ".",', ' "action": [', - ' "python",', + ' "python3",', ' "-c",', ' "open(\'src/git_hooked_mac\', \'w\').write(' '\'git_hooked_mac\')",', @@ -840,7 +839,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase): ' "pattern": ".",', ' "cwd": ".",', ' "action": [', - ' "python",', + ' "python3",', ' "-c",', ' "pass",', ' ]', @@ -852,7 +851,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase): ' "pattern": ".",', ' "cwd": "src/repo16",', ' "action": [', - ' "python",', + ' "python3",', ' "relative.py",', ' ]', ' },', @@ -1008,7 +1007,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase): ' "condition": \'True\',', ' "cwd": ".",', ' "action": [', - ' "python",', + ' "python3",', ' "-c",', ' "open(\'src/git_hooked1\', \'w\')' '.write(\'git_hooked1\')",', @@ -1020,7 +1019,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase): ' "pattern": "nonexistent",', ' "cwd": ".",', ' "action": [', - ' "python",', + ' "python3",', ' "-c",', ' "open(\'src/git_hooked2\', \'w\').write(\'git_hooked2\')",', ' ]', @@ -1032,7 +1031,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase): ' "condition": \'checkout_mac\',', ' "cwd": ".",', ' "action": [', - ' "python",', + ' "python3",', ' "-c",', ' "open(\'src/git_hooked_mac\', \'w\').write(' '\'git_hooked_mac\')",', @@ -1045,7 +1044,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase): ' "pattern": ".",', ' "cwd": ".",', ' "action": [', - ' "python",', + ' "python3",', ' "-c",', ' "pass",', ' ]', @@ -1057,7 +1056,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase): ' "pattern": ".",', ' "cwd": "src/repo16",', ' "action": [', - ' "python",', + ' "python3",', ' "relative.py",', ' ]', ' },',