diff --git a/scripts/test.sh b/scripts/test.sh index 120dcece4282..580c69573b88 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -543,11 +543,22 @@ function bom_pass { ######## VARIOUS CHECKERS ###################################################### function dump_deps_of_module() { - local module - if ! module=$(go mod edit -json | jq -r '.Module.Path'); then - return 255 - fi - run go mod edit -json | jq -r '.Require[] | .Path+","+.Version+","+if .Indirect then " (indirect)" else "" end+",'"${module}"'"' + local modules=("$@") + local deps=() + for module in "${modules[@]}"; do + local module_file + local module_name + local module_deps + module_file="${module/.../go.mod}" + if ! module_name=$(go mod edit -json "$module_file" | jq -r '.Module.Path'); then + return 255 + fi + mapfile -t module_deps < <(go mod edit -json "$module_file" | jq -r '.Require[] | .Path+","+.Version+","+if .Indirect then " (indirect)" else "" end+",'"${module_name}"'"') +go mod edit -json "$module_file" | jq -r '.Require[] | .Path+","+.Version+","+if .Indirect then " (indirect)" else "" end+",'"${module_name}"'"' >> depsl.txt + echo "${module_deps[@]}" > deps.txt + deps+=("${module_deps[@]}") + done + echo "${deps[@]}" } # Checks whether dependencies are consistent across modules @@ -555,6 +566,7 @@ function dep_pass { local all_dependencies local tools_mod_dependencies all_dependencies=$(run_for_modules dump_deps_of_module) || return 2 + echo $all_dependencies > depsall.txt # tools/mod is a special case. It is a module that is not included in the # module list from test_lib.sh. However, we need to ensure that the # dependency versions match the rest of the project. Therefore, explicitly