Skip to content

Commit c69bdf5

Browse files
committed
CI Update run-tests.sh to handle non-existent files as empty
1 parent 15f9be1 commit c69bdf5

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

regression-tests/rm-empty-files.bat

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@echo off
2+
setlocal enabledelayedexpansion
3+
4+
:: Loop through all files in the current directory and subdirectories
5+
for /r %%f in (*) do (
6+
:: Check if the file size is 0 bytes
7+
if %%~zf==0 (
8+
:: Remove the empty file
9+
del "%%f"
10+
)
11+
)
12+
13+
endlocal

regression-tests/rm-empty-files.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
find . -type f -exec bash -c "[ ! -s \"{}\" ] && rm \"{}\"" \;

regression-tests/run-tests.sh

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,21 @@ check_file () {
5555
patch_file="${label}-${cxx_compiler}-${cxx_std}-${cxx_stdlib}.patch"
5656

5757
if [[ $untracked -eq 1 ]]; then
58-
# Add the file to the index to be able to diff it...
59-
git add "$file"
60-
# ... report the diff ...
61-
report_diff "$file" \
62-
"The $description is not tracked by git" \
63-
"$patch_file" \
64-
"HEAD"
65-
# ... and remove the file from the index
66-
git rm --cached -- "$file" > /dev/null 2>&1
58+
# Untraced files are expected to be empty - report if they are not
59+
if [[ -s ""$file"" ]]; then
60+
# Add the file to the index to be able to diff it...
61+
git add "$file"
62+
# ... report the diff ...
63+
report_diff "$file" \
64+
"The $description is not tracked by git, it is expected to be empty" \
65+
"$patch_file" \
66+
"HEAD"
67+
# ... and remove the file from the index
68+
git rm --cached -- "$file" > /dev/null 2>&1
69+
else
70+
# The file is empty as expected - it can be removed
71+
rm "$file"
72+
fi
6773
else
6874
# Compare the content with the reference value checked in git
6975
# Lines includng Windows paths are excluded from diff
@@ -73,6 +79,13 @@ check_file () {
7379
"Non-matching $description" \
7480
"$patch_file" \
7581
--ignore-cr-at-eol
82+
83+
# If the file is tracked an empty report an error
84+
if [[ $failure != 1 && ! -s "$file" ]]; then
85+
echo " Empty tracked file:"
86+
echo " $file"
87+
failure=1
88+
fi
7689
fi
7790
}
7891

0 commit comments

Comments
 (0)