2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-11-27 17:43:27 +00:00
bazel-lib/e2e/smoke/test_preserve_mtime.sh
2024-08-14 11:27:58 -07:00

31 lines
753 B
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
function main {
compareMTimes d/1 copy_to_directory_mtime_out/d/1
compareMTimes d/1 copy_directory_mtime_out/1
}
function compareMTimes {
local originalFile="$1"
local copiedFile="$2"
local mtimeOriginal
mtimeOriginal="$(stat --dereference --format=%y "$originalFile")"
local mtimeCopy
mtimeCopy="$(stat --dereference --format=%y "$copiedFile")"
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
echo "Preserve mtime test passed for $originalFile and $copiedFile"
}
main "$@"