mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 20:38:08 +01:00
test: cope with glass backend file naming variations
In several places in the test suite we intentionally corrupt the Xapian database in order to test error handling. This corruption is specific to the on-disk organization of the database, and that changed with the glass backend. We use the previously computed default backend to make the tests adapt to changing names.
This commit is contained in:
parent
deb4e5567c
commit
e311aad182
5 changed files with 10 additions and 10 deletions
|
@ -284,9 +284,9 @@ notmuch config set new.tags $OLDCONFIG
|
||||||
|
|
||||||
|
|
||||||
test_begin_subtest "Xapian exception: read only files"
|
test_begin_subtest "Xapian exception: read only files"
|
||||||
chmod u-w ${MAIL_DIR}/.notmuch/xapian/*.DB
|
chmod u-w ${MAIL_DIR}/.notmuch/xapian/*.${db_ending}
|
||||||
output=$(NOTMUCH_NEW --debug 2>&1 | sed 's/: .*$//' )
|
output=$(NOTMUCH_NEW --debug 2>&1 | sed 's/: .*$//' )
|
||||||
chmod u+w ${MAIL_DIR}/.notmuch/xapian/*.DB
|
chmod u+w ${MAIL_DIR}/.notmuch/xapian/*.${db_ending}
|
||||||
test_expect_equal "$output" "A Xapian exception occurred opening database"
|
test_expect_equal "$output" "A Xapian exception occurred opening database"
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
|
@ -95,7 +95,7 @@ test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
backup_database
|
backup_database
|
||||||
test_begin_subtest "error message for database open"
|
test_begin_subtest "error message for database open"
|
||||||
dd if=/dev/zero of="${MAIL_DIR}/.notmuch/xapian/postlist.DB" count=3
|
dd if=/dev/zero of="${MAIL_DIR}/.notmuch/xapian/postlist.${db_ending}" count=3
|
||||||
notmuch count '*' 2>OUTPUT 1>/dev/null
|
notmuch count '*' 2>OUTPUT 1>/dev/null
|
||||||
output=$(sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' OUTPUT)
|
output=$(sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' OUTPUT)
|
||||||
test_expect_equal "${output}" "A Xapian exception occurred opening database"
|
test_expect_equal "${output}" "A Xapian exception occurred opening database"
|
||||||
|
@ -105,7 +105,7 @@ cat <<EOF > count-files.gdb
|
||||||
set breakpoint pending on
|
set breakpoint pending on
|
||||||
break count_files
|
break count_files
|
||||||
commands
|
commands
|
||||||
shell cp /dev/null ${MAIL_DIR}/.notmuch/xapian/postlist.DB
|
shell cp /dev/null ${MAIL_DIR}/.notmuch/xapian/postlist.${db_ending}
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
run
|
run
|
||||||
|
|
|
@ -287,9 +287,9 @@ test_expect_code 1 "Empty tag names" 'notmuch tag + One'
|
||||||
test_expect_code 1 "Tag name beginning with -" 'notmuch tag +- One'
|
test_expect_code 1 "Tag name beginning with -" 'notmuch tag +- One'
|
||||||
|
|
||||||
test_begin_subtest "Xapian exception: read only files"
|
test_begin_subtest "Xapian exception: read only files"
|
||||||
chmod u-w ${MAIL_DIR}/.notmuch/xapian/*.DB
|
chmod u-w ${MAIL_DIR}/.notmuch/xapian/*.${db_ending}
|
||||||
output=$(notmuch tag +something '*' 2>&1 | sed 's/: .*$//' )
|
output=$(notmuch tag +something '*' 2>&1 | sed 's/: .*$//' )
|
||||||
chmod u+w ${MAIL_DIR}/.notmuch/xapian/*.DB
|
chmod u+w ${MAIL_DIR}/.notmuch/xapian/*.${db_ending}
|
||||||
test_expect_equal "$output" "A Xapian exception occurred opening database"
|
test_expect_equal "$output" "A Xapian exception occurred opening database"
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
|
@ -15,11 +15,11 @@ test_begin_subtest 'running test' run_test
|
||||||
mkdir -p ${PWD}/fakedb/.notmuch
|
mkdir -p ${PWD}/fakedb/.notmuch
|
||||||
( LD_LIBRARY_PATH="$TEST_DIRECTORY/../lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" \
|
( LD_LIBRARY_PATH="$TEST_DIRECTORY/../lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" \
|
||||||
$TEST_DIRECTORY/symbol-test ${PWD}/fakedb ${PWD}/nonexistent \
|
$TEST_DIRECTORY/symbol-test ${PWD}/fakedb ${PWD}/nonexistent \
|
||||||
2>&1 | notmuch_dir_sanitize | sed "s,\`,\',g") > OUTPUT
|
2>&1 | notmuch_dir_sanitize | sed -e "s,\`,\',g" -e "s,${NOTMUCH_DEFAULT_XAPIAN_BACKEND},backend,g") > OUTPUT
|
||||||
|
|
||||||
cat <<EOF > EXPECTED
|
cat <<EOF > EXPECTED
|
||||||
A Xapian exception occurred opening database: Couldn't stat 'CWD/fakedb/.notmuch/xapian'
|
A Xapian exception occurred opening database: Couldn't stat 'CWD/fakedb/.notmuch/xapian'
|
||||||
caught No chert database found at path 'CWD/nonexistent'
|
caught No backend database found at path 'CWD/nonexistent'
|
||||||
EOF
|
EOF
|
||||||
test_expect_equal_file EXPECTED OUTPUT
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,7 @@ Path already exists: MAIL_DIR
|
||||||
EOF
|
EOF
|
||||||
test_expect_equal_file EXPECTED OUTPUT
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
cat <<'EOF' > c_head
|
cat <<EOF > c_head
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -210,7 +210,7 @@ int main (int argc, char** argv)
|
||||||
fprintf (stderr, "error opening database: %d %s\n", stat, msg ? msg : "");
|
fprintf (stderr, "error opening database: %d %s\n", stat, msg ? msg : "");
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
path = talloc_asprintf (db, "%s/.notmuch/xapian/postlist.DB", argv[1]);
|
path = talloc_asprintf (db, "%s/.notmuch/xapian/postlist.${db_ending}", argv[1]);
|
||||||
fd = open(path,O_WRONLY|O_TRUNC);
|
fd = open(path,O_WRONLY|O_TRUNC);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf (stderr, "error opening %s\n", argv[1]);
|
fprintf (stderr, "error opening %s\n", argv[1]);
|
||||||
|
|
Loading…
Reference in a new issue