These are based on the equivalent functions for json. Like those,
these are pretty simple-minded, and don't really understand the
syntax.
---
 test/T170-sexp.sh | 29 ++++++++++++++---------------
 test/test-lib.sh  | 14 ++++++++++++++
 2 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/test/T170-sexp.sh b/test/T170-sexp.sh
index 0d32560c..76e07481 100755
--- a/test/T170-sexp.sh
+++ b/test/T170-sexp.sh
@@ -5,32 +5,32 @@ test_description="--format=sexp output"
 
 test_begin_subtest "Show message: sexp"
 add_message "[subject]=\"sexp-show-subject\"" "[date]=\"Sat, 01 Jan 2000 
12:00:00 -0000\"" "[bcc]=\"test_suite+...@notmuchmail.org\"" 
"[reply-to]=\"test_suite+repl...@notmuchmail.org\"" 
"[body]=\"sexp-show-message\""
-output=$(notmuch show --format=sexp "sexp-show-message")
-test_expect_equal "$output" "((((:id \"${gen_msg_id}\" :match t :excluded nil 
:filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative 
\"2000-01-01\" :tags (\"inbox\" \"unread\") :body ((:id 1 :content-type 
\"text/plain\" :content \"sexp-show-message\n\")) :crypto () :headers (:Subject 
\"sexp-show-subject\" :From \"Notmuch Test Suite <test_su...@notmuchmail.org>\" 
:To \"Notmuch Test Suite <test_su...@notmuchmail.org>\" :Bcc 
\"test_suite+...@notmuchmail.org\" :Reply-To 
\"test_suite+repl...@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 
+0000\")) ())))"
+output=$(notmuch show --format=sexp "sexp-show-message" | 
notmuch_sexp_show_sanitize)
+test_expect_equal "$output" "((((:id \"XXXXX\" :match t :excluded nil 
:filename (\"YYYYY\") :timestamp 42 :date_relative \"2000-01-01\" :tags 
(\"inbox\" \"unread\") :body ((:id 1 :content-type \"text/plain\" :content 
\"sexp-show-message\n\")) :crypto () :headers (:Subject \"sexp-show-subject\" 
:From \"Notmuch Test Suite <test_su...@notmuchmail.org>\" :To \"Notmuch Test 
Suite <test_su...@notmuchmail.org>\" :Bcc \"test_suite+...@notmuchmail.org\" 
:Reply-To \"test_suite+repl...@notmuchmail.org\" :Date \"GENERATED_DATE\")) 
())))"
 
 # This should be the same output as above.
 test_begin_subtest "Show message: sexp --body=true"
-output=$(notmuch show --format=sexp --body=true "sexp-show-message")
-test_expect_equal "$output" "((((:id \"${gen_msg_id}\" :match t :excluded nil 
:filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative 
\"2000-01-01\" :tags (\"inbox\" \"unread\") :body ((:id 1 :content-type 
\"text/plain\" :content \"sexp-show-message\n\")) :crypto () :headers (:Subject 
\"sexp-show-subject\" :From \"Notmuch Test Suite <test_su...@notmuchmail.org>\" 
:To \"Notmuch Test Suite <test_su...@notmuchmail.org>\" :Bcc 
\"test_suite+...@notmuchmail.org\" :Reply-To 
\"test_suite+repl...@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 
+0000\")) ())))"
+output=$(notmuch show --format=sexp --body=true "sexp-show-message" | 
notmuch_sexp_show_sanitize)
+test_expect_equal "$output" "((((:id \"XXXXX\" :match t :excluded nil 
:filename (\"YYYYY\") :timestamp 42 :date_relative \"2000-01-01\" :tags 
(\"inbox\" \"unread\") :body ((:id 1 :content-type \"text/plain\" :content 
\"sexp-show-message\n\")) :crypto () :headers (:Subject \"sexp-show-subject\" 
:From \"Notmuch Test Suite <test_su...@notmuchmail.org>\" :To \"Notmuch Test 
Suite <test_su...@notmuchmail.org>\" :Bcc \"test_suite+...@notmuchmail.org\" 
:Reply-To \"test_suite+repl...@notmuchmail.org\" :Date \"GENERATED_DATE\")) 
())))"
 
 test_begin_subtest "Show message: sexp --body=false"
-output=$(notmuch show --format=sexp --body=false "sexp-show-message")
-test_expect_equal "$output" "((((:id \"${gen_msg_id}\" :match t :excluded nil 
:filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative 
\"2000-01-01\" :tags (\"inbox\" \"unread\") :crypto () :headers (:Subject 
\"sexp-show-subject\" :From \"Notmuch Test Suite <test_su...@notmuchmail.org>\" 
:To \"Notmuch Test Suite <test_su...@notmuchmail.org>\" :Bcc 
\"test_suite+...@notmuchmail.org\" :Reply-To 
\"test_suite+repl...@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 
+0000\")) ())))"
+output=$(notmuch show --format=sexp --body=false "sexp-show-message" | 
notmuch_sexp_show_sanitize)
+test_expect_equal "$output" "((((:id \"XXXXX\" :match t :excluded nil 
:filename (\"YYYYY\") :timestamp 42 :date_relative \"2000-01-01\" :tags 
(\"inbox\" \"unread\") :crypto () :headers (:Subject \"sexp-show-subject\" 
:From \"Notmuch Test Suite <test_su...@notmuchmail.org>\" :To \"Notmuch Test 
Suite <test_su...@notmuchmail.org>\" :Bcc \"test_suite+...@notmuchmail.org\" 
:Reply-To \"test_suite+repl...@notmuchmail.org\" :Date \"GENERATED_DATE\")) 
())))"
 
 test_begin_subtest "Search message: sexp"
 add_message "[subject]=\"sexp-search-subject\"" "[date]=\"Sat, 01 Jan 2000 
12:00:00 -0000\"" "[body]=\"sexp-search-message\""
-output=$(notmuch search --format=sexp "sexp-search-message" | 
notmuch_search_sanitize)
-test_expect_equal "$output" "((:thread \"0000000000000002\" :timestamp 
946728000 :date_relative \"2000-01-01\" :matched 1 :total 1 :authors \"Notmuch 
Test Suite\" :subject \"sexp-search-subject\" :query (\"id:$gen_msg_id\" nil) 
:tags (\"inbox\" \"unread\")))"
+output=$(notmuch search --format=sexp "sexp-search-message" | 
notmuch_sexp_search_sanitize)
+test_expect_equal "$output" "((:thread \"XXX\" :timestamp 946728000 
:date_relative \"2000-01-01\" :matched 1 :total 1 :authors \"Notmuch Test 
Suite\" :subject \"sexp-search-subject\" :query (\"id:$gen_msg_id\" nil) :tags 
(\"inbox\" \"unread\")))"
 
 test_begin_subtest "Show message: sexp, utf-8"
 add_message "[subject]=\"sexp-show-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 
2000 12:00:00 -0000\"" "[body]=\"jsön-show-méssage\""
-output=$(notmuch show --format=sexp "jsön-show-méssage")
-test_expect_equal "$output" "((((:id \"${gen_msg_id}\" :match t :excluded nil 
:filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative 
\"2000-01-01\" :tags (\"inbox\" \"unread\") :body ((:id 1 :content-type 
\"text/plain\" :content \"jsön-show-méssage\n\")) :crypto () :headers (:Subject 
\"sexp-show-utf8-body-sübjéct\" :From \"Notmuch Test Suite 
<test_su...@notmuchmail.org>\" :To \"Notmuch Test Suite 
<test_su...@notmuchmail.org>\" :Date \"Sat, 01 Jan 2000 12:00:00 +0000\")) 
())))"
+output=$(notmuch show --format=sexp "jsön-show-méssage" | 
notmuch_sexp_show_sanitize)
+test_expect_equal "$output" "((((:id \"XXXXX\" :match t :excluded nil 
:filename (\"YYYYY\") :timestamp 42 :date_relative \"2000-01-01\" :tags 
(\"inbox\" \"unread\") :body ((:id 1 :content-type \"text/plain\" :content 
\"jsön-show-méssage\n\")) :crypto () :headers (:Subject 
\"sexp-show-utf8-body-sübjéct\" :From \"Notmuch Test Suite 
<test_su...@notmuchmail.org>\" :To \"Notmuch Test Suite 
<test_su...@notmuchmail.org>\" :Date \"GENERATED_DATE\")) ())))"
 
 test_begin_subtest "Search message: sexp, utf-8"
 add_message "[subject]=\"sexp-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 
Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\""
-output=$(notmuch search --format=sexp "jsön-search-méssage" | 
notmuch_search_sanitize)
-test_expect_equal "$output" "((:thread \"0000000000000004\" :timestamp 
946728000 :date_relative \"2000-01-01\" :matched 1 :total 1 :authors \"Notmuch 
Test Suite\" :subject \"sexp-search-utf8-body-sübjéct\" :query 
(\"id:$gen_msg_id\" nil) :tags (\"inbox\" \"unread\")))"
+output=$(notmuch search --format=sexp "jsön-search-méssage" | 
notmuch_sexp_search_sanitize)
+test_expect_equal "$output" "((:thread \"XXX\" :timestamp 946728000 
:date_relative \"2000-01-01\" :matched 1 :total 1 :authors \"Notmuch Test 
Suite\" :subject \"sexp-search-utf8-body-sübjéct\" :query (\"id:$gen_msg_id\" 
nil) :tags (\"inbox\" \"unread\")))"
 
 test_begin_subtest "Show message: sexp, inline attachment filename"
 subject='sexp-show-inline-attachment-filename'
@@ -54,10 +54,9 @@ add_message "[subject]=\"extra-headers\"" "[date]=\"Sat, 01 
Jan 2000 12:00:00 -0
        for <test_suite_ot...@notmuchmail.org>; Sat, 10 Apr 2010 07:54:51 -0400 
(EDT)\"" \
 
 notmuch config set show.extra_headers "in-reply-to;received"
-notmuch show --format=sexp --body=false id:${gen_msg_id} | \
-    notmuch_dir_sanitize | sed 's/msg-[0-9]*/MSG/g'> OUTPUT
+notmuch show --format=sexp --body=false id:${gen_msg_id} | 
notmuch_sexp_show_sanitize > OUTPUT
 cat <<EOF > EXPECTED
-((((:id "MSG@notmuch-test-suite" :match t :excluded nil :filename 
("MAIL_DIR/MSG") :timestamp 946728000 :date_relative "2000-01-01" :tags 
("inbox" "unread") :crypto () :headers (:Subject "extra-headers" :From "Notmuch 
Test Suite <test_su...@notmuchmail.org>" :To "Notmuch Test Suite 
<test_su...@notmuchmail.org>" :Date "Sat, 01 Jan 2000 12:00:00 +0000" 
:In-Reply-To "<parent@notmuch-test-suite>" :Received "from mail.example.com 
(mail.example.com [1.1.1.1])\011by mail.notmuchmail.org (some MTA) with ESMTP 
id 12345678\011for <test_suite_ot...@notmuchmail.org>; Sat, 10 Apr 2010 
07:54:51 -0400 (EDT)")) ())))
+((((:id "XXXXX" :match t :excluded nil :filename ("YYYYY") :timestamp 42 
:date_relative "2000-01-01" :tags ("inbox" "unread") :crypto () :headers 
(:Subject "extra-headers" :From "Notmuch Test Suite 
<test_su...@notmuchmail.org>" :To "Notmuch Test Suite 
<test_su...@notmuchmail.org>" :Date "GENERATED_DATE" :In-Reply-To 
"<parent@notmuch-test-suite>" :Received "from mail.example.com 
(mail.example.com [1.1.1.1])\011by mail.notmuchmail.org (some MTA) with ESMTP 
id 12345678\011for <test_suite_ot...@notmuchmail.org>; Sat, 10 Apr 2010 
07:54:51 -0400 (EDT)")) ())))
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 75a62214..4eb58ea0 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -527,6 +527,20 @@ notmuch_json_show_sanitize () {
        -e 's|"content-length": [1-9][0-9]*|"content-length": "NONZERO"|g'
 }
 
+notmuch_sexp_show_sanitize () {
+    sed \
+       -e 's|:id "[^"]*"|:id "XXXXX"|g' \
+       -e 's|:Date "Sat, 01 Jan 2000 [^"]*0000"|:Date "GENERATED_DATE"|g' \
+       -e 's|:filename "signature.asc"||g' \
+       -e 's|:filename ("/[^"]*")|:filename ("YYYYY")|g' \
+       -e 's|:timestamp 9........|:timestamp 42|g' \
+       -e 's|:content-length [1-9][0-9]*|:content-length "NONZERO"|g'
+}
+
+notmuch_sexp_search_sanitize () {
+    sed -e 's|:thread "[^"]*"|:thread "XXX"|'
+}
+
 notmuch_emacs_error_sanitize () {
     local command
     command=$1
-- 
2.35.2

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org

Reply via email to