Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions ci/compatibility_helper.py
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 8 additions & 3 deletions ci/firebase_testlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
11 changes: 8 additions & 3 deletions ci/scan_flattened_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, '..'))
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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:
Expand Down
13 changes: 12 additions & 1 deletion testing/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='='):
Expand Down Expand Up @@ -569,8 +570,18 @@ def EnsureIosTestsAreBuilt(ios_out_dir):
def AssertExpectedXcodeVersion():
"""Checks that the user has a version of Xcode installed"""
version_output = subprocess.check_output(['xcodebuild', '-version'])
<<<<<<< HEAD
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'
>>>>>>> ba188d7ca2 (Update infrastructure python code to be compatible with python 2 and python 3 (#39133))
assert match, message


Expand Down