3 test_description="emacs: mail subject to filename"
6 # emacs server can't be started in a child process with $(test_emacs ...)
9 # test notmuch-wash-subject-to-patch-sequence-number (subject)
10 test_begin_subtest "no patch sequence number"
11 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
12 "[PATCH] A normal patch subject without numbers")'
14 test_expect_equal "$output" ""
16 test_begin_subtest "patch sequence number #1"
17 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
18 "[PATCH 2/3] A most regular patch subject")'
20 test_expect_equal "$output" 2
22 test_begin_subtest "patch sequence number #2"
23 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
24 " [dummy list prefix] [RFC PATCH v2 13/42] Special prefixes")'
26 test_expect_equal "$output" 13
28 test_begin_subtest "patch sequence number #3"
29 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
30 "[PATCH 2/3] [PATCH 032/037] use the last prefix")'
32 test_expect_equal "$output" 32
34 test_begin_subtest "patch sequence number #4"
35 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
36 "[dummy list prefix] [PATCH 2/3] PATCH 3/3] do not use a broken prefix")'
38 test_expect_equal "$output" 2
40 test_begin_subtest "patch sequence number #5"
41 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
42 "[RFC][PATCH 3/5][PATCH 4/5][PATCH 5/5] A made up test")'
44 test_expect_equal "$output" 5
46 test_begin_subtest "patch sequence number #6"
47 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
48 "[PATCH 2/3] this -> [PATCH 3/3] is not a prefix anymore [nor this 4/4]")'
50 test_expect_equal "$output" 2
52 test_begin_subtest "patch sequence number #7"
53 output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
54 "[liberally accept crapola right before123/456and after] the numbers")'
56 test_expect_equal "$output" 123
58 # test notmuch-wash-subject-to-filename (subject &optional maxlen)
59 test_begin_subtest "filename #1"
60 output=$(test_emacs '(notmuch-wash-subject-to-filename
61 "just a subject line")'
63 test_expect_equal $output '"just-a-subject-line"'
65 test_begin_subtest "filename #2"
66 output=$(test_emacs '(notmuch-wash-subject-to-filename
67 " [any] [prefixes are ] [removed!] from the subject")'
69 test_expect_equal $output '"from-the-subject"'
71 test_begin_subtest "filename #3"
72 output=$(test_emacs '(notmuch-wash-subject-to-filename
73 " leading and trailing space ")'
75 test_expect_equal $output '"leading-and-trailing-space"'
77 test_begin_subtest "filename #4"
78 output=$(test_emacs '(notmuch-wash-subject-to-filename
79 "!# leading ()// &%, and in between_and_trailing garbage ()(&%%")'
81 test_expect_equal $output '"-leading-and-in-between_and_trailing-garbage"'
83 test_begin_subtest "filename #5"
84 output=$(test_emacs '(notmuch-wash-subject-to-filename
85 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_01234567890")'
87 test_expect_equal $output '"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_01234567890"'
89 test_begin_subtest "filename #6"
90 output=$(test_emacs '(notmuch-wash-subject-to-filename
91 "sequences of ... are squashed and trailing are removed ...")'
93 test_expect_equal $output '"sequences-of-.-are-squashed-and-trailing-are-removed"'
95 test_begin_subtest "filename #7"
96 output=$(test_emacs '(notmuch-wash-subject-to-filename
99 test_expect_equal $output '"m"'
101 test_begin_subtest "filename #8"
102 output=$(test_emacs '(notmuch-wash-subject-to-filename
103 "max length test /&(/%&/%%&¤%¤" 20)'
105 test_expect_equal $output '"max-length-test"'
107 test_begin_subtest "filename #9"
108 output=$(test_emacs '(notmuch-wash-subject-to-filename
109 "[a prefix] [is only separated] by [spaces], so \"by\" is not okay!")'
111 test_expect_equal $output '"by-spaces-so-by-is-not-okay"'
113 # test notmuch-wash-subject-to-patch-filename (subject)
114 test_begin_subtest "patch filename #1"
115 output=$(test_emacs '(notmuch-wash-subject-to-patch-filename
116 "[RFC][PATCH 099/100] rewrite notmuch")'
118 test_expect_equal "$output" '"0099-rewrite-notmuch.patch"'
120 test_begin_subtest "patch filename #2"
121 output=$(test_emacs '(notmuch-wash-subject-to-patch-filename
122 "[RFC PATCH v1] has no patch number, default to 1")'
124 test_expect_equal "$output" '"0001-has-no-patch-number-default-to-1.patch"'
126 test_begin_subtest "patch filename #3"
127 output=$(test_emacs '(notmuch-wash-subject-to-patch-filename
128 "[PATCH 4/5] the maximum length of a patch filename is 52 + patch sequence number + .patch extension")'
130 test_expect_equal "$output" '"0004-the-maximum-length-of-a-patch-filename-is-52-patch-s.patch"'
132 test_begin_subtest "patch filename #4"
133 output=$(test_emacs '(notmuch-wash-subject-to-patch-filename
134 "[PATCH 4/5] the maximum length of a patch filename is 52 + patchh ! sequence number + .patch extension, *before* trimming trailing - and .")'
136 test_expect_equal "$output" '"0004-the-maximum-length-of-a-patch-filename-is-52-patchh.patch"'