Skip to content

Commit 2c7903a

Browse files
committed
Fixed logic for image deletion
1 parent 9fdca21 commit 2c7903a

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

.github/workflows/tests.yml

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -344,34 +344,29 @@ jobs:
344344
- name: Cleanup non-failed image files
345345
if: failure()
346346
run: |
347-
function remove_files() {
348-
local extension=$1
349-
find ./result_images -name "*-expected*.$extension" | while read file; do
350-
if [[ $file == *"-expected_pdf"* ]]; then
351-
base=${file%-expected_pdf.$extension}_pdf
352-
elif [[ $file == *"-expected_eps"* ]]; then
353-
base=${file%-expected_eps.$extension}_eps
354-
elif [[ $file == *"-expected_svg"* ]]; then
355-
base=${file%-expected_svg.$extension}_svg
356-
elif [[ $file == *"-expected_gif"* ]]; then
357-
base=${file%-expected_gif.$extension}_gif
358-
else
359-
base=${file%-expected.$extension}
360-
fi
361-
if [[ ! -e "${base}-failed-diff.$extension" ]]; then
362-
if [[ -e "$file" ]]; then
363-
rm "$file"
364-
echo "Removed $file"
365-
fi
366-
if [[ -e "${base}.$extension" ]]; then
367-
rm "${base}.$extension"
368-
echo " Removed ${base}.$extension"
369-
fi
370-
fi
347+
find ./result_images -name "*-expected*.png" | while read file; do
348+
if [[ $file == *-expected_???.png ]]; then
349+
extension=${file: -7:3}
350+
base=${file%*-expected_$extension.png}_$extension
351+
else
352+
extension="png"
353+
base=${file%-expected.png}
354+
fi
355+
if [[ ! -e ${base}-failed-diff.png ]]; then
356+
indent=""
357+
list=($file $base.png)
358+
if [[ $extension != "png" ]]; then
359+
list+=(${base%_$extension}-expected.$extension ${base%_$extension}.$extension)
360+
fi
361+
for to_remove in "${list[@]}"; do
362+
if [[ -e $to_remove ]]; then
363+
rm $to_remove
364+
echo "${indent}Removed $to_remove"
365+
fi
366+
indent+=" "
371367
done
372-
}
373-
374-
remove_files "png"; remove_files "svg"; remove_files "pdf"; remove_files "eps"; remove_files "gif";
368+
fi
369+
done
375370
376371
if [ "$(find ./result_images -mindepth 1 -type d)" ]; then
377372
find ./result_images/* -type d -empty -delete

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy