Compare commits

...

4 Commits

Author SHA1 Message Date
Eric Eastwood
c75fb2eeb6 Add changelog 2025-11-20 17:36:21 -06:00
Eric Eastwood
ad94b9103e Use consistent indentation 2025-11-20 17:31:42 -06:00
Eric Eastwood
588c2b4db9 Use return instead of exit
This is useful so that the script can be sourced without exiting the calling subshell.
2025-11-20 17:29:07 -06:00
Eric Eastwood
573accd0df Run complement.sh logic as function
This is useful as later we can refactor the early `exit` calls to `return` calls
so that the script can be sourced without exiting the calling subshell.
2025-11-20 17:25:50 -06:00
2 changed files with 179 additions and 168 deletions

1
changelog.d/19209.misc Normal file
View File

@@ -0,0 +1 @@
Refactor `scripts-dev/complement.sh` logic to avoid `exit` to facilitate being able to source it from other scripts (composable).

View File

@@ -72,6 +72,7 @@ For help on arguments to 'go test', run 'go help testflag'.
EOF EOF
} }
main() {
# parse our arguments # parse our arguments
skip_docker_build="" skip_docker_build=""
skip_complement_run="" skip_complement_run=""
@@ -80,7 +81,7 @@ while [ $# -ge 1 ]; do
case "$arg" in case "$arg" in
"-h") "-h")
usage usage
exit 1 return 1
;; ;;
"-f"|"--fast") "-f"|"--fast")
skip_docker_build=1 skip_docker_build=1
@@ -207,7 +208,7 @@ fi
if [ -n "$skip_complement_run" ]; then if [ -n "$skip_complement_run" ]; then
echo "Skipping Complement run as requested." echo "Skipping Complement run as requested."
exit return 0
fi fi
export COMPLEMENT_BASE_IMAGE=complement-synapse export COMPLEMENT_BASE_IMAGE=complement-synapse
@@ -299,3 +300,12 @@ echo "Images built; running complement with ${extra_test_args[@]} $@ ${test_pack
cd "$COMPLEMENT_DIR" cd "$COMPLEMENT_DIR"
go test -v -tags "synapse_blacklist" -count=1 "${extra_test_args[@]}" "$@" "${test_packages[@]}" go test -v -tags "synapse_blacklist" -count=1 "${extra_test_args[@]}" "$@" "${test_packages[@]}"
}
main "$@"
# For any non-zero exit code (indicating some sort of error happened), we want to exit
# with that code.
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi