[Tool] Better error message for check_bazel_workspace.py (#35375)

Simple `assert` statements don't help much to know what needs to be done. Instead, explicit error messages will let us know what's wrong which is helpful to know what to look at.

Closes #35375

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35375 from veblush:check-work 0733499c31
PiperOrigin-RevId: 592920747
This commit is contained in:
Esun Kim 2023-12-21 12:08:42 -08:00 committed by Copybara-Service
parent 2a6be96366
commit f2e0ffc765
1 changed files with 7 additions and 3 deletions

View File

@ -172,9 +172,13 @@ build_rules = {
"Label": lambda a: None,
}
exec((bazel_file), build_rules)
for name in _GRPC_DEP_NAMES:
assert name in list(names_and_urls.keys())
assert len(_GRPC_DEP_NAMES) == len(list(names_and_urls.keys()))
grpc_dep_names_set = set(_GRPC_DEP_NAMES)
names_set = set(names_and_urls.keys())
if grpc_dep_names_set != names_set:
print("Differences detected between GRPC_DEP_NAMES and grpc_deps.bzl")
print("- GRPC_DEP_NAMES only:", grpc_dep_names_set - names_set)
print("- grpc_deps.bzl only:", names_set - grpc_dep_names_set)
sys.exit(1)
# There are some "bazel-only" deps that are exceptions to this sanity check,
# we don't require that there is a corresponding git module for these.