Add function to test if a file exists.
authorAdam Sampson <ats@offog.org>
Thu, 11 Jul 2013 13:21:54 +0000 (13:21 +0000)
committerAdam Sampson <ats@offog.org>
Thu, 11 Jul 2013 13:21:54 +0000 (13:21 +0000)
test-rawdog

index 45c196a36c10d132f39655d6203ab00cc6b775ce..972bd4acd60406fe50d1e8dc4979f21d955de608 100644 (file)
@@ -75,7 +75,16 @@ equals () {
        fi
 }
 
+exists () {
+       for fn in "$@"; do
+               if ! [ -e "$fn" ]; then
+                       die "expected $fn to exist"
+               fi
+       done
+}
+
 same () {
+       exists "$1" "$2"
        if ! cmp "$1" "$2"; then
                die "expected $1 to have the same contents as $2"
        fi
@@ -83,6 +92,7 @@ same () {
 
 contains () {
        file="$1"
+       exists "$file"
        shift
        for key in "$@"; do
                if ! grep -q "$key" "$file"; then
@@ -94,6 +104,7 @@ contains () {
 
 not_contains () {
        file="$1"
+       exists "$file"
        shift
        for key in "$@"; do
                if grep -q "$key" "$file"; then