notmuch/test/t0004-thread-naming.sh
Michal Sojka 5398e6966a Convert the actual tests to the new framework
The changes are:
- The notmuch-test was split into several files (t000?-*.sh).
- Removed helper functions which were moved to test-lib.sh
- Replaced every printf with test_expect_success.
- Test commands chained with && (test-lib.sh doesn't use "set -e" in
  order to complete the test suite even if something fails)
- Many variables such as ${MAIL_DIR} were properly quoted as they
  contain spaces.
- Changed quoting patterns in add_message and generate_message (single
  quotes are already used by the test framework).
- ${TEST_DIR} replaced by ${PWD}

QUICK HOWTO:

To run the whole test suite
    make

To run only a single test
   ./t0001-new.sh

To stop on the first error
   ./t0001-new.sh -i
then mail store and database can be inspected in
"trash directory.t0001-new"

To see the output of tests
   ./t0001-new.sh -v

To not remove trash directory at the end:
   ./t0001-new.sh -d

To run all tests verbosely:
   make GIT_TEST_OPTS="-v"

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
2010-09-16 15:56:44 -07:00

191 lines
8.3 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
test_description="naming of threads with changing subject"
. ./test-lib.sh
test_expect_success 'Generate some messages' '
add_message "[subject]=\"thread-naming: Initial thread subject\"" \
"[date]=\"Fri, 05 Jan 2001 15:43:56 -0800\"" &&
first=${gen_msg_cnt} &&
parent=${gen_msg_id} &&
add_message "[subject]=\"thread-naming: Older changed subject\"" \
"[date]=\"Sat, 06 Jan 2001 15:43:56 -0800\"" \
"[in-reply-to]=\<$parent\>" &&
add_message "[subject]=\"thread-naming: Newer changed subject\"" \
"[date]=\"Sun, 07 Jan 2001 15:43:56 -0800\"" \
"[in-reply-to]=\<$parent\>" &&
add_message "[subject]=\"thread-naming: Final thread subject\"" \
"[date]=\"Mon, 08 Jan 2001 15:43:56 -0800\"" \
"[in-reply-to]=\<$parent\>" &&
final=${gen_msg_id}
'
test_expect_success "Initial thread name (oldest-first search)" '
output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
pass_if_equal "$output" "thread:XXX 2001-01-05 [4/4] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
'
test_expect_success "Initial thread name (newest-first search)" '
output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
pass_if_equal "$output" "thread:XXX 2001-01-08 [4/4] Notmuch Test Suite; thread-naming: Final thread subject (inbox unread)"
# Remove oldest and newest messages from search results
$NOTMUCH tag -inbox id:$parent or id:$final
'
test_expect_success "Changed thread name (oldest-first search)" '
output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
pass_if_equal "$output" "thread:XXX 2001-01-06 [2/4] Notmuch Test Suite; thread-naming: Older changed subject (inbox unread)"
'
test_expect_success "Changed thread name (newest-first search)" '
output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
pass_if_equal "$output" "thread:XXX 2001-01-07 [2/4] Notmuch Test Suite; thread-naming: Newer changed subject (inbox unread)"
'
test_expect_success "Ignore added reply prefix (Re:)" '
add_message "[subject]=\"Re: thread-naming: Initial thread subject\"" \
"[date]=\"Tue, 09 Jan 2001 15:43:45 -0800\"" \
"[in-reply-to]=\<$parent\>" &&
output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
pass_if_equal "$output" "thread:XXX 2001-01-09 [3/5] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
'
test_expect_success "Ignore added reply prefix (Aw:)" '
add_message "[subject]=\"Aw: thread-naming: Initial thread subject\"" \
"[date]=\"Wed, 10 Jan 2001 15:43:45 -0800\"" \
"[in-reply-to]=\<$parent\>" &&
output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
pass_if_equal "$output" "thread:XXX 2001-01-10 [4/6] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
'
test_expect_success "Ignore added reply prefix (Vs:)" '
add_message "[subject]=\"Vs: thread-naming: Initial thread subject\"" \
"[date]=\"Thu, 11 Jan 2001 15:43:45 -0800\"" \
"[in-reply-to]=\<$parent\>" &&
output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
pass_if_equal "$output" "thread:XXX 2001-01-11 [5/7] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
'
test_expect_success "Ignore added reply prefix (Sv:)" '
add_message "[subject]=\"Sv: thread-naming: Initial thread subject\"" \
"[date]=\"Fri, 12 Jan 2001 15:43:45 -0800\"" \
"[in-reply-to]=\<$parent\>" &&
output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize) &&
pass_if_equal "$output" "thread:XXX 2001-01-12 [6/8] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
'
test_expect_success "Test order of messages in \"notmuch show\"" '
output=$($NOTMUCH show thread-naming | notmuch_show_sanitize) &&
pass_if_equal "$output" " message{ id:msg-$(printf "%03d" $first)@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-$(printf "%03d" $first)
header{
Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (unread)
Subject: thread-naming: Initial thread subject
From: Notmuch Test Suite <test_suite@notmuchmail.org>
To: Notmuch Test Suite <test_suite@notmuchmail.org>
Date: Fri, 05 Jan 2001 15:43:56 -0800
header}
body{
part{ ID: 1, Content-type: text/plain
This is just a test message (#$first)
part}
body}
message}
message{ id:msg-$(printf "%03d" $((first + 1)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 1)))
header{
Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-06) (inbox unread)
Subject: thread-naming: Older changed subject
From: Notmuch Test Suite <test_suite@notmuchmail.org>
To: Notmuch Test Suite <test_suite@notmuchmail.org>
Date: Sat, 06 Jan 2001 15:43:56 -0800
header}
body{
part{ ID: 1, Content-type: text/plain
This is just a test message (#$((first + 1)))
part}
body}
message}
message{ id:msg-$(printf "%03d" $((first + 2)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 2)))
header{
Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-07) (inbox unread)
Subject: thread-naming: Newer changed subject
From: Notmuch Test Suite <test_suite@notmuchmail.org>
To: Notmuch Test Suite <test_suite@notmuchmail.org>
Date: Sun, 07 Jan 2001 15:43:56 -0800
header}
body{
part{ ID: 1, Content-type: text/plain
This is just a test message (#$((first + 2)))
part}
body}
message}
message{ id:msg-$(printf "%03d" $((first + 3)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 3)))
header{
Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-08) (unread)
Subject: thread-naming: Final thread subject
From: Notmuch Test Suite <test_suite@notmuchmail.org>
To: Notmuch Test Suite <test_suite@notmuchmail.org>
Date: Mon, 08 Jan 2001 15:43:56 -0800
header}
body{
part{ ID: 1, Content-type: text/plain
This is just a test message (#$((first + 3)))
part}
body}
message}
message{ id:msg-$(printf "%03d" $((first + 4)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 4)))
header{
Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-09) (inbox unread)
Subject: Re: thread-naming: Initial thread subject
From: Notmuch Test Suite <test_suite@notmuchmail.org>
To: Notmuch Test Suite <test_suite@notmuchmail.org>
Date: Tue, 09 Jan 2001 15:43:45 -0800
header}
body{
part{ ID: 1, Content-type: text/plain
This is just a test message (#$((first + 4)))
part}
body}
message}
message{ id:msg-$(printf "%03d" $((first + 5)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 5)))
header{
Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-10) (inbox unread)
Subject: Aw: thread-naming: Initial thread subject
From: Notmuch Test Suite <test_suite@notmuchmail.org>
To: Notmuch Test Suite <test_suite@notmuchmail.org>
Date: Wed, 10 Jan 2001 15:43:45 -0800
header}
body{
part{ ID: 1, Content-type: text/plain
This is just a test message (#$((first + 5)))
part}
body}
message}
message{ id:msg-$(printf "%03d" $((first + 6)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 6)))
header{
Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-11) (inbox unread)
Subject: Vs: thread-naming: Initial thread subject
From: Notmuch Test Suite <test_suite@notmuchmail.org>
To: Notmuch Test Suite <test_suite@notmuchmail.org>
Date: Thu, 11 Jan 2001 15:43:45 -0800
header}
body{
part{ ID: 1, Content-type: text/plain
This is just a test message (#$((first + 6)))
part}
body}
message}
message{ id:msg-$(printf "%03d" $((first + 7)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 7)))
header{
Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-12) (inbox unread)
Subject: Sv: thread-naming: Initial thread subject
From: Notmuch Test Suite <test_suite@notmuchmail.org>
To: Notmuch Test Suite <test_suite@notmuchmail.org>
Date: Fri, 12 Jan 2001 15:43:45 -0800
header}
body{
part{ ID: 1, Content-type: text/plain
This is just a test message (#$((first + 7)))
part}
body}
message}"
'
test_done