Permalink
Browse files

verbose output is better in tests. http://en.wikipedia.org/wiki/Test_…

…Anything_Protocol

removed set -e, seemed to be problematic
  • Loading branch information...
1 parent 8a31d41 commit 866dab9d77cdf772f392814e33b5b94e04707b70 @dominictarr dominictarr committed Oct 26, 2011
Showing with 39 additions and 10 deletions.
  1. +11 −1 test/invalid-test.sh
  2. +13 −2 test/parse-test.sh
  3. +7 −4 test/tokenizer-test.sh
  4. +8 −3 test/valid-test.sh
View
@@ -2,16 +2,26 @@
cd ${0%/*}
+# make test output TAP compatible
+# http://en.wikipedia.org/wiki/Test_Anything_Protocol
+
fails=0
+tests=`ls invalid/* -1l | wc -l`
+echo "1..$tests"
for input in invalid/*
do
+ let i+=1
if ../bin/json_parse < "$input" > outlog 2> errlog
then
- echo "NOT OK: cat $input | ../bin/json_parse SHOULD FAIL"
+ echo "not ok $i - cat $input | ../bin/json_parse should fail"
+ #this should be indented with '#' at the start.
echo "OUTPUT WAS >>>"
cat outlog
echo "<<<"
let fails=$fails+1
+ else
+ echo "ok $i - $input was rejected"
+
fi
done
echo "$fails test(s) failed"
View
@@ -9,15 +9,26 @@ ptest () {
}
fails=0
+i=0
+echo "1..4"
for input in '"oooo" ' '[true, 1, [0, {}]] ' '{"true": 1}'
do
- echo "$input" | ptest || let fails=$fails+1
+ let i++
+ if echo "$input" | ptest
+ then
+ echo "ok $i - $input"
+ else
+ echo "not ok $i - $input"
+ let fails=$fails+1
+ fi
done
if ! ptest < ../package.json
then
- echo "Parsing package.json failed!"
+ echo "not ok 4 - Parsing package.json failed!"
let fails=$fails+1
+else
+ echo "ok $i - package.json"
fi
echo "$fails test(s) failed"
View
@@ -1,20 +1,23 @@
#! /usr/bin/env bash
cd ${0%/*}
-
. ../parse.sh
-set -e
+i=0
+fails=0
ttest () {
+ let i++
local input="$1"; shift
local expected="$(printf '%s\n' "$@")"
- if ! echo "$input" | tokenize |diff -u - <(echo "$expected")
+ if echo "$input" | tokenize | diff -u - <(echo "$expected")
then
+ echo "ok $i - $input"
+ else
+ echo "not ok $i - $input"
let fails=$fails+1
fi
}
-fails=0
ttest '"dah"' '"dah"'
ttest '""' '""'
ttest '["dah"]' '[' '"dah"' ']'
View
@@ -1,15 +1,20 @@
#! /usr/bin/env bash
cd ${0%/*}
-
-set -e
fails=0
+i=0
+tests=`ls valid/*.json -1l | wc -l`
+echo "1..$tests"
for input in valid/*.json
do
expected="${input%.json}.parsed"
- if ! ../bin/json_parse < "$input" | diff -u - "$expected"
+ let i++
+ if ! ../bin/json_parse < "$input" | diff -u - "$expected"
then
+ echo "not ok $i - $input"
let fails=$fails+1
+ else
+ echo "ok $i - $input"
fi
done
echo "$fails test(s) failed"

0 comments on commit 866dab9

Please sign in to comment.