Loading tools/auto_gen_test_config.py +24 −15 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ """A tool to generate TradeFed test config file. """A tool to generate TradeFed test config file. """ """ import argparse import re import re import os import os import shutil import shutil Loading @@ -43,20 +44,28 @@ def main(argv): Returns: Returns: 0 if no error, otherwise 1. 0 if no error, otherwise 1. """ """ if len(argv) != 4 and len(argv) != 6: sys.stderr.write( parser = argparse.ArgumentParser() f'Invalid arguments: {argv}. The script requires 4 arguments for file paths: ' parser.add_argument( 'target_config, android_manifest (or the xmltree dump), empty_config, ' "target_config", 'instrumentation_test_config_template, ' help="Path to the generated output config.") 'and 2 optional arguments for extra configs: ' parser.add_argument( '--extra-configs \'EXTRA_CONFIGS\'.\n') "android_manifest", return 1 help="Path to AndroidManifest.xml or output of 'aapt2 dump xmltree' with .xmltree extension.") parser.add_argument( target_config = argv[0] "empty_config", android_manifest = argv[1] help="Path to the empty config template.") empty_config = argv[2] parser.add_argument( instrumentation_test_config_template = argv[3] "instrumentation_test_config_template", extra_configs = '\n'.join(argv[5].split('\\n')) if len(argv) == 6 else '' help="Path to the instrumentation test config template.") parser.add_argument("--extra-configs", default="") args = parser.parse_args(argv) target_config = args.target_config android_manifest = args.android_manifest empty_config = args.empty_config instrumentation_test_config_template = args.instrumentation_test_config_template extra_configs = '\n'.join(args.extra_configs.split('\\n')) module = os.path.splitext(os.path.basename(target_config))[0] module = os.path.splitext(os.path.basename(target_config))[0] Loading @@ -70,7 +79,7 @@ def main(argv): # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern = re.compile(r"\(Raw:\s\"(.*)\"\)$") pattern = re.compile(r"\(Raw:\s\"(.*)\"\)$") curr_element = None curr_element = None for line in manifest.readlines(): for line in manifest: curr_line = line.strip() curr_line = line.strip() if curr_line.startswith("E:"): if curr_line.startswith("E:"): # e.g. "E: instrumentation (line=9)" # e.g. "E: instrumentation (line=9)" Loading Loading
tools/auto_gen_test_config.py +24 −15 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ """A tool to generate TradeFed test config file. """A tool to generate TradeFed test config file. """ """ import argparse import re import re import os import os import shutil import shutil Loading @@ -43,20 +44,28 @@ def main(argv): Returns: Returns: 0 if no error, otherwise 1. 0 if no error, otherwise 1. """ """ if len(argv) != 4 and len(argv) != 6: sys.stderr.write( parser = argparse.ArgumentParser() f'Invalid arguments: {argv}. The script requires 4 arguments for file paths: ' parser.add_argument( 'target_config, android_manifest (or the xmltree dump), empty_config, ' "target_config", 'instrumentation_test_config_template, ' help="Path to the generated output config.") 'and 2 optional arguments for extra configs: ' parser.add_argument( '--extra-configs \'EXTRA_CONFIGS\'.\n') "android_manifest", return 1 help="Path to AndroidManifest.xml or output of 'aapt2 dump xmltree' with .xmltree extension.") parser.add_argument( target_config = argv[0] "empty_config", android_manifest = argv[1] help="Path to the empty config template.") empty_config = argv[2] parser.add_argument( instrumentation_test_config_template = argv[3] "instrumentation_test_config_template", extra_configs = '\n'.join(argv[5].split('\\n')) if len(argv) == 6 else '' help="Path to the instrumentation test config template.") parser.add_argument("--extra-configs", default="") args = parser.parse_args(argv) target_config = args.target_config android_manifest = args.android_manifest empty_config = args.empty_config instrumentation_test_config_template = args.instrumentation_test_config_template extra_configs = '\n'.join(args.extra_configs.split('\\n')) module = os.path.splitext(os.path.basename(target_config))[0] module = os.path.splitext(os.path.basename(target_config))[0] Loading @@ -70,7 +79,7 @@ def main(argv): # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern = re.compile(r"\(Raw:\s\"(.*)\"\)$") pattern = re.compile(r"\(Raw:\s\"(.*)\"\)$") curr_element = None curr_element = None for line in manifest.readlines(): for line in manifest: curr_line = line.strip() curr_line = line.strip() if curr_line.startswith("E:"): if curr_line.startswith("E:"): # e.g. "E: instrumentation (line=9)" # e.g. "E: instrumentation (line=9)" Loading