Re: v6 of boolean folder patches

Subject: Re: v6 of boolean folder patches

Date: Tue, 11 Mar 2014 20:10:44 -0300

To: notmuch@notmuchmail.org

Cc:

From: David Bremner


David Bremner <david@tethera.net> writes:

>
> Here's a diffstat
>
>  test/T090-search-output.sh                    | 112 +++++++++++++-------------
>  test/T530-upgrade.sh                          |  26 +++---
>  test/test-databases/Makefile.local            |   2 +-
>  test/test-databases/database-v1.tar.xz.sha256 |   1 +
>  test/test-databases/folders-v1.tar.xz.sha256  |   1 -
>  test/test-lib.sh                              |   6 ++
>  6 files changed, 77 insertions(+), 71 deletions(-)

by request, a real diff

diff --git a/test/T090-search-output.sh b/test/T090-search-output.sh
index e0bf8c1..947d572 100755
--- a/test/T090-search-output.sh
+++ b/test/T090-search-output.sh
@@ -181,67 +181,71 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "--output=files"
-notmuch search --output=files '*' | notmuch_search_files_sanitize >OUTPUT
+notmuch search --output=files '*' | notmuch_search_files_sanitize | sort >OUTPUT
 cat <<EOF >EXPECTED
-MAIL_DIR/cur/52:2,
-MAIL_DIR/cur/53:2,
-MAIL_DIR/cur/50:2,
-MAIL_DIR/cur/49:2,
-MAIL_DIR/cur/48:2,
-MAIL_DIR/cur/47:2,
-MAIL_DIR/cur/46:2,
-MAIL_DIR/cur/45:2,
-MAIL_DIR/cur/44:2,
-MAIL_DIR/cur/43:2,
-MAIL_DIR/cur/42:2,
-MAIL_DIR/cur/41:2,
-MAIL_DIR/cur/40:2,
-MAIL_DIR/cur/39:2,
-MAIL_DIR/cur/38:2,
-MAIL_DIR/cur/37:2,
-MAIL_DIR/cur/36:2,
-MAIL_DIR/cur/35:2,
-MAIL_DIR/cur/34:2,
-MAIL_DIR/cur/33:2,
-MAIL_DIR/cur/32:2,
-MAIL_DIR/cur/31:2,
-MAIL_DIR/cur/30:2,
-MAIL_DIR/cur/29:2,
-MAIL_DIR/bar/baz/new/28:2,
-MAIL_DIR/bar/baz/new/27:2,
-MAIL_DIR/bar/baz/cur/26:2,
-MAIL_DIR/bar/baz/cur/25:2,
-MAIL_DIR/bar/baz/24:2,
+MAIL_DIR/01:2,
+MAIL_DIR/02:2,
+MAIL_DIR/bar/17:2,
+MAIL_DIR/bar/18:2,
+MAIL_DIR/bar/baz/05:2,
 MAIL_DIR/bar/baz/23:2,
-MAIL_DIR/bar/new/22:2,
-MAIL_DIR/bar/new/21:2,
+MAIL_DIR/bar/baz/24:2,
+MAIL_DIR/bar/baz/cur/25:2,
+MAIL_DIR/bar/baz/cur/26:2,
+MAIL_DIR/bar/baz/new/27:2,
+MAIL_DIR/bar/baz/new/28:2,
 MAIL_DIR/bar/cur/19:2,
-MAIL_DIR/bar/18:2,
-MAIL_DIR/cur/51:2,
 MAIL_DIR/bar/cur/20:2,
-MAIL_DIR/bar/17:2,
-MAIL_DIR/foo/baz/new/16:2,
-MAIL_DIR/foo/baz/new/15:2,
-MAIL_DIR/foo/baz/cur/14:2,
-MAIL_DIR/foo/baz/cur/13:2,
-MAIL_DIR/foo/baz/12:2,
+MAIL_DIR/bar/new/21:2,
+MAIL_DIR/bar/new/22:2,
+MAIL_DIR/cur/29:2,
+MAIL_DIR/cur/30:2,
+MAIL_DIR/cur/31:2,
+MAIL_DIR/cur/32:2,
+MAIL_DIR/cur/33:2,
+MAIL_DIR/cur/34:2,
+MAIL_DIR/cur/35:2,
+MAIL_DIR/cur/36:2,
+MAIL_DIR/cur/37:2,
+MAIL_DIR/cur/38:2,
+MAIL_DIR/cur/39:2,
+MAIL_DIR/cur/40:2,
+MAIL_DIR/cur/41:2,
+MAIL_DIR/cur/42:2,
+MAIL_DIR/cur/43:2,
+MAIL_DIR/cur/44:2,
+MAIL_DIR/cur/45:2,
+MAIL_DIR/cur/46:2,
+MAIL_DIR/cur/47:2,
+MAIL_DIR/cur/48:2,
+MAIL_DIR/cur/49:2,
+MAIL_DIR/cur/50:2,
+MAIL_DIR/cur/51:2,
+MAIL_DIR/cur/52:2,
+MAIL_DIR/cur/53:2,
+MAIL_DIR/foo/06:2,
 MAIL_DIR/foo/baz/11:2,
-MAIL_DIR/foo/new/10:2,
-MAIL_DIR/foo/new/09:2,
+MAIL_DIR/foo/baz/12:2,
+MAIL_DIR/foo/baz/cur/13:2,
+MAIL_DIR/foo/baz/cur/14:2,
+MAIL_DIR/foo/baz/new/15:2,
+MAIL_DIR/foo/baz/new/16:2,
+MAIL_DIR/foo/cur/07:2,
 MAIL_DIR/foo/cur/08:2,
-MAIL_DIR/foo/06:2,
-MAIL_DIR/bar/baz/05:2,
-MAIL_DIR/new/04:2,
 MAIL_DIR/foo/new/03:2,
-MAIL_DIR/foo/cur/07:2,
-MAIL_DIR/02:2,
-MAIL_DIR/01:2,
+MAIL_DIR/foo/new/09:2,
+MAIL_DIR/foo/new/10:2,
+MAIL_DIR/new/04:2,
 EOF
 test_expect_equal_file OUTPUT EXPECTED
 
+dup1=$(notmuch search --output=files id:20091117232137.GA7669@griffis1.net | head -n 1 | sed -e "s,$MAIL_DIR,MAIL_DIR,")
+dup2=$(notmuch search --output=files id:20091117232137.GA7669@griffis1.net | tail -n 1 | sed -e "s,$MAIL_DIR,MAIL_DIR,")
+
 test_begin_subtest "--output=files --duplicate=1"
-notmuch search --output=files --duplicate=1 '*' | notmuch_search_files_sanitize >OUTPUT
-cat <<EOF >EXPECTED
+notmuch search --output=files --duplicate=1 '*' | notmuch_search_files_sanitize | sort >OUTPUT
+cat <<EOF | sort >EXPECTED
+$dup1
 MAIL_DIR/cur/52:2,
 MAIL_DIR/cur/53:2,
 MAIL_DIR/cur/50:2,
@@ -275,7 +279,6 @@ MAIL_DIR/bar/baz/23:2,
 MAIL_DIR/bar/new/22:2,
 MAIL_DIR/bar/new/21:2,
 MAIL_DIR/bar/cur/19:2,
-MAIL_DIR/bar/18:2,
 MAIL_DIR/bar/cur/20:2,
 MAIL_DIR/bar/17:2,
 MAIL_DIR/foo/baz/new/16:2,
@@ -298,8 +301,9 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "--output=files --format=json"
-notmuch search --format=json --output=files '*' | notmuch_search_files_sanitize >OUTPUT
-cat <<EOF >EXPECTED
+notmuch search --format=json --output=files '*' | notmuch_search_files_sanitize \
+    | test_sort_json >OUTPUT
+cat <<EOF | test_sort_json >EXPECTED
 ["MAIL_DIR/cur/52:2,",
 "MAIL_DIR/cur/53:2,",
 "MAIL_DIR/cur/50:2,",
@@ -359,7 +363,7 @@ test_expect_equal_file OUTPUT EXPECTED
 test_begin_subtest "--output=files --format=json --duplicate=2"
 notmuch search --format=json --output=files --duplicate=2 '*' | notmuch_search_files_sanitize >OUTPUT
 cat <<EOF >EXPECTED
-["MAIL_DIR/cur/51:2,"]
+["$dup2"]
 EOF
 test_expect_equal_file OUTPUT EXPECTED
 
diff --git a/test/T530-upgrade.sh b/test/T530-upgrade.sh
index 56cee02..67bbf31 100755
--- a/test/T530-upgrade.sh
+++ b/test/T530-upgrade.sh
@@ -3,7 +3,7 @@ test_description="database upgrade"
 
 . ./test-lib.sh
 
-dbtarball=folders-v1.tar.xz
+dbtarball=database-v1.tar.xz
 
 # XXX: Accomplish the same with test lib helpers
 if [ ! -e ${TEST_DIRECTORY}/test-databases/${dbtarball} ]; then
diff --git a/test/test-databases/Makefile.local b/test/test-databases/Makefile.local
index e777ada..0572e78 100644
--- a/test/test-databases/Makefile.local
+++ b/test/test-databases/Makefile.local
@@ -4,7 +4,7 @@ TEST_DATABASE_MIRROR=http://notmuchmail.org/releases/test-databases
 
 dir := test/test-databases
 
-test_databases := $(dir)/folders-v1.tar.xz
+test_databases := $(dir)/database-v1.tar.xz
 
 %.tar.xz:
 	wget -nv -O $@ ${TEST_DATABASE_MIRROR}/$(notdir $@);
diff --git a/test/test-databases/database-v1.tar.xz.sha256 b/test/test-databases/database-v1.tar.xz.sha256
new file mode 100644
index 0000000..2cc4f96
--- /dev/null
+++ b/test/test-databases/database-v1.tar.xz.sha256
@@ -0,0 +1 @@
+4299e051b10e1fa7b33ea2862790a09ebfe96859681804e5251e130f800e69d2  database-v1.tar.xz
diff --git a/test/test-databases/folders-v1.tar.xz.sha256 b/test/test-databases/folders-v1.tar.xz.sha256
deleted file mode 100644
index 01ad79d..0000000
--- a/test/test-databases/folders-v1.tar.xz.sha256
+++ /dev/null
@@ -1 +0,0 @@
-ace8a61216756b90a421e23d03910e1228bcb910e197c35e51e29f2cf57b37d9  folders-v1.tar.xz
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 837c669..8697d6a 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 ||

Thread: