test: sanitize generated message files names

It is fragile to encode the generated names into tests, as it makes
tests break when e.g. new tests are added.  There is a possibility
that this will hide certain failures; in that case meaningful filenames
should be chosen for the generated messages.
This commit is contained in:
David Bremner 2022-01-21 19:38:48 -04:00
parent 0a32741fce
commit 0756105832
5 changed files with 14 additions and 14 deletions

View file

@ -346,7 +346,7 @@ output=$(notmuch search --query=sexp '(attachment (starts-with not))' | notmuch_
test_expect_equal "$output" 'thread:XXX 2009-11-18 [2/2] Lars Kellogg-Stedman; [notmuch] "notmuch help" outputs to stderr? (attachment inbox signed unread)'
test_begin_subtest "starts-with, folder"
notmuch search --output=files --query=sexp '(folder (starts-with bad))' | notmuch_dir_sanitize | sed 's/[0-9]*$/XXX/' > OUTPUT
notmuch search --output=files --query=sexp '(folder (starts-with bad))' | notmuch_search_files_sanitize > OUTPUT
cat <<EOF > EXPECTED
MAIL_DIR/bad/msg-XXX
MAIL_DIR/bad/news/msg-XXX

View file

@ -28,8 +28,8 @@ test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1(2)] Notmuch Test Suite
test_begin_subtest "Folder search with --output=files"
output=$(notmuch search --output=files folder:bad/news | notmuch_search_files_sanitize)
test_expect_equal "$output" "MAIL_DIR/bad/news/msg-003
MAIL_DIR/duplicate/bad/news/msg-003"
test_expect_equal "$output" "MAIL_DIR/bad/news/msg-XXX
MAIL_DIR/duplicate/bad/news/msg-XXX"
test_begin_subtest "After removing duplicate instance of matching path"
rm -r "${MAIL_DIR}/bad/news"
@ -39,7 +39,7 @@ test_expect_equal "$output" ""
test_begin_subtest "Folder search with --output=files part #2"
output=$(notmuch search --output=files folder:duplicate/bad/news | notmuch_search_files_sanitize)
test_expect_equal "$output" "MAIL_DIR/duplicate/bad/news/msg-003"
test_expect_equal "$output" "MAIL_DIR/duplicate/bad/news/msg-XXX"
test_begin_subtest "After removing duplicate instance of matching path part #2"
output=$(notmuch search folder:duplicate/bad/news | notmuch_search_sanitize)

View file

@ -24,8 +24,8 @@ test_expect_equal "$output" "No new mail."
test_begin_subtest "Multiple files for same message"
cat <<EOF >EXPECTED
MAIL_DIR/msg-001
MAIL_DIR/spam/msg-001
MAIL_DIR/msg-XXX
MAIL_DIR/spam/msg-XXX
EOF
notmuch search --output=files id:$id_x | notmuch_search_files_sanitize >OUTPUT
test_expect_equal_file EXPECTED OUTPUT

View file

@ -58,13 +58,13 @@ test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "notmuch search --output=files with partially gzipped mail store"
notmuch search --output=files '*' | notmuch_search_files_sanitize > OUTPUT
cat <<EOF > EXPECTED
MAIL_DIR/msg-001.gz
MAIL_DIR/msg-002.gz
MAIL_DIR/msg-003.gz
MAIL_DIR/msg-004
MAIL_DIR/msg-005.gz
MAIL_DIR/msg-006
MAIL_DIR/msg-007.gz
MAIL_DIR/msg-XXX.gz
MAIL_DIR/msg-XXX.gz
MAIL_DIR/msg-XXX.gz
MAIL_DIR/msg-XXX
MAIL_DIR/msg-XXX.gz
MAIL_DIR/msg-XXX
MAIL_DIR/msg-XXX.gz
EOF
test_expect_equal_file EXPECTED OUTPUT

View file

@ -551,7 +551,7 @@ notmuch_search_sanitize () {
}
notmuch_search_files_sanitize () {
notmuch_dir_sanitize
notmuch_dir_sanitize | sed 's/msg-[0-9][0-9][0-9]/msg-XXX/'
}
notmuch_dir_sanitize () {