diff --git a/regression-tests/rm-empty-files.bat b/regression-tests/rm-empty-files.bat new file mode 100644 index 000000000..a8752b81c --- /dev/null +++ b/regression-tests/rm-empty-files.bat @@ -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 diff --git a/regression-tests/rm-empty-files.sh b/regression-tests/rm-empty-files.sh new file mode 100644 index 000000000..b808151f8 --- /dev/null +++ b/regression-tests/rm-empty-files.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +find . -type f -exec bash -c "[ ! -s \"{}\" ] && rm \"{}\"" \; diff --git a/regression-tests/run-tests.sh b/regression-tests/run-tests.sh index fa630c561..b4cfc8787 100644 --- a/regression-tests/run-tests.sh +++ b/regression-tests/run-tests.sh @@ -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 @@ -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 }