]> git.notmuchmail.org Git - notmuch/commitdiff
test:Improve test behaviors when --root is used
authorMark Anderson <ma.skies@gmail.com>
Tue, 28 Jun 2011 22:11:32 +0000 (16:11 -0600)
committerCarl Worth <cworth@cworth.org>
Tue, 28 Jun 2011 23:01:56 +0000 (16:01 -0700)
Change add_email_corpus, emacs_deliver_message and tests to use
$TEST_DIRECTORY instead of '..'.

This improves the behavior of the usage of --root=<dir>, as the
assumption of what '..' means will usually be incorrect.

Document -root option in README and update valgrind to work with
-root.

test/README
test/basic
test/crypto
test/emacs
test/symbol-hiding
test/test-lib.sh

index be75e0e706e7af579c087243dcb01aae3cc6b195..8fbf78da57618f613e5ebb26736f5ef16b1fd7ad 100644 (file)
@@ -41,6 +41,15 @@ The following command-line options are available when running tests:
        As the names depend on the tests' file names, it is safe to
        run the tests with this option in parallel.
 
+--root=<dir>::
+       This runs the testsuites specified under a seperate directory.
+       However, caution is advised, as not all tests are maintained
+       with this relocation in mind, so some tests may behave
+       differently.
+
+       Pointing this argument at a tmpfs filesystem can improve the
+       speed of the test suite for some users.
+
 When invoking the test suite via "make test" any of the above options
 can be specified as follows:
 
index d6e8c100d083b91b6719930344e2c6c7547c3051..33bf711339b96614555818c873ae126f799dcbef 100755 (executable)
@@ -51,9 +51,9 @@ test_expect_code 2 'failure to clean up causes the test to fail' '
 
 # Ensure that all tests are being run
 test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'
-eval $(sed -n -e '/^TESTS="$/,/^"$/p' notmuch-test ../notmuch-test)
+eval $(sed -n -e '/^TESTS="$/,/^"$/p' notmuch-test $TEST_DIRECTORY/notmuch-test)
 tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)
-available=$(ls -1 ../ | \
+available=$(ls -1 $TEST_DIRECTORY/ | \
     sed -r -e "/^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test)/d" \
           -e "/^(README|test-lib.sh|test-lib.el|test-results|tmp.*|valgrind|corpus*)/d" \
           -e "/^(emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose|symbol-test.cc)/d" \
@@ -63,19 +63,19 @@ available=$(ls -1 ../ | \
           | sort)
 test_expect_equal "$tests_in_suite" "$available"
 
-EXPECTED=../test.expected-output
+EXPECTED=$TEST_DIRECTORY/test.expected-output
 suppress_diff_date() {
     sed -e 's/\(.*\-\-\- test-verbose\.4\.\expected\).*/\1/' \
        -e 's/\(.*\+\+\+ test-verbose\.4\.\output\).*/\1/'
 }
 
 test_begin_subtest "Ensure that test output is suppressed unless the test fails"
-output=$(cd ..; ./test-verbose 2>&1 | suppress_diff_date)
+output=$(cd $TEST_DIRECTORY; ./test-verbose 2>&1 | suppress_diff_date)
 expected=$(cat $EXPECTED/test-verbose-no | suppress_diff_date)
 test_expect_equal "$output" "$expected"
 
 test_begin_subtest "Ensure that -v does not suppress test output"
-output=$(cd ..; ./test-verbose -v 2>&1 | suppress_diff_date)
+output=$(cd $TEST_DIRECTORY; ./test-verbose -v 2>&1 | suppress_diff_date)
 expected=$(cat $EXPECTED/test-verbose-yes | suppress_diff_date)
 # Do not include the results of test-verbose in totals
 rm $TEST_DIRECTORY/test-results/test-verbose-*
index 01daffe7eb94a79f233f7004d57e24bef3ba8b41..7eb3559169ffafbfe7b29c087a48c9cc82a6109f 100755 (executable)
@@ -12,7 +12,7 @@ add_gnupg_home ()
     local output
     [ -d ${GNUPGHOME} ] && return
     mkdir -m 0700 "$GNUPGHOME"
-    gpg --no-tty --import <../gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1
+    gpg --no-tty --import <$TEST_DIRECTORY/gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1
     test_debug "cat $GNUPGHOME/import.log"
     if (gpg --quick-random --version >/dev/null 2>&1) ; then
        echo quick-random >> "$GNUPGHOME"/gpg.conf
index 3d426453b0613bf0038c9ae022c9b0bbd5c269fb..3034a5a6c765f1f367cb5c6e16d79a1a6346a57a 100755 (executable)
@@ -8,7 +8,7 @@
 test_description="emacs interface"
 . test-lib.sh
 
-EXPECTED=../emacs.expected-output
+EXPECTED=$TEST_DIRECTORY/emacs.expected-output
 
 add_email_corpus
 
@@ -123,13 +123,13 @@ test_emacs '(notmuch-search "id:\"123..456@example\"")
 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
 
-test_begin_subtest "Sending a message via (fake) SMTP"
 emacs_deliver_message \
     'Testing message sent via SMTP' \
     'This is a test that messages are sent via SMTP' \
     '(message-goto-to)
      (kill-whole-line)
      (insert "To: user@example.com\n")'
+
 sed \
     -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
     -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' < sent_message >OUTPUT
index bb5552450ffebb8bd1ab66fd31bb6f93278aafa6..d0b31aec115ce83b92f37b4fc3e161d9601cadb0 100755 (executable)
@@ -12,13 +12,13 @@ test_description='exception symbol hiding'
 . ./test-lib.sh
 
 run_test(){
-    result=$(LD_LIBRARY_PATH=../../lib ./symbol-test 2>&1)
+    result=$(LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib ./symbol-test 2>&1)
 }
 
 output="A Xapian exception occurred opening database: Couldn't stat 'fakedb/.notmuch/xapian'
 caught No chert database found at path \`./nonexistant'"
 
-g++ -o symbol-test -I../../lib ../symbol-test.cc -L../../lib -lnotmuch -lxapian
+g++ -o symbol-test -I$TEST_DIRECTORY/../lib $TEST_DIRECTORY/symbol-test.cc -L$TEST_DIRECTORY/../lib -lnotmuch -lxapian
 mkdir -p fakedb/.notmuch
 test_expect_success 'running test' run_test
 test_begin_subtest 'checking output'
index 48bace2c9368915d16ccaa9d9f9ec0dd67ca0e99..49522da8706e6f6c7ee6dbc8dc48e41f9eb0faef 100755 (executable)
@@ -392,7 +392,7 @@ emacs_deliver_message ()
     shift 2
     # before we can send a message, we have to prepare the FCC maildir
     mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp}
-    ../smtp-dummy sent_message &
+    $TEST_DIRECTORY/smtp-dummy sent_message &
     smtp_dummy_pid=$!
     test_emacs \
        "(let ((message-send-mail-function 'message-smtpmail-send-it)
@@ -421,12 +421,12 @@ emacs_deliver_message ()
 add_email_corpus ()
 {
     rm -rf ${MAIL_DIR}
-    if [ -d ../corpus.mail ]; then
-       cp -a ../corpus.mail ${MAIL_DIR}
+    if [ -d $TEST_DIRECTORY/corpus.mail ]; then
+       cp -a $TEST_DIRECTORY/corpus.mail ${MAIL_DIR}
     else
-       cp -a ../corpus ${MAIL_DIR}
+       cp -a $TEST_DIRECTORY/corpus ${MAIL_DIR}
        notmuch new >/dev/null
-       cp -a ${MAIL_DIR} ../corpus.mail
+       cp -a ${MAIL_DIR} $TEST_DIRECTORY/corpus.mail
     fi
 }
 
@@ -867,8 +867,8 @@ fi
 # --load               Force loading of notmuch.el and test-lib.el
 
 emacs \$BATCH --no-init-file --no-site-file \
-       --directory "$TMP_DIRECTORY/../../emacs" --load notmuch.el \
-       --directory "$TMP_DIRECTORY/.." --load test-lib.el \
+       --directory "$TEST_DIRECTORY/../emacs" --load notmuch.el \
+       --directory "$TEST_DIRECTORY" --load test-lib.el \
        --eval "(progn \$@)"
 EOF
        chmod a+x "$TMP_DIRECTORY/run_emacs"
@@ -931,11 +931,11 @@ then
                    test ! -d "$symlink_target" &&
                    test "#!" != "$(head -c 2 < "$symlink_target")"
                then
-                       symlink_target=../valgrind.sh
+                       symlink_target=$TEST_DIRECTORY/valgrind.sh
                fi
                case "$base" in
                *.sh|*.perl)
-                       symlink_target=../unprocessed-script
+                       symlink_target=$TEST_DIRECTORY/unprocessed-script
                esac
                # create the link, or replace it if it is out of date
                make_symlink "$symlink_target" "$GIT_VALGRIND/bin/$base" || exit