From f2e0ffc765e7da111034ac64499480e000de115e Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Thu, 21 Dec 2023 12:08:42 -0800 Subject: [PATCH] [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 0733499c319f45b0fa75350aef5959a668c46a1e PiperOrigin-RevId: 592920747 --- tools/run_tests/sanity/check_bazel_workspace.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index bf3358e19e8..9e6e436f112 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -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.