Skip to content

Commit

Permalink
Update run_for_modules, drop change directory
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Valdes <[email protected]>
  • Loading branch information
ivanvc committed Aug 7, 2024
1 parent f0993c0 commit 491a287
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions scripts/test_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,17 @@ function modules() {
echo "${modules[@]}"
}

function workspace_modules() {
local modules
mapfile -t modules < <(go work edit -json | jq -r '.Use[].DiskPath + "/..."')
for m in "${modules[@]}"; do
if [[ "$m" =~ ^\./tools ]]; then
modules=("${modules[@]/$m}")
fi
done
echo "${modules[@]}"
}

function modules_exp() {
for m in $(modules); do
echo -n "${m}/... "
Expand All @@ -208,23 +219,9 @@ function modules_exp() {
function run_for_modules {
KEEP_GOING_MODULE=${KEEP_GOING_MODULE:-false}
local pkg="${PKG:-./...}"
local fail_mod=false
if [ -z "${USERMOD:-}" ]; then
for m in $(module_dirs); do
if run_for_module "${m}" "$@" "${pkg}"; then
continue
else
if [ "$KEEP_GOING_MODULE" = false ]; then
log_error "There was a Failure in module ${m}, aborting..."
return 1
fi
log_error "There was a Failure in module ${m}, keep going..."
fail_mod=true
fi
done
if [ "$fail_mod" = true ]; then
return 1
fi
# shellcheck disable=SC2046
"$@" $(workspace_modules)
else
run_for_module "${USERMOD}" "$@" "${pkg}" || return "$?"
fi
Expand Down

0 comments on commit 491a287

Please sign in to comment.