From 488e91f42b95c116b387212c90ea47c43c716f5b Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Tue, 28 Apr 2020 14:57:20 -0400 Subject: [PATCH] test-lib.sh: add test_valid_json This test does exactly what it says on the tin. It expects JSON data to be parseable by Python, at least. Signed-off-by: Daniel Kahn Gillmor --- test/test-lib.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test-lib.sh b/test/test-lib.sh index cb5bb894..43fffa09 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -524,6 +524,12 @@ test_expect_equal_json () { test_expect_equal "$output" "$expected" "$@" } +# Ensure that the argument is valid JSON data. +test_valid_json () { + PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -c "import sys, json; json.load(sys.stdin)" <<<"$1" + test_expect_equal "$?" 0 +} + # Sort the top-level list of JSON data from stdin. test_sort_json () { PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -c \ -- 2.43.0