From: Adam Sampson Date: Thu, 11 Jul 2013 13:21:54 +0000 (+0000) Subject: Add function to test if a file exists. X-Git-Tag: v2.15rc2~3 X-Git-Url: http://git.ozo.com/?a=commitdiff_plain;h=d2cfea10e54345a76bf1605960cb0173357cc836;p=rawdog%2F.git Add function to test if a file exists. --- diff --git a/test-rawdog b/test-rawdog index 45c196a..972bd4a 100644 --- a/test-rawdog +++ b/test-rawdog @@ -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