Merge changes I47b4756d,I0564369e am: f486885133 am: 39e7a58749
Original change: https://android-review.googlesource.com/c/platform/development/+/1804439 Change-Id: Ie7b51080ffe15b69bbff2f36218ae94988fdb2f4
This commit is contained in:
@@ -27,11 +27,15 @@ argument is provided, it assumes the crate is the current directory.
|
|||||||
This script is automatically called by external_updater.
|
This script is automatically called by external_updater.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import glob
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from datetime import datetime
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
# Some tests requires specific options. Consider fixing the upstream crate
|
# Some tests requires specific options. Consider fixing the upstream crate
|
||||||
# before updating this dictionary.
|
# before updating this dictionary.
|
||||||
@@ -245,19 +249,47 @@ class TestMapping(object):
|
|||||||
print("TEST_MAPPING successfully updated for %s!" % self.package.dir_rel)
|
print("TEST_MAPPING successfully updated for %s!" % self.package.dir_rel)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
parser = argparse.ArgumentParser('update_crate_tests')
|
||||||
|
parser.add_argument('paths',
|
||||||
|
nargs='*',
|
||||||
|
help='Absolute or relative paths of the projects as globs.')
|
||||||
|
parser.add_argument('--branch_and_commit',
|
||||||
|
action='store_true',
|
||||||
|
help='Starts a new branch and commit changes.')
|
||||||
|
parser.add_argument('--push_change',
|
||||||
|
action='store_true',
|
||||||
|
help='Pushes change to Gerrit.')
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) > 1:
|
args = parse_args()
|
||||||
paths = sys.argv[1:]
|
paths = args.paths if len(args.paths) > 0 else [os.getcwd()]
|
||||||
else:
|
# We want to use glob to get all the paths, so we first convert to absolute.
|
||||||
paths = [os.getcwd()]
|
paths = [Path(path).resolve() for path in paths]
|
||||||
|
paths = sorted([path for abs_path in paths
|
||||||
|
for path in glob.glob(str(abs_path))])
|
||||||
|
|
||||||
env = Env()
|
env = Env()
|
||||||
bazel = Bazel(env)
|
bazel = Bazel(env)
|
||||||
for path in paths:
|
for path in paths:
|
||||||
try:
|
try:
|
||||||
test_mapping = TestMapping(env, bazel, path)
|
test_mapping = TestMapping(env, bazel, path)
|
||||||
except UpdaterException as err:
|
test_mapping.create()
|
||||||
|
changed = (subprocess.call(['git', 'diff', '--quiet']) == 1)
|
||||||
|
if changed and args.branch_and_commit:
|
||||||
|
subprocess.check_output(['repo', 'start',
|
||||||
|
'tmp_auto_test_mapping', '.'])
|
||||||
|
subprocess.check_output(['git', 'add', 'TEST_MAPPING'])
|
||||||
|
subprocess.check_output(['git', 'commit', '-m',
|
||||||
|
'Update TEST_MAPPING\n\nTest: None'])
|
||||||
|
if changed and args.push_change:
|
||||||
|
date = datetime.today().strftime('%m-%d')
|
||||||
|
subprocess.check_output(['git', 'push', 'aosp', 'HEAD:refs/for/master',
|
||||||
|
'-o', 'topic=test-mapping-%s' % date])
|
||||||
|
except (UpdaterException, subprocess.CalledProcessError) as err:
|
||||||
sys.exit("Error: " + str(err))
|
sys.exit("Error: " + str(err))
|
||||||
test_mapping.create()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user