bazel-lib/e2e/smoke/test_preserve_mtime.sh

31 lines
753 B
Bash
Raw Normal View History

#!/usr/bin/env bash
set -euo pipefail
function main {
2024-08-14 18:27:58 +00:00
compareMTimes d/1 copy_to_directory_mtime_out/d/1
compareMTimes d/1 copy_directory_mtime_out/1
}
function compareMTimes {
2024-08-14 18:27:58 +00:00
local originalFile="$1"
local copiedFile="$2"
2024-08-14 18:27:58 +00:00
local mtimeOriginal
mtimeOriginal="$(stat --dereference --format=%y "$originalFile")"
2024-08-14 18:27:58 +00:00
local mtimeCopy
mtimeCopy="$(stat --dereference --format=%y "$copiedFile")"
2024-08-14 18:27:58 +00:00
if [[ "$mtimeOriginal" != "$mtimeCopy" ]]; then
echo "Preserve mtime test failed. Modify times do not match for $originalFile and $copiedFile"
echo " Original modify time: $mtimeOriginal"
echo " Copied modify time: $mtimeCopy"
return 1
fi
2024-08-14 18:27:58 +00:00
echo "Preserve mtime test passed for $originalFile and $copiedFile"
}
main "$@"