Skip to content

CI Remove empty test reference files #1164

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

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Loading
Loading