diff options
author | 2017-12-12 17:19:18 -0800 | |
---|---|---|
committer | 2017-12-12 17:19:18 -0800 | |
commit | 438f219701a0d4e41060142a5a5db0d828eeeb3f (patch) | |
tree | f3d876edec2c08a53f242143763bc39ab72ca3a2 /tools/run_tests/sanity/check_bazel_workspace.py | |
parent | 69e8ab400dadb2843e9a1927cf579bdec94d729b (diff) | |
parent | c47c58971bfd838843befed66430e87b77eab4fb (diff) |
Merge pull request #13719 from ncteisen/yapf-tools
Yapf tools/
Diffstat (limited to 'tools/run_tests/sanity/check_bazel_workspace.py')
-rwxr-xr-x | tools/run_tests/sanity/check_bazel_workspace.py | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index 776c78b03f..b5a77f4479 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -27,23 +27,37 @@ os.chdir(os.path.join(os.path.dirname(sys.argv[0]), '../../..')) git_hash_pattern = re.compile('[0-9a-f]{40}') # Parse git hashes from submodules -git_submodules = subprocess.check_output('git submodule', shell=True).strip().split('\n') -git_submodule_hashes = {re.search(git_hash_pattern, s).group() for s in git_submodules} +git_submodules = subprocess.check_output( + 'git submodule', shell=True).strip().split('\n') +git_submodule_hashes = { + re.search(git_hash_pattern, s).group() + for s in git_submodules +} # Parse git hashes from Bazel WORKSPACE {new_}http_archive rules with open('WORKSPACE', 'r') as f: - workspace_rules = [expr.value for expr in ast.parse(f.read()).body] - -http_archive_rules = [rule for rule in workspace_rules if rule.func.id.endswith('http_archive')] -archive_urls = [kw.value.s for rule in http_archive_rules for kw in rule.keywords if kw.arg == 'url'] -workspace_git_hashes = {re.search(git_hash_pattern, url).group() for url in archive_urls} + workspace_rules = [expr.value for expr in ast.parse(f.read()).body] + +http_archive_rules = [ + rule for rule in workspace_rules if rule.func.id.endswith('http_archive') +] +archive_urls = [ + kw.value.s for rule in http_archive_rules for kw in rule.keywords + if kw.arg == 'url' +] +workspace_git_hashes = { + re.search(git_hash_pattern, url).group() + for url in archive_urls +} # Validate the equivalence of the git submodules and Bazel git dependencies. The # condition we impose is that there is a git submodule for every dependency in # the workspace, but not necessarily conversely. E.g. Bloaty is a dependency # not used by any of the targets built by Bazel. if len(workspace_git_hashes - git_submodule_hashes) > 0: - print("Found discrepancies between git submodules and Bazel WORKSPACE dependencies") + print( + "Found discrepancies between git submodules and Bazel WORKSPACE dependencies" + ) sys.exit(1) sys.exit(0) |