diff --git a/tests/scripts/check-generated-files.sh b/tests/scripts/check-generated-files.sh index 5e35be8f9..75730ba25 100755 --- a/tests/scripts/check-generated-files.sh +++ b/tests/scripts/check-generated-files.sh @@ -65,24 +65,25 @@ check() fi for FILE in "$@"; do - cp "$FILE" "$FILE.bak" + cp -p "$FILE" "$FILE.bak" done "$SCRIPT" # Compare the script output to the old files and remove backups for FILE in "$@"; do - if ! diff "$FILE" "$FILE.bak" >/dev/null 2>&1; then + if diff "$FILE" "$FILE.bak" >/dev/null 2>&1; then + # Move the original file back so that $FILE's timestamp doesn't + # change (avoids spurious rebuilds with make). + mv "$FILE.bak" "$FILE" + else echo "'$FILE' was either modified or deleted by '$SCRIPT'" if [ -z "$UPDATE" ]; then exit 1 + else + rm "$FILE.bak" fi fi - if [ -z "$UPDATE" ]; then - mv "$FILE.bak" "$FILE" - else - rm "$FILE.bak" - fi done if [ -n "$directory" ]; then