From a877ee62b1fcd52c590d466ffdd0b2df5bd3e74e Mon Sep 17 00:00:00 2001 From: Edward Lemur Date: Tue, 3 Sep 2019 20:23:17 +0000 Subject: [PATCH] depot_tools: Run some tests on Python 3 on the bots. Bug: 984182 Change-Id: I0b7f1e3e056548a27a416c9b4078e54c9e5d60d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1769400 Auto-Submit: Edward Lesmes Commit-Queue: Andrii Shyshkalov Reviewed-by: Andrii Shyshkalov --- PRESUBMIT.py | 13 +++++++------ gclient_utils.py | 2 +- testing_support/subprocess2_test_script.py | 2 +- tests/gclient_eval_unittest.py | 2 +- tests/gclient_scm_test.py | 2 +- tests/gclient_test.py | 6 +++--- tests/gclient_utils_test.py | 2 +- tests/metrics_test.py | 2 +- tests/scm_unittest.py | 2 +- tests/subprocess2_test.py | 2 +- 10 files changed, 18 insertions(+), 17 deletions(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index d0598591ac..a0999bd27c 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -56,7 +56,7 @@ def DepotToolsPylint(input_api, output_api): disabled_warnings=disabled_warnings) -def CommonChecks(input_api, output_api, tests_to_black_list): +def CommonChecks(input_api, output_api, tests_to_black_list, run_on_python3): results = [] results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) results.extend(input_api.canned_checks.CheckOwnersFormat( @@ -78,7 +78,8 @@ def CommonChecks(input_api, output_api, tests_to_black_list): output_api, 'tests', whitelist=tests_to_white_list, - blacklist=tests_to_black_list)) + blacklist=tests_to_black_list, + run_on_python3=run_on_python3)) # Validate CIPD manifests. root = input_api.os_path.normpath( @@ -120,15 +121,15 @@ def CheckChangeOnUpload(input_api, output_api): r'^checkout_test\.py$', r'^cipd_bootstrap_test\.py$', r'^gclient_smoketest\.py$', - r'^scm_unittest\.py$', - r'^subprocess2_test\.py$', ] - return CommonChecks(input_api, output_api, tests_to_black_list) + # TODO(ehmaldonado): Run Python 3 tests on upload once Python 3 is + # bootstrapped on Linux and Mac. + return CommonChecks(input_api, output_api, tests_to_black_list, False) def CheckChangeOnCommit(input_api, output_api): output = [] - output.extend(CommonChecks(input_api, output_api, [])) + output.extend(CommonChecks(input_api, output_api, [], True)) output.extend(input_api.canned_checks.CheckDoNotSubmit( input_api, output_api)) diff --git a/gclient_utils.py b/gclient_utils.py index 45617dfdf3..7b4ae5664b 100644 --- a/gclient_utils.py +++ b/gclient_utils.py @@ -916,7 +916,7 @@ class ExecutionQueue(object): running = self.running self.running = [] for t in running: - if t.isAlive(): + if t.is_alive(): self.running.append(t) else: t.join() diff --git a/testing_support/subprocess2_test_script.py b/testing_support/subprocess2_test_script.py index 8e0139d50e..83b64446ef 100644 --- a/testing_support/subprocess2_test_script.py +++ b/testing_support/subprocess2_test_script.py @@ -48,7 +48,7 @@ do('A') do('BB') do('CCC') if options.read: - assert options.return_value is 0 + assert options.return_value == 0 try: while sys.stdin.read(1): options.return_value += 1 diff --git a/tests/gclient_eval_unittest.py b/tests/gclient_eval_unittest.py index 5821d7f059..03a460ee1f 100755 --- a/tests/gclient_eval_unittest.py +++ b/tests/gclient_eval_unittest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env vpython3 # Copyright 2017 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py index 2081446e53..2a4f3d9a78 100755 --- a/tests/gclient_scm_test.py +++ b/tests/gclient_scm_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env vpython3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/tests/gclient_test.py b/tests/gclient_test.py index e260d06f1b..8516e04b24 100755 --- a/tests/gclient_test.py +++ b/tests/gclient_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env vpython3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -565,8 +565,8 @@ class GclientTest(trial_dir.TestCase): obj = gclient.GClient.LoadCurrentConfig(options) obj.RunOnDeps('None', []) self.assertEqual(['unix'], sorted(obj.enforced_os)) - self.assertEqual([('unix', 'baz'), ('unix',)], - [dep.target_os for dep in obj.dependencies]) + self.assertEqual([('unix',), ('unix', 'baz')], + sorted(dep.target_os for dep in obj.dependencies)) self.assertEqual([('foo', 'svn://example.com/foo'), ('bar', 'svn://example.com/bar')], self._get_processed()) diff --git a/tests/gclient_utils_test.py b/tests/gclient_utils_test.py index 98bdffe4b0..adb0e633dd 100755 --- a/tests/gclient_utils_test.py +++ b/tests/gclient_utils_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env vpython3 # coding=utf-8 # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/tests/metrics_test.py b/tests/metrics_test.py index 0e6973ae1e..2345bd1b5a 100644 --- a/tests/metrics_test.py +++ b/tests/metrics_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env vpython3 # Copyright (c) 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/tests/scm_unittest.py b/tests/scm_unittest.py index eeb98702a4..150f95629a 100755 --- a/tests/scm_unittest.py +++ b/tests/scm_unittest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env vpython3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/tests/subprocess2_test.py b/tests/subprocess2_test.py index ace3e996b5..e93bdfc2be 100755 --- a/tests/subprocess2_test.py +++ b/tests/subprocess2_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env vpython3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.