#!/bin/bash # With this script, we create a timestamps file for two files, delete one, and test whether the change is detected. # setup mkdir -p a rm -f a/.file-timestamps echo file1 > a/file1 echo file2 > a/file2 # Create the initial timestamp file. This is not really what we're trying to scrutinize with this test. if ! output=$(../../../file-timestamps --generate a) then echo "$0: file-timestamps failed" 1>&2 echo "$output" 1>&2 exit 1 fi case "$output" in equal) # Good; there was no preexisting timestamps file, so this should be equal ;; unequal) echo "Bad: there was no preexisting timestamps file, so this should have been equal" 1>&2 exit 1 ;; *) echo "Bad: strange output found:" 1>&2 echo "$output" 1>&2 exit 1 ;; esac # Remove the file rm -f a/file2 if ! output=$(../../../file-timestamps --generate a) then echo "$0: file-timestamps failed" 1>&2 echo "$output" 1>&2 exit 1 fi case "$output" in unequal) # Good; the change was detected. exit 0 ;; equal) echo "Bad: change not detected" 1>&2 exit 1 ;; *) echo "Bad: strange output found:" 1>&2 echo "$output" 1>&2 exit 1 ;; esac