Skip to content

Commit

Permalink
CI Update run-tests.sh to handle non-existent files as empty
Browse files Browse the repository at this point in the history
  • Loading branch information
jarzec committed Jul 22, 2024
1 parent 15f9be1 commit c69bdf5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
13 changes: 13 additions & 0 deletions regression-tests/rm-empty-files.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@echo off
setlocal enabledelayedexpansion

:: Loop through all files in the current directory and subdirectories
for /r %%f in (*) do (
:: Check if the file size is 0 bytes
if %%~zf==0 (
:: Remove the empty file
del "%%f"
)
)

endlocal
3 changes: 3 additions & 0 deletions regression-tests/rm-empty-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

find . -type f -exec bash -c "[ ! -s \"{}\" ] && rm \"{}\"" \;
31 changes: 22 additions & 9 deletions regression-tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,21 @@ check_file () {
patch_file="${label}-${cxx_compiler}-${cxx_std}-${cxx_stdlib}.patch"

if [[ $untracked -eq 1 ]]; then
# Add the file to the index to be able to diff it...
git add "$file"
# ... report the diff ...
report_diff "$file" \
"The $description is not tracked by git" \
"$patch_file" \
"HEAD"
# ... and remove the file from the index
git rm --cached -- "$file" > /dev/null 2>&1
# Untraced files are expected to be empty - report if they are not
if [[ -s ""$file"" ]]; then
# Add the file to the index to be able to diff it...
git add "$file"
# ... report the diff ...
report_diff "$file" \
"The $description is not tracked by git, it is expected to be empty" \
"$patch_file" \
"HEAD"
# ... and remove the file from the index
git rm --cached -- "$file" > /dev/null 2>&1
else
# The file is empty as expected - it can be removed
rm "$file"
fi
else
# Compare the content with the reference value checked in git
# Lines includng Windows paths are excluded from diff
Expand All @@ -73,6 +79,13 @@ check_file () {
"Non-matching $description" \
"$patch_file" \
--ignore-cr-at-eol

# If the file is tracked an empty report an error
if [[ $failure != 1 && ! -s "$file" ]]; then
echo " Empty tracked file:"
echo " $file"
failure=1
fi
fi
}

Expand Down

0 comments on commit c69bdf5

Please sign in to comment.