Instead of assuming that the mailstore doesn't store its absolute filenames, we use a symlink that can change back and forth. As long as filenames contain this symlink, they can work in either the real database, or the current snapshot. Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com> --- test/atomicity | 10 +++++----- test/atomicity.gdb | 11 ++++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/test/atomicity b/test/atomicity index 6df0a00..7b62ec7 100755 --- a/test/atomicity +++ b/test/atomicity @@ -49,13 +49,13 @@ if test_require_external_prereq gdb; then rm $MAIL_DIR/.remove-dir/remove-directory-duplicate:2, rmdir $MAIL_DIR/.remove-dir - # Prepare a snapshot of the updated maildir. The gdb script will - # update the database in this snapshot as it goes. + # Copy the mail database. We will run on this database concurrently. cp -ra $MAIL_DIR $MAIL_DIR.snap - cp ${NOTMUCH_CONFIG} ${NOTMUCH_CONFIG}.snap - NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap notmuch config set database.path $MAIL_DIR.snap - + # Use a symlink instead of the real path. This way, we can change the symlink, + # without filenames having to change. + mv $MAIL_DIR $MAIL_DIR.real + ln -s $MAIL_DIR.real $MAIL_DIR # Execute notmuch new and, at every call to rename, snapshot the # database, run notmuch new again on the snapshot, and capture the diff --git a/test/atomicity.gdb b/test/atomicity.gdb index fd67525..3d4e210 100644 --- a/test/atomicity.gdb +++ b/test/atomicity.gdb @@ -38,12 +38,17 @@ shell mv backtrace backtrace.`cat outcount` # Snapshot the database shell rm -r $MAIL_DIR.snap/.notmuch shell cp -r $MAIL_DIR/.notmuch $MAIL_DIR.snap/.notmuch +shell rm $MAIL_DIR +shell ln -s $MAIL_DIR.snap $MAIL_DIR # Restore the mtime of $MAIL_DIR.snap, which we just changed -shell touch -r $MAIL_DIR $MAIL_DIR.snap +shell touch -r $MAIL_DIR.real $MAIL_DIR.snap # Run notmuch new to completion on the snapshot -shell NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap XAPIAN_FLUSH_THRESHOLD=1000 notmuch new > /dev/null -shell NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap notmuch search '*' > search.`cat outcount` 2>&1 +shell NOTMUCH_CONFIG=${NOTMUCH_CONFIG} XAPIAN_FLUSH_THRESHOLD=1000 notmuch new > /dev/null +shell NOTMUCH_CONFIG=${NOTMUCH_CONFIG} notmuch search '*' > search.`cat outcount` 2>&1 shell echo $(expr $(cat outcount) + 1) > outcount +# restore symlink to correct database before resuming +shell rm $MAIL_DIR +shell ln -s $MAIL_DIR.real $MAIL_DIR cont end -- 1.7.9.5