3 test_description="emacs: mail subject to filename"
4 . $(dirname "$0")/test-lib.sh || exit 1
5 . $(dirname "$0")/test-lib-emacs.sh || exit 1
9 # emacs server can't be started in a child process with $(test_emacs ...)
10 test_emacs '(ignore)' > /dev/null
12 # test notmuch-wash-subject-to-patch-sequence-number (subject)
13 test_begin_subtest "no patch sequence number"
14 output=$(test_emacs '(format "%S" (notmuch-wash-subject-to-patch-sequence-number
15 "[PATCH] A normal patch subject without numbers"))'
17 test_expect_equal "$output" '"nil"'
19 test_begin_subtest "patch sequence number #1"
20 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
21 "[PATCH 2/3] A most regular patch subject")'
23 test_expect_equal "$output" 2
25 test_begin_subtest "patch sequence number #2"
26 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
27 " [dummy list prefix] [RFC PATCH v2 13/42] Special prefixes")'
29 test_expect_equal "$output" 13
31 test_begin_subtest "patch sequence number #3"
32 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
33 "[PATCH 2/3] [PATCH 032/037] use the last prefix")'
35 test_expect_equal "$output" 32
37 test_begin_subtest "patch sequence number #4"
38 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
39 "[dummy list prefix] [PATCH 2/3] PATCH 3/3] do not use a broken prefix")'
41 test_expect_equal "$output" 2
43 test_begin_subtest "patch sequence number #5"
44 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
45 "[RFC][PATCH 3/5][PATCH 4/5][PATCH 5/5] A made up test")'
47 test_expect_equal "$output" 5
49 test_begin_subtest "patch sequence number #6"
50 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
51 "[PATCH 2/3] this -> [PATCH 3/3] is not a prefix anymore [nor this 4/4]")'
53 test_expect_equal "$output" 2
55 test_begin_subtest "patch sequence number #7"
56 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
57 "[liberally accept crapola right before123/456and after] the numbers")'
59 test_expect_equal "$output" 123
61 # test notmuch-wash-subject-to-filename (subject &optional maxlen)
62 test_begin_subtest "filename #1"
63 output=$(test_emacs '(notmuch-wash-subject-to-filename
64 "just a subject line")'
66 test_expect_equal "$output" '"just-a-subject-line"'
68 test_begin_subtest "filename #2"
69 output=$(test_emacs '(notmuch-wash-subject-to-filename
70 " [any] [prefixes are ] [removed!] from the subject")'
72 test_expect_equal "$output" '"from-the-subject"'
74 test_begin_subtest "filename #3"
75 output=$(test_emacs '(notmuch-wash-subject-to-filename
76 " leading and trailing space ")'
78 test_expect_equal "$output" '"leading-and-trailing-space"'
80 test_begin_subtest "filename #4"
81 output=$(test_emacs '(notmuch-wash-subject-to-filename
82 "!# leading ()// &%, and in between_and_trailing garbage ()(&%%")'
84 test_expect_equal "$output" '"-leading-and-in-between_and_trailing-garbage"'
86 test_begin_subtest "filename #5"
87 output=$(test_emacs '(notmuch-wash-subject-to-filename
88 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_01234567890")'
90 test_expect_equal "$output" '"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_01234567890"'
92 test_begin_subtest "filename #6"
93 output=$(test_emacs '(notmuch-wash-subject-to-filename
94 "sequences of ... are squashed and trailing are removed ...")'
96 test_expect_equal "$output" '"sequences-of-.-are-squashed-and-trailing-are-removed"'
98 test_begin_subtest "filename #7"
99 output=$(test_emacs '(notmuch-wash-subject-to-filename
100 "max length test" 1)'
102 test_expect_equal "$output" '"m"'
104 test_begin_subtest "filename #8"
105 output=$(test_emacs '(notmuch-wash-subject-to-filename
106 "max length test /&(/%&/%%&¤%¤" 20)'
108 test_expect_equal "$output" '"max-length-test"'
110 test_begin_subtest "filename #9"
111 output=$(test_emacs '(notmuch-wash-subject-to-filename
112 "[a prefix] [is only separated] by [spaces], so \"by\" is not okay!")'
114 test_expect_equal "$output" '"by-spaces-so-by-is-not-okay"'
116 # test notmuch-wash-subject-to-patch-filename (subject)
117 test_begin_subtest "patch filename #1"
118 output=$(test_emacs '(notmuch-wash-subject-to-patch-filename
119 "[RFC][PATCH 099/100] rewrite notmuch")'
121 test_expect_equal "$output" '"0099-rewrite-notmuch.patch"'
123 test_begin_subtest "patch filename #2"
124 output=$(test_emacs '(notmuch-wash-subject-to-patch-filename
125 "[RFC PATCH v1] has no patch number, default to 1")'
127 test_expect_equal "$output" '"0001-has-no-patch-number-default-to-1.patch"'
129 test_begin_subtest "patch filename #3"
130 output=$(test_emacs '(notmuch-wash-subject-to-patch-filename
131 "[PATCH 4/5] the maximum length of a patch filename is 52 + patch sequence number + .patch extension")'
133 test_expect_equal "$output" '"0004-the-maximum-length-of-a-patch-filename-is-52-patch-s.patch"'
135 test_begin_subtest "patch filename #4"
136 output=$(test_emacs '(notmuch-wash-subject-to-patch-filename
137 "[PATCH 4/5] the maximum length of a patch filename is 52 + patchh ! sequence number + .patch extension, *before* trimming trailing - and .")'
139 test_expect_equal "$output" '"0004-the-maximum-length-of-a-patch-filename-is-52-patchh.patch"'