Skip to content

Commit 47c9f77

Browse files
committed
Modified code to delete all types of files which have not failed
Minor extension handling Checking if file exists before deleting
1 parent b1faf0d commit 47c9f77

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

.github/workflows/tests.yml

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -320,32 +320,35 @@ jobs:
320320
321321
- name: Cleanup non-failed image files
322322
run: |
323-
# Handle -expected.png files
324-
find ./result_images -type f -name "*-expected.png" | while read file; do
325-
dir=$(dirname "$file")
326-
if [[ $dir == *"test_compare_images"* ]]; then
327-
continue
328-
fi
329-
base=${file%-expected.png}
330-
echo "${base}-failed-diff.png"
331-
if [[ ! -e "${base}-failed-diff.png" ]]; then
332-
rm "$file"
333-
fi
334-
done
323+
function remove_files() {
324+
local extension=$1
325+
find ./result_images -type f -name "*-expected*.$extension" | while read file; do
326+
if [[ $file == *"-expected_pdf"* ]]; then
327+
base=${file%-expected_pdf.$extension}_pdf
328+
elif [[ $file == *"-expected_eps"* ]]; then
329+
base=${file%-expected_eps.$extension}_eps
330+
elif [[ $file == *"-expected_svg"* ]]; then
331+
base=${file%-expected_svg.$extension}_svg
332+
else
333+
base=${file%-expected.$extension}
334+
fi
335+
if [[ ! -e "${base}-failed-diff.$extension" ]]; then
336+
if [[ -e "$file" ]]; then
337+
rm "$file"
338+
echo "Removed $file"
339+
fi
340+
if [[ -e "${base}.$extension" ]]; then
341+
rm "${base}.$extension"
342+
fi
343+
echo "Removed $file"
344+
fi
345+
done
346+
}
335347
336-
# Handle .png files, excluding those ending with -failed-diff.png and -expected.png
337-
find ./result_images -type f -name "*.png" ! -name "*-failed-diff.png" ! -name "*-expected.png" \
338-
| while read file; do
339-
dir=$(dirname "$file")
340-
if [[ $dir == *"test_compare_images"* ]]; then
341-
continue
342-
fi
343-
base=${file%.png}
344-
echo "${base}-failed-diff.png"
345-
if [[ ! -e "${base}-failed-diff.png" ]]; then
346-
rm "$file"
347-
fi
348-
done
348+
remove_files "png"; remove_files "svg"; remove_files "pdf"; remove_files "eps";
349+
350+
find "./result_images"/* -type d -empty -delete
351+
echo "Removed empty directories under result_images."
349352
350353
- name: Filter C coverage
351354
run: |

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