mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-24 20:08:10 +01:00
test: Update helper functions
Modify the helper functions to work with git-based test suite i.e. 1) Quote arguments where it is necessary. 2) Do not use $NOTMUCH. It is equal to "notmuch" since $PATH is set to the build tree. 3) Modify pass_if_equal to fit into the git-based test suite. Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
This commit is contained in:
parent
223987bace
commit
04d454f582
1 changed files with 13 additions and 20 deletions
|
@ -221,10 +221,10 @@ remove_cr () {
|
||||||
increment_mtime_amount=0
|
increment_mtime_amount=0
|
||||||
increment_mtime ()
|
increment_mtime ()
|
||||||
{
|
{
|
||||||
dir=$1
|
dir="$1"
|
||||||
|
|
||||||
increment_mtime_amount=$((increment_mtime_amount + 1))
|
increment_mtime_amount=$((increment_mtime_amount + 1))
|
||||||
touch -d "+${increment_mtime_amount} seconds" $dir
|
touch -d "+${increment_mtime_amount} seconds" "$dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate a new message in the mail directory, with a unique message
|
# Generate a new message in the mail directory, with a unique message
|
||||||
|
@ -291,7 +291,7 @@ generate_message ()
|
||||||
gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
|
gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
|
||||||
else
|
else
|
||||||
gen_msg_filename="${MAIL_DIR}/${template[dir]}/$gen_msg_name"
|
gen_msg_filename="${MAIL_DIR}/${template[dir]}/$gen_msg_name"
|
||||||
mkdir -p $(dirname $gen_msg_filename)
|
mkdir -p "$(dirname "$gen_msg_filename")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${template[body]}" ]; then
|
if [ -z "${template[body]}" ]; then
|
||||||
|
@ -346,7 +346,7 @@ ${additional_headers}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
cat <<EOF >$gen_msg_filename
|
cat <<EOF >"$gen_msg_filename"
|
||||||
From: ${template[from]}
|
From: ${template[from]}
|
||||||
To: ${template[to]}
|
To: ${template[to]}
|
||||||
Message-Id: <${gen_msg_id}>
|
Message-Id: <${gen_msg_id}>
|
||||||
|
@ -357,7 +357,7 @@ ${template[body]}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Ensure that the mtime of the containing directory is updated
|
# Ensure that the mtime of the containing directory is updated
|
||||||
increment_mtime $(dirname ${gen_msg_filename})
|
increment_mtime "$(dirname "${gen_msg_filename}")"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate a new message and add it to the index.
|
# Generate a new message and add it to the index.
|
||||||
|
@ -366,41 +366,34 @@ EOF
|
||||||
# are also supported here, so see that function for details.
|
# are also supported here, so see that function for details.
|
||||||
add_message ()
|
add_message ()
|
||||||
{
|
{
|
||||||
generate_message "$@"
|
generate_message "$@" &&
|
||||||
|
notmuch new > /dev/null
|
||||||
$NOTMUCH new > /dev/null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tests=0
|
|
||||||
test_failures=0
|
|
||||||
|
|
||||||
pass_if_equal ()
|
pass_if_equal ()
|
||||||
{
|
{
|
||||||
output=$1
|
output=$1
|
||||||
expected=$2
|
expected=$2
|
||||||
|
|
||||||
tests=$((tests + 1))
|
|
||||||
|
|
||||||
if [ "$output" = "$expected" ]; then
|
if [ "$output" = "$expected" ]; then
|
||||||
echo " PASS"
|
true
|
||||||
else
|
else
|
||||||
echo " FAIL"
|
testname=$this_test.$test_count
|
||||||
testname=test-$(printf "%03d" $tests)
|
|
||||||
echo "$expected" > $testname.expected
|
echo "$expected" > $testname.expected
|
||||||
echo "$output" > $testname.output
|
echo "$output" > $testname.output
|
||||||
diff -u $testname.expected $testname.output || true
|
diff -u $testname.expected $testname.output
|
||||||
test_failures=$((test_failures + 1))
|
false
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_DIR=$(pwd)/test.$$
|
TEST_DIR=$(pwd)/test.$$
|
||||||
MAIL_DIR=${TEST_DIR}/mail
|
MAIL_DIR=${TEST_DIR}/mail
|
||||||
export NOTMUCH_CONFIG=${TEST_DIR}/notmuch-config
|
export NOTMUCH_CONFIG=${TEST_DIR}/notmuch-config
|
||||||
NOTMUCH=$(find_notmuch_binary $(pwd))
|
NOTMUCH=notmuch
|
||||||
|
|
||||||
NOTMUCH_NEW ()
|
NOTMUCH_NEW ()
|
||||||
{
|
{
|
||||||
$NOTMUCH new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'
|
notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'
|
||||||
}
|
}
|
||||||
|
|
||||||
notmuch_search_sanitize ()
|
notmuch_search_sanitize ()
|
||||||
|
|
Loading…
Reference in a new issue