# HG changeset patch # User Lucas Thompson # Date 1485903709 0 # Node ID 353f842ed73fcc4a7d0fa5577cebed22b1d9bb65 # Parent 1990dd9570d8804a35c04b5a2f628e368ab6a277 Add a more relaxed comparision of JSON responses if the initial comparision fails. Some optional fields aren't populated from the JSON serialisation code. diff -r 1990dd9570d8 -r 353f842ed73f vamp-server/test.sh --- a/vamp-server/test.sh Tue Jan 31 22:58:38 2017 +0000 +++ b/vamp-server/test.sh Tue Jan 31 23:01:49 2017 +0000 @@ -27,6 +27,7 @@ allrespfile="$tmpdir/resp.all" input="$tmpdir/input" expected="$tmpdir/expected" +expected_less_strict="$tmpdir/obtained-less-strict" obtained="$tmpdir/obtained" validate() { @@ -82,9 +83,10 @@ {"error": {"code": 0, "message": "error in finish request: unknown plugin handle supplied to finish"}, "id": "blah", "jsonrpc": "2.0", "method": "finish"} EOF -# We run the whole test twice, once with the server in Capnp mode -# (converting to JSON using piper-convert) and once with it directly -# in JSON mode +# We run the whole test three times, +# to cover (de)serialisation of json and capnp requests and responses +# as well as exercising both server modes (json and capnp) +# converting / reading from capnp requests is currently not tested #debugflag=-d debugflag= @@ -120,10 +122,16 @@ tail -n +4 "$allrespfile" > "$obtained" echo "Checking response contents against expected contents..." - if ! cmp "$obtained" "$expected"; then - diff -U 1 "$obtained" "$expected" + + # the expected configuration response is fragile, capnp fills in optional fields, + # json doesn't - which is fine behaviour, but causes the test to fail - remove empty binCount and binNames + expected_without_optional_fields=$( cat "$expected" | sed -E 's/\"(binCount|binNames)\": ?((\[\])|0),? ?//g') + echo "$expected_without_optional_fields" > "$expected_less_strict" + + if cmp "$obtained" "$expected" -s || cmp "$obtained" "$expected_less_strict" -s; then + echo "OK" else - echo "OK" + diff -U 1 "$obtained" "$expected" fi echo "Checking plugin counts from list responses..."