From: Felipe Contreras <felipe.contreras@gmail.com>
To: notmuch@notmuchmail.org
Cc: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Subject: [PATCH v2 2/6] test: more style fixes
Date: Sat, 15 May 2021 15:47:40 -0500 [thread overview]
Message-ID: <20210515204744.965206-3-felipe.contreras@gmail.com> (raw)
In-Reply-To: <20210515204744.965206-1-felipe.contreras@gmail.com>
In order to fit the git coding style.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
test/T140-excludes.sh | 3 +-
test/T190-multipart.sh | 3 +-
test/T490-parse-time-string.sh | 6 +--
test/export-dirs.sh | 3 +-
test/test-lib-common.sh | 6 +--
test/test-lib.sh | 78 ++++++++++++----------------------
6 files changed, 33 insertions(+), 66 deletions(-)
diff --git a/test/T140-excludes.sh b/test/T140-excludes.sh
index acab5381..352b3eb8 100755
--- a/test/T140-excludes.sh
+++ b/test/T140-excludes.sh
@@ -5,8 +5,7 @@ test_description='"notmuch search, count and show" with excludes in several vari
# Generates a thread consisting of a top level message and 'length'
# replies. The subject of the top message 'subject: top message"
# and the subject of the nth reply in the thread is "subject: reply n"
-generate_thread ()
-{
+generate_thread () {
local subject="$1"
local length="$2"
generate_message '[subject]="'"${subject}: top message"'"' '[body]="'"body of top message"'"'
diff --git a/test/T190-multipart.sh b/test/T190-multipart.sh
index 6f715ff9..3545a599 100755
--- a/test/T190-multipart.sh
+++ b/test/T190-multipart.sh
@@ -725,8 +725,7 @@ EOF
notmuch new > /dev/null
-cat_expected_head ()
-{
+cat_expected_head () {
cat <<EOF
[[[{"id": "htmlmessage", "match":true, "excluded": false, "date_relative":"2000-01-01",
"crypto": {},
diff --git a/test/T490-parse-time-string.sh b/test/T490-parse-time-string.sh
index d1c70cfa..f89755ed 100755
--- a/test/T490-parse-time-string.sh
+++ b/test/T490-parse-time-string.sh
@@ -4,13 +4,11 @@ test_description="date/time parser module"
# Sanity/smoke tests for the date/time parser independent of notmuch
-_date ()
-{
+_date () {
date -d "$*" +%s
}
-_parse_time ()
-{
+_parse_time () {
${TEST_DIRECTORY}/parse-time --format=%s "$*"
}
diff --git a/test/export-dirs.sh b/test/export-dirs.sh
index 844ee682..0a048e1f 100644
--- a/test/export-dirs.sh
+++ b/test/export-dirs.sh
@@ -9,8 +9,7 @@ if [[ -z "${NOTMUCH_SRCDIR}" ]]; then
export NOTMUCH_SRCDIR="$(cd "$(dirname "$0")"/.. && pwd)"
fi
-find_builddir ()
-{
+find_builddir () {
local dir="$1"
while [[ -n "$dir" ]] && [[ "$dir" != "/" ]]; do
diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh
index 2f7950ac..ebbf4cdf 100644
--- a/test/test-lib-common.sh
+++ b/test/test-lib-common.sh
@@ -105,8 +105,7 @@ fi
gen_msg_cnt=0
gen_msg_filename=""
gen_msg_id=""
-generate_message ()
-{
+generate_message () {
# This is our (bash-specific) magic for doing named parameters
local -A template="($@)"
local additional_headers
@@ -225,8 +224,7 @@ EOF
#
# All of the arguments and return values supported by generate_message
# are also supported here, so see that function for details.
-add_message ()
-{
+add_message () {
generate_message "$@" &&
notmuch new > /dev/null
}
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 3147b782..c1395c87 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -120,8 +120,7 @@ test_require_emacs () {
test_require_external_prereq dtach
}
-add_gnupg_home ()
-{
+add_gnupg_home () {
[ -e "${GNUPGHOME}/gpg.conf" ] && return
_gnupg_exit () { gpgconf --kill all 2>/dev/null || true; }
at_exit_function _gnupg_exit
@@ -141,8 +140,7 @@ add_gnupg_home ()
printf '%s:6:\n' "$FINGERPRINT" | gpg --quiet --batch --no-tty --import-ownertrust
}
-add_gpgsm_home ()
-{
+add_gpgsm_home () {
local fpr
[ -e "$GNUPGHOME/gpgsm.conf" ] && return
_gnupg_exit () { gpgconf --kill all 2>/dev/null || true; }
@@ -274,8 +272,7 @@ then
fi
test_description_printed=
-print_test_description ()
-{
+print_test_description () {
test -z "$test_description_printed" || return 0
echo
echo $this_test: "Testing ${test_description}"
@@ -355,8 +352,7 @@ trap 'trap_signal' HUP INT TERM
# Accepts arbitrary extra emacs/elisp functions to modify the message
# before sending, which is useful to doing things like attaching files
# to the message and encrypting/signing.
-emacs_deliver_message ()
-{
+emacs_deliver_message () {
local subject body smtp_dummy_pid smtp_dummy_port
subject="$1"
body="$2"
@@ -402,8 +398,7 @@ emacs_deliver_message ()
# If any GNU-style long-arguments (like --quiet or --decrypt=true) are
# at the head of the argument list, they are sent directly to "notmuch
# new" after message delivery
-emacs_fcc_message ()
-{
+emacs_fcc_message () {
local nmn_args subject body
nmn_args=''
while [[ "$1" =~ ^-- ]]; do
@@ -441,8 +436,7 @@ emacs_fcc_message ()
# history of the notmuch mailing list, which allows for reliably
# testing commands that need to operate on a not-totally-trivial
# number of messages.
-add_email_corpus ()
-{
+add_email_corpus () {
local corpus
corpus=${1:-default}
@@ -451,8 +445,7 @@ add_email_corpus ()
notmuch new >/dev/null || die "'notmuch new' failed while adding email corpus"
}
-test_begin_subtest ()
-{
+test_begin_subtest () {
if [ -n "$inside_subtest" ]; then
exec 1>&6 2>&7 # Restore stdout and stderr
error "bug in test script: Missing test_expect_equal in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}"
@@ -472,8 +465,7 @@ test_begin_subtest ()
# not accept a test name. Instead, the caller should call
# test_begin_subtest before calling this function in order to set the
# name.
-test_expect_equal ()
-{
+test_expect_equal () {
local output expected testname
exec 1>&6 2>&7 # Restore stdout and stderr
if [ -z "$inside_subtest" ]; then
@@ -499,8 +491,7 @@ test_expect_equal ()
}
# Like test_expect_equal, but takes two filenames.
-test_expect_equal_file ()
-{
+test_expect_equal_file () {
local file1 file2 testname basename1 basename2
exec 1>&6 2>&7 # Restore stdout and stderr
if [ -z "$inside_subtest" ]; then
@@ -616,19 +607,16 @@ test_emacs_expect_t () {
fi
}
-NOTMUCH_NEW ()
-{
+NOTMUCH_NEW () {
notmuch new "${@}" | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'
}
-NOTMUCH_DUMP_TAGS ()
-{
+NOTMUCH_DUMP_TAGS () {
# this relies on the default format being batch-tag, otherwise some tests will break
notmuch dump --include=tags "${@}" | sed '/^#/d' | sort
}
-notmuch_drop_mail_headers ()
-{
+notmuch_drop_mail_headers () {
$NOTMUCH_PYTHON -c '
import email, sys
msg = email.message_from_file(sys.stdin)
@@ -637,41 +625,34 @@ print(msg.as_string(False))
' "$@"
}
-notmuch_exception_sanitize ()
-{
+notmuch_exception_sanitize () {
perl -pe 's/(A Xapian exception occurred at .*[.]cc?):([0-9]*)/\1:XXX/'
}
-notmuch_search_sanitize ()
-{
+notmuch_search_sanitize () {
perl -pe 's/("?thread"?: ?)("?)................("?)/\1\2XXX\3/'
}
-notmuch_search_files_sanitize ()
-{
+notmuch_search_files_sanitize () {
notmuch_dir_sanitize
}
-notmuch_dir_sanitize ()
-{
+notmuch_dir_sanitize () {
sed -e "s,$MAIL_DIR,MAIL_DIR," -e "s,${PWD},CWD,g" "$@"
}
NOTMUCH_SHOW_FILENAME_SQUELCH='s,filename:.*/mail,filename:/XXX/mail,'
-notmuch_show_sanitize ()
-{
+notmuch_show_sanitize () {
sed -e "$NOTMUCH_SHOW_FILENAME_SQUELCH"
}
-notmuch_show_sanitize_all ()
-{
+notmuch_show_sanitize_all () {
sed \
-e 's| filename:.*| filename:XXXXX|' \
-e 's| id:[^ ]* | id:XXXXX |' | \
notmuch_date_sanitize
}
-notmuch_json_show_sanitize ()
-{
+notmuch_json_show_sanitize () {
sed \
-e 's|"id": "[^"]*",|"id": "XXXXX",|g' \
-e 's|"Date": "Fri, 05 Jan 2001 [^"]*0000"|"Date": "GENERATED_DATE"|g' \
@@ -681,8 +662,7 @@ notmuch_json_show_sanitize ()
-e 's|"content-length": [1-9][0-9]*|"content-length": "NONZERO"|g'
}
-notmuch_emacs_error_sanitize ()
-{
+notmuch_emacs_error_sanitize () {
local command
command=$1
shift
@@ -694,24 +674,20 @@ notmuch_emacs_error_sanitize ()
-e "s|^\(command: \)\{0,1\}/.*/$command|\1YYY/$command|"
}
-notmuch_date_sanitize ()
-{
+notmuch_date_sanitize () {
sed \
-e 's/^Date: Fri, 05 Jan 2001 .*0000/Date: GENERATED_DATE/'
}
-notmuch_uuid_sanitize ()
-{
+notmuch_uuid_sanitize () {
sed 's/[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/UUID/g'
}
-notmuch_built_with_sanitize ()
-{
+notmuch_built_with_sanitize () {
sed 's/^built_with[.]\(.*\)=.*$/built_with.\1=something/'
}
-notmuch_passwd_sanitize ()
-{
+notmuch_passwd_sanitize () {
${NOTMUCH_PYTHON} -c'
import os, sys, pwd, socket
@@ -731,13 +707,11 @@ for l in sys.stdin:
'
}
-notmuch_config_sanitize ()
-{
+notmuch_config_sanitize () {
notmuch_dir_sanitize | notmuch_built_with_sanitize
}
-notmuch_show_part ()
-{
+notmuch_show_part () {
awk '/^\014part}/{ f=0 }; { if (f) { print $0 } } /^\014part{ ID: '"$1"'/{ f=1 }'
}
--
2.31.1
next prev parent reply other threads:[~2021-05-15 20:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-15 20:47 [PATCH v2 0/6] test: several cleanups Felipe Contreras
2021-05-15 20:47 ` [PATCH v2 1/6] test: trivial style cleanups Felipe Contreras
2021-05-15 20:47 ` Felipe Contreras [this message]
2021-05-16 12:08 ` [PATCH v2 2/6] test: more style fixes David Bremner
2021-05-16 18:16 ` Felipe Contreras
2021-05-17 11:16 ` David Bremner
2021-05-15 20:47 ` [PATCH v2 3/6] test: emacs: simplify missing dependencies check Felipe Contreras
2021-05-15 20:47 ` [PATCH v2 4/6] test: emacs: check for configured emacs Felipe Contreras
2021-05-15 20:47 ` [PATCH v2 5/6] test: emacs: fix a couple of shellcheck complaints Felipe Contreras
2021-05-15 20:47 ` [PATCH v2 6/6] test: split emacs functionality to its own file Felipe Contreras
2021-05-17 11:17 ` [PATCH v2 0/6] test: several cleanups David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210515204744.965206-3-felipe.contreras@gmail.com \
--to=felipe.contreras@gmail.com \
--cc=dkg@fifthhorseman.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).