From 79a51e9afcb71231ae2882c7ccbe1ddf3eede623 Mon Sep 17 00:00:00 2001 From: Bala FA Date: Tue, 24 Oct 2017 12:21:25 -0700 Subject: [PATCH] fix JSON format error in functional test (#2294) Previously `error` field is not populated properly due to double formatting error message into JSON string. This patch fixes the issue by avoid second time formatting in `printf` command. --- functional-tests.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functional-tests.sh b/functional-tests.sh index 40e00195..5be16a79 100755 --- a/functional-tests.sh +++ b/functional-tests.sh @@ -149,8 +149,9 @@ function assert() rv=$? if [ "$rv" -ne "$expected_rv" ]; then if [ -n "$MINT_MODE" ]; then - err=$(python -c 'import sys,json; print(json.dumps(sys.stdin.read()))' <<<"$err") - printf '{"name": "mc", "duration": "%d", "function": "%s", "status": "FAIL", "error": "%s"}\n' "$(get_duration "$start_time")" "$func_name" "$err" + err=$(printf "$err" | python -c 'import sys,json; print(json.dumps(sys.stdin.read()))') + ## err is already JSON string, no need to double quote + printf '{"name": "mc", "duration": "%d", "function": "%s", "status": "FAIL", "error": %s}\n' "$(get_duration "$start_time")" "$func_name" "$err" else echo "mc: $func_name: $err" fi