Allow passing globs to update_crate_tests.py.

This makes it easier to run it on multiple directories.

Test: Call with various globs.
Change-Id: I0564369e4e8b9d62482fb2162a16d0e588f94e57
This commit is contained in:
Joel Galenson
2021-08-20 11:39:48 -07:00
parent 097e8c0a15
commit 08352445c8

View File

@@ -27,11 +27,14 @@ 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 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,11 +248,23 @@ 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.')
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: