[Patch v6 01/14] test: add utility function to sort a json list

David Bremner david at tethera.net
Tue Mar 11 16:01:27 PDT 2014


So far we only need this one place, but it's a bit messy to inline
---
 test/test-lib.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 66edb7c..9824bb6 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -622,6 +622,12 @@ test_expect_equal_json () {
     test_expect_equal "$output" "$expected" "$@"
 }
 
+# Sort the top-level list of JSON data from stdin.
+test_sort_json () {
+    PYTHONIOENCODING=utf-8 python -c \
+        "import sys, json; json.dump(sorted(json.load(sys.stdin)),sys.stdout)"
+}
+
 test_emacs_expect_t () {
 	test "$#" = 2 && { prereq=$1; shift; } || prereq=
 	test "$#" = 1 ||
-- 
1.8.5.3



More information about the notmuch mailing list