+test_begin_subtest "Empty tag names"
+test_expect_code 1 'notmuch tag + One'
+
+test_begin_subtest "Tag name beginning with -"
+test_expect_code 1 'notmuch tag +- One'
+
+test_begin_subtest "Xapian exception: read only files"
+test_subtest_broken_for_root
+chmod u-w ${MAIL_DIR}/.notmuch/xapian/*.*
+output=$(notmuch tag +something '*' 2>&1 | sed 's/: .*$//' )
+chmod u+w ${MAIL_DIR}/.notmuch/xapian/*.*
+test_expect_equal "$output" "A Xapian exception occurred opening database"
+
+add_email_corpus
+
+if [ "${NOTMUCH_HAVE_SFSEXP-0}" = "1" ]; then
+
+ test_query_syntax '(and "wonderful" "wizard")' 'wonderful and wizard'
+ test_query_syntax '(or "php" "wizard")' 'php or wizard'
+ test_query_syntax 'wizard' 'wizard'
+ test_query_syntax 'Wizard' 'Wizard'
+ test_query_syntax '(attachment notmuch-help.patch)' 'attachment:notmuch-help.patch'
+ test_query_syntax '(mimetype text/html)' 'mimetype:text/html'
+
+ test_begin_subtest "--batch --query=sexp"
+ notmuch dump --format=batch-tag > backup.tags
+ notmuch tag --batch --query=sexp <<EOF
+ +all -- (or One Two)
+ +none -- (and One Two)
+ EOF
+ notmuch dump > OUTPUT
+ cat <<EOF > EXPECTED
+ #notmuch-dump batch-tag:3 config,properties,tags
+ +all +inbox +tag5 +unread -- id:msg-001@notmuch-test-suite
+ +all +inbox +tag4 +tag5 +unread -- id:msg-002@notmuch-test-suite
+EOF
+ notmuch restore --format=batch-tag < backup.tags
+ test_expect_equal_file EXPECTED OUTPUT