Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't follow symlinks when deleting test outputs #19948

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions tools/test/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,16 @@ fi

# Zip up undeclared outputs.
if [[ -n "$TEST_UNDECLARED_OUTPUTS_ZIP" ]] && cd "$TEST_UNDECLARED_OUTPUTS_DIR"; then
shopt -s dotglob
if [[ "$(echo *)" != "*" ]]; then
# If * found nothing, echo printed the literal *.
# Otherwise echo printed the top-level files and directories.
# Pass files to zip with *, so paths with spaces aren't broken up.
# Remove original files after zipping them.
if ! zip_output="$(zip -qrm "$TEST_UNDECLARED_OUTPUTS_ZIP" -- * 2>&1)"; then
shopt -s dotglob nullglob
# Capture the contents of TEST_UNDECLARED_OUTPUTS_DIR prior to creating the output.zip
UNDECLARED_OUTPUTS=(*)
if [[ "${#UNDECLARED_OUTPUTS[@]}" != 0 ]]; then
if ! zip_output="$(zip -qr "$TEST_UNDECLARED_OUTPUTS_ZIP" -- "${UNDECLARED_OUTPUTS[@]}")" ; then
echo >&2 "Could not create \"$TEST_UNDECLARED_OUTPUTS_ZIP\": $zip_output"
fi
# Use 'rm' instead of 'zip -m' so that we don't follow symlinks when deleting the
# contents.
rm -r "${UNDECLARED_OUTPUTS[@]}"
fi
fi

Expand Down
Loading