diff --git a/ci/builders/linux_android_debug_engine.json b/ci/builders/linux_android_debug_engine.json index e004a47b6822f..07be90ab6c690 100644 --- a/ci/builders/linux_android_debug_engine.json +++ b/ci/builders/linux_android_debug_engine.json @@ -33,7 +33,7 @@ }, "tests": [ { - "language": "python", + "language": "python3", "name": "Host Tests for android_jit_release_x86", "parameters": [ "--variant", @@ -115,7 +115,7 @@ }, "tests": [ { - "language": "python", + "language": "python3", "name": "Host Tests for android_debug", "parameters": [ "--variant", diff --git a/ci/builders/linux_host_engine.json b/ci/builders/linux_host_engine.json index 876fca52c101c..395b5ec9270ad 100644 --- a/ci/builders/linux_host_engine.json +++ b/ci/builders/linux_host_engine.json @@ -53,7 +53,7 @@ }, "tests": [ { - "language": "python", + "language": "python3", "name": "Host Tests for host_debug_impeller_vulkan", "parameters": [ "--variant", @@ -148,7 +148,7 @@ }, "tests": [ { - "language": "python", + "language": "python3", "name": "Host Tests for host_profile", "parameters": [ "--variant", @@ -198,7 +198,7 @@ }, "tests": [ { - "language": "python", + "language": "python3", "name": "Host Tests for host_release", "parameters": [ "--variant", diff --git a/ci/builders/mac_host_engine.json b/ci/builders/mac_host_engine.json index 834563eeb142a..729ebf13f7c61 100644 --- a/ci/builders/mac_host_engine.json +++ b/ci/builders/mac_host_engine.json @@ -82,7 +82,7 @@ }, "tests": [ { - "language": "python", + "language": "python3", "name": "Host Tests for host_profile", "parameters": [ "--variant", diff --git a/ci/builders/mac_ios_engine.json b/ci/builders/mac_ios_engine.json index 68fc73f63ba68..9ae1f41b812bb 100644 --- a/ci/builders/mac_ios_engine.json +++ b/ci/builders/mac_ios_engine.json @@ -87,7 +87,7 @@ "out/ios_debug_sim_arm64" ], "script": "flutter/sky/tools/create_full_ios_framework.py", - "language": "python" + "language": "python3" }, { "name": "obj-c-doc", diff --git a/ci/builders/mac_ios_engine_profile.json b/ci/builders/mac_ios_engine_profile.json index ee762339ded0b..2d9891355a021 100644 --- a/ci/builders/mac_ios_engine_profile.json +++ b/ci/builders/mac_ios_engine_profile.json @@ -83,7 +83,7 @@ "out/ios_debug_sim_arm64" ], "script": "flutter/sky/tools/create_full_ios_framework.py", - "language": "python" + "language": "python3" } ] }, diff --git a/ci/builders/mac_ios_engine_release.json b/ci/builders/mac_ios_engine_release.json index 269dd67d0e8cb..2de17631cf171 100644 --- a/ci/builders/mac_ios_engine_release.json +++ b/ci/builders/mac_ios_engine_release.json @@ -85,7 +85,7 @@ "--strip" ], "script": "flutter/sky/tools/create_full_ios_framework.py", - "language": "python" + "language": "python3" }, { "name": "release-nobitcode-FlutterMacOS.framework", @@ -102,7 +102,7 @@ "--strip" ], "script": "flutter/sky/tools/create_full_ios_framework.py", - "language": "python" + "language": "python3" }, { "name": "Release-macos-gen-snapshots", @@ -113,7 +113,7 @@ "out/ios_release" ], "script": "flutter/sky/tools/create_macos_gen_snapshots.py", - "language": "python" + "language": "python3" } ] }, diff --git a/ci/builders/windows_host_engine.json b/ci/builders/windows_host_engine.json index a22943aae63db..3ca9c796c4fce 100644 --- a/ci/builders/windows_host_engine.json +++ b/ci/builders/windows_host_engine.json @@ -46,7 +46,7 @@ }, "tests": [ { - "language": "python", + "language": "python3", "name": "Host Tests for host_debug", "parameters": [ "--variant", diff --git a/ci/compatibility_helper.py b/ci/compatibility_helper.py new file mode 100644 index 0000000000000..0d8231ca178e7 --- /dev/null +++ b/ci/compatibility_helper.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +# +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# This script contains helper function(s) for supporting both +# python 2 and python 3 infrastructure code. + +ENCODING = 'UTF-8' + + +def byte_str_decode(str_or_bytes): + """Returns a string if given either a string or bytes. + + TODO: This function should be removed when the supported python + version is only python 3. + + Args: + str_or_bytes (string or bytes) we want to convert or return as + the possible value changes depending on the version of python + used. + """ + return str_or_bytes if isinstance(str_or_bytes, + str) else str_or_bytes.decode(ENCODING) diff --git a/ci/firebase_testlab.py b/ci/firebase_testlab.py index 92069a7c1f584..510f582e8b82d 100755 --- a/ci/firebase_testlab.py +++ b/ci/firebase_testlab.py @@ -10,6 +10,7 @@ import os import subprocess import sys +from compatibility_helper import byte_str_decode if 'STORAGE_BUCKET' not in os.environ: print('The GCP storage bucket must be provided as an environment variable.') @@ -67,6 +68,7 @@ def check_logcat(results_dir): 'gsutil', 'cat', '%s/%s/*/logcat' % (BUCKET, results_dir) ]) + logcat = byte_str_decode(logcat) if not logcat: sys.exit(1) @@ -82,7 +84,9 @@ def check_timeline(results_dir): 'gsutil', 'du', '%s/%s/*/game_loop_results/results_scenario_0.json' % (BUCKET, results_dir) - ]).strip() + ]) + gsutil_du = byte_str_decode(gsutil_du) + gsutil_du = gsutil_du.strip() if gsutil_du == '0': print('Failed to produce a timeline.') sys.exit(1) @@ -113,8 +117,9 @@ def main(): return 1 git_revision = subprocess.check_output(['git', 'rev-parse', 'HEAD'], - cwd=script_dir).strip() - + cwd=script_dir) + git_revision = byte_str_decode(git_revision) + git_revision = git_revision.strip() results = [] apk = None for apk in apks: diff --git a/ci/scan_flattened_deps.py b/ci/scan_flattened_deps.py index ece1154fb97a4..0184db7a9e6bf 100644 --- a/ci/scan_flattened_deps.py +++ b/ci/scan_flattened_deps.py @@ -17,6 +17,7 @@ import subprocess import sys from urllib import request +from compatibility_helper import byte_str_decode SCRIPT_DIR = os.path.dirname(sys.argv[0]) CHECKOUT_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) @@ -206,7 +207,9 @@ def get_common_ancestor_commit(dep, deps_list): 'git --git-dir ' + temp_dep_dir + '/.git remote show upstream ' + "| sed -n \'/HEAD branch/s/.*: //p\'", shell=True - ).decode().strip() + ) + default_branch = byte_str_decode(default_branch) + default_branch = default_branch.strip() print( 'default_branch found: {default_branch}'.format( default_branch=default_branch @@ -223,7 +226,8 @@ def get_common_ancestor_commit(dep, deps_list): "--format=\'%(objectname:short)\' refs/heads/upstream", shell=True ) - commit = commit.decode().strip() + commit = byte_str_decode(commit) + commit = commit.strip() # perform merge-base on most recent default branch commit and pinned mirror commit ancestor_commit = subprocess.check_output( @@ -232,7 +236,8 @@ def get_common_ancestor_commit(dep, deps_list): ), shell=True ) - ancestor_commit = ancestor_commit.decode().strip() + ancestor_commit = byte_str_decode(ancestor_commit) + ancestor_commit = ancestor_commit.strip() print('Ancestor commit: ' + ancestor_commit) return ancestor_commit except subprocess.CalledProcessError as error: diff --git a/testing/run_tests.py b/testing/run_tests.py index acbfa9c0cac61..32b77d5397b04 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -32,7 +32,8 @@ roboto_font_path = os.path.join(fonts_dir, 'Roboto-Regular.ttf') font_subset_dir = os.path.join(buildroot_dir, 'flutter', 'tools', 'font-subset') -fml_unittests_filter = '--gtest_filter=-*TimeSensitiveTest*' +FML_UNITTESTS_FILTER = '--gtest_filter=-*TimeSensitiveTest*' +ENCODING = 'UTF-8' def PrintDivider(char='='): @@ -341,7 +342,7 @@ def make_test(name, flags=repeat_flags, extra_env={}): make_test('embedder_a11y_unittests'), make_test('embedder_proctable_unittests'), make_test('embedder_unittests'), - make_test('fml_unittests', flags=[fml_unittests_filter] + repeat_flags), + make_test('fml_unittests', flags=[FML_UNITTESTS_FILTER] + repeat_flags), make_test('no_dart_plugin_registrant_unittests'), make_test('runtime_unittests'), make_test('testing_unittests'), @@ -569,8 +570,13 @@ def EnsureIosTestsAreBuilt(ios_out_dir): def AssertExpectedXcodeVersion(): """Checks that the user has a version of Xcode installed""" version_output = subprocess.check_output(['xcodebuild', '-version']) - match = re.match(b"Xcode (\d+)", version_output) - message = "Xcode must be installed to run the iOS embedding unit tests" + # TODO ricardoamador: remove this check when python 2 is deprecated. + version_output = version_output if isinstance( + version_output, str + ) else version_output.decode(ENCODING) + version_output = version_output.strip() + match = re.match(r'Xcode (\d+)', version_output) + message = 'Xcode must be installed to run the iOS embedding unit tests' assert match, message diff --git a/tools/fuchsia/merge_and_upload_debug_symbols.py b/tools/fuchsia/merge_and_upload_debug_symbols.py index 6e1038ed7ce1f..6005b6dcfc8ae 100755 --- a/tools/fuchsia/merge_and_upload_debug_symbols.py +++ b/tools/fuchsia/merge_and_upload_debug_symbols.py @@ -64,6 +64,7 @@ def CheckCIPDPackageExists(package_name, tag): tag, ] stdout = subprocess.check_output(command) + stdout = stdout if isinstance(stdout, str) else stdout.decode('UTF-8') match = re.search(r'No matching instances\.', stdout) if match: return False