Commit 2662827c 2662827ca1abe42442d14cc3cbf08d076b3ee1ab by Sergey Poznyakoff

Add MH testsuite.

* configure.ac (mh/tests): New testdir
* mh/Makefile.am (SUBDIRS): Add tests

* tests/Makefile.am: New file.
* mh/tests/Makefile.am: New file.
* mh/tests/atlocal.in: New file.
* mh/tests/folder.at: New file.
* mh/tests/inc.at: New file.
* mh/tests/mark.at: New file.
* mh/tests/mhparam.at: New file.
* mh/tests/mhpath.at: New file.
* mh/tests/refile.at: New file.
* mh/tests/rmf.at: New file.
* mh/tests/rmm.at: New file.
* mh/tests/scan.at: New file.
* mh/tests/testsuite.at: New file.
* mh/tests/.gitignore: New file.

* testsuite/testsuite.inc (MUT_MBCOPY): Work correctly if
DST is a directory name (for MH and maildir formats).

* mh/folder.c (action_list): Treat empty value as
equal to no value.
* mh/install-mh.c (main): Honor MH environment variable.
* mh/mh_ctx.c (mh_context_read, mh_context_write): Use MU streams
instead of stdio FILE.
(mh_context_iterate): Add error checking.
Do not coredump on NULL header.
* mh/mh_global.c (_mh_init_global_sequences): Destroy sequences.
* mh/TODO: Update.

* libmailutils/stream/message_stream.c (copy_trimmed_value): New
static function.
(scan_stream): Strip final newline from the saved envelope values.

* mu/Makefile.am (BUILD_SOURCES, EXTRA_DIST): Add
mu-setup.c and mu-setup.h.
......@@ -1217,6 +1217,7 @@ AC_CONFIG_TESTDIR(maidag/tests)
AC_CONFIG_TESTDIR(messages/tests)
AC_CONFIG_TESTDIR(readmsg/tests)
AC_CONFIG_TESTDIR(sieve/tests)
AC_CONFIG_TESTDIR(mh/tests)
AC_CONFIG_FILES([libmailutils/tests/Makefile
libmailutils/tests/atlocal
......@@ -1231,7 +1232,9 @@ AC_CONFIG_FILES([libmailutils/tests/Makefile
readmsg/tests/Makefile
readmsg/tests/atlocal
sieve/tests/Makefile
sieve/tests/atlocal])
sieve/tests/atlocal
mh/tests/Makefile
mh/tests/atlocal])
AM_MISSING_PROG([AUTOM4TE], [autom4te])
dnl Make sysconfdir available to the application
......
......@@ -129,6 +129,20 @@ _message_size (mu_stream_t stream, mu_off_t *psize)
*psize -= s->envelope_length + s->mark_length;
return rc;
}
static char *
copy_trimmed_value (const char *str)
{
char *p;
size_t len;
str = mu_str_skip_class (str, MU_CTYPE_SPACE);
len = strlen (str) - 1;
p = malloc (len);
memcpy (p, str, len);
p[len] = 0;
return p;
}
static int
scan_stream (struct _mu_message_stream *str)
......@@ -180,21 +194,17 @@ scan_stream (struct _mu_message_stream *str)
if (!from && mu_c_strncasecmp (buffer, MU_HEADER_FROM,
sizeof (MU_HEADER_FROM) - 1) == 0)
from = mu_strdup (mu_str_skip_class (buffer +
sizeof (MU_HEADER_FROM),
MU_CTYPE_SPACE));
from = copy_trimmed_value (buffer + sizeof (MU_HEADER_FROM));
else if (!env_from
&& mu_c_strncasecmp (buffer, MU_HEADER_ENV_SENDER,
sizeof (MU_HEADER_ENV_SENDER) - 1) == 0)
env_from = mu_strdup (mu_str_skip_class (buffer +
sizeof (MU_HEADER_ENV_SENDER),
MU_CTYPE_SPACE));
env_from = copy_trimmed_value (buffer +
sizeof (MU_HEADER_ENV_SENDER));
else if (!env_date
&& mu_c_strncasecmp (buffer, MU_HEADER_ENV_DATE,
sizeof (MU_HEADER_ENV_DATE) - 1) == 0)
env_date = mu_strdup (mu_str_skip_class (buffer +
sizeof (MU_HEADER_ENV_DATE),
MU_CTYPE_SPACE));
env_date = copy_trimmed_value (buffer +
sizeof (MU_HEADER_ENV_DATE));
}
}
......
......@@ -15,6 +15,7 @@
## You should have received a copy of the GNU General Public License
## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
SUBDIRS = . tests
bindir = @MH_BIN_DIR@
mhlibdir = $(pkgdatadir)/mh
bin_PROGRAMS = \
......
......@@ -24,7 +24,7 @@ State Nice Utility Comments
* -20 forw --inplace,--whatnowproc
* -20 send --alias,--filter,--format,--forward,--mime,
--width
* -20 refile --link copies messages.
* -20 refile --link copies messages; rmmproc ignored.
* -20 rmm rmproc:
+ -15 folder(s)
+ -15 mhn
......@@ -34,7 +34,7 @@ State Nice Utility Comments
center,split,datefield
+ 5 mark
+ 5 pick See the README entry.
+ 10 anno
+ 10 anno -inplace
+ 10 burst See the README entry.
* 10 whom --check
+ 10 mhpath
......
......@@ -506,7 +506,7 @@ action_list ()
const char *stack = mh_global_context_get ("Folder-Stack", NULL);
printf ("%s", mh_current_folder ());
if (stack)
if (stack && stack[0])
printf (" %s", stack);
printf ("\n");
return 0;
......
......@@ -57,7 +57,7 @@ opt_handler (int key, char *arg, struct argp_state *state)
int
main (int argc, char **argv)
{
char *home, *name;
char *name;
extern int mh_auto_install;
/* Native Language Support */
......@@ -68,10 +68,17 @@ main (int argc, char **argv)
mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, NULL);
home = mu_get_homedir ();
if (!home)
abort (); /* shouldn't happen */
name = mh_safe_make_file_name (home, MH_USER_PROFILE);
name = getenv ("MH");
if (name)
name = mu_tilde_expansion (name, "/", NULL);
else
{
char *home = mu_get_homedir ();
if (!home)
abort (); /* shouldn't happen */
name = mh_safe_make_file_name (home, MH_USER_PROFILE);
free (home);
}
mh_install (name, automode);
return 0;
}
......
......@@ -80,80 +80,81 @@ mh_context_merge (mh_context_t *dst, mh_context_t *src)
int
mh_context_read (mh_context_t *ctx)
{
int status;
int rc;
char *blurb, *p;
struct stat st;
FILE *fp;
mu_stream_t stream;
mu_off_t stream_size;
char *buf = NULL;
size_t size = 0;
size_t size = 0, n;
if (!ctx)
return MU_ERR_OUT_NULL;
if (stat (ctx->name, &st))
return errno;
rc = mu_file_stream_create (&stream, ctx->name, MU_STREAM_READ);
if (rc)
return rc;
blurb = malloc (st.st_size);
if (!blurb)
return ENOMEM;
fp = fopen (ctx->name, "r");
if (!fp)
rc = mu_stream_size (stream, &stream_size);
if (rc)
{
free (blurb);
return errno;
mu_stream_destroy (&stream);
return rc;
}
blurb = malloc (stream_size + 1);
if (!blurb)
{
mu_stream_destroy (&stream);
return ENOMEM;
}
p = blurb;
while (getline (&buf, &size, fp) > 0)
while (mu_stream_getline (stream, &buf, &size, &n) == 0 && n > 0)
{
char *q;
for (q = buf; *q && mu_isspace (*q); q++)
;
char *q = mu_str_skip_class (buf, MU_CTYPE_SPACE);
if (!*q || *q == '#')
continue;
for (q = buf; *q;)
*p++ = *q++;
}
fclose (fp);
status = mu_header_create (&ctx->header, blurb, p - blurb);
mu_stream_destroy (&stream);
rc = mu_header_create (&ctx->header, blurb, p - blurb);
free (blurb);
return status;
return rc;
}
int
mh_context_write (mh_context_t *ctx)
{
mu_stream_t stream;
char buffer[512];
size_t n;
FILE *fp;
int rc;
mu_stream_t instream, outstream;
mu_off_t size;
if (!ctx)
return MU_ERR_OUT_NULL;
fp = fopen (ctx->name, "w");
if (!fp)
rc = mu_file_stream_create (&outstream, ctx->name,
MU_STREAM_WRITE|MU_STREAM_CREAT);
if (rc)
{
mu_error (_("cannot open context file %s: %s"),
ctx->name, strerror (errno));
mu_error (_("cannot open context file %s for writing: %s"),
ctx->name, mu_strerror (rc));
return MU_ERR_FAILURE;
}
/* FIXME: Use mu_stream+copy */
mu_header_get_streamref (ctx->header, &stream);
while (mu_stream_read (stream, buffer, sizeof buffer - 1, &n) == 0
&& n != 0)
mu_header_get_streamref (ctx->header, &instream);
rc = mu_stream_copy (outstream, instream, 0, &size);
if (rc)
{
buffer[n] = '\0';
fprintf (fp, "%s", buffer);
mu_error (_("error writing to context file %s: %s"),
ctx->name, mu_strerror (rc));
return MU_ERR_FAILURE;
}
mu_stream_destroy (&stream);
fclose (fp);
else
rc = mu_stream_truncate (outstream, size);
mu_stream_destroy (&instream);
mu_stream_destroy (&outstream);
return 0;
}
......@@ -194,13 +195,35 @@ mh_context_iterate (mh_context_t *ctx, mh_context_iterator fp, void *data)
if (!ctx)
return EINVAL;
mu_header_get_field_count (ctx->header, &nfields);
if (!ctx->header)
return 0;
rc = mu_header_get_field_count (ctx->header, &nfields);
if (rc)
{
mu_error (_("cannot obtain field count for context %s"), ctx->name);
return rc;
}
for (i = 1; i <= nfields && rc == 0; i++)
{
const char *name, *value;
mu_header_sget_field_name (ctx->header, i, &name);
mu_header_sget_field_value (ctx->header, i, &value);
rc = mu_header_sget_field_name (ctx->header, i, &name);
if (rc)
{
mu_error (_("cannot obtain field name for context %s:%d: %s"),
ctx->name,i,mu_strerror (rc));
break;
}
rc = mu_header_sget_field_value (ctx->header, i, &value);
if (rc)
{
mu_error (_("cannot obtain field value for context %s:%d: %s"),
ctx->name,i,mu_strerror (rc));
break;
}
rc = fp (name, value, data);
}
......
......@@ -163,7 +163,7 @@ _mh_init_global_sequences ()
void
mh_global_sequences_drop ()
{
sequences = NULL;
mh_context_destroy (&sequences);
}
const char *
......
atconfig
atlocal
package.m4
status.mf
testsuite
testsuite.dir
testsuite.log
# This file is part of GNU Mailutils.
# Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4
DISTCLEANFILES = atconfig $(check_SCRIPTS)
MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
## ------------ ##
## package.m4. ##
## ------------ ##
$(srcdir)/package.m4: $(top_srcdir)/configure.ac
$(AM_V_GEN){ \
echo '# Signature of the current package.'; \
echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \
echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \
echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \
echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
} >$(srcdir)/package.m4
#
## ------------ ##
## Test suite. ##
## ------------ ##
TESTSUITE_AT = \
folder.at\
inc.at\
mark.at\
mhparam.at\
mhpath.at\
scan.at\
refile.at\
rmf.at\
rmm.at\
testsuite.at
TESTSUITE = $(srcdir)/testsuite
M4=m4
AUTOTEST = $(AUTOM4TE) --language=autotest
$(TESTSUITE): package.m4 $(TESTSUITE_AT) $(top_srcdir)/testsuite/testsuite.inc
$(AM_V_GEN)$(AUTOTEST) -I $(srcdir) -I $(top_srcdir)/testsuite testsuite.at -o $@.tmp
$(AM_V_at)mv $@.tmp $@
atconfig: $(top_builddir)/config.status
cd $(top_builddir) && ./config.status tests/$@
clean-local:
@test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
check-local: atconfig atlocal $(TESTSUITE)
@$(SHELL) $(TESTSUITE)
# Run the test suite on the *installed* tree.
#installcheck-local:
# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
# @configure_input@ -*- shell-script -*-
# Configurable variable values for Mailutils test suite.
# Copyright (C) 2004, 2010 Free Software Foundation, Inc.
PATH=@abs_builddir@:@abs_top_builddir@/mh:$top_srcdir:$srcdir:$PATH
\ No newline at end of file
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2010 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef[MH_KEYWORDS],[folder])
MH_CHECK([folder],[folder00 folder-print],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail])
echo 'Current-Folder: inbox' > Mail/context
folder
],
[0],
[ inbox+ has 5 messages ( 1- 5).
])
MH_CHECK([folder -all],[folder01 folder-all],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail])
echo 'Current-Folder: inbox' > Mail/context
folder -all
],
[0],
[dnl
Folder # of messages ( range ) cur msg (other files)
inbox+ has 5 messages ( 1- 5).
teaparty has 95 messages ( 1- 95).
TOTAL= 100 messages in 2 folders
])
MH_CHECK([folder -all -fast],[folder02 folder-all folder-all-fast],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail])
echo 'Current-Folder: inbox' > Mail/context
folder -all -fast
],
[0],
[inbox
teaparty
])
MH_CHECK([folder +mbox],[folder03 folder+mbox],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail])
echo 'Current-Folder: inbox' > Mail/context
folder +teaparty
sed -n 's/^\(Current-Folder\): *\(.*\)/\1: \2/p' Mail/context
],
[0],
[dnl
teaparty+ has 95 messages ( 1- 95).
Current-Folder: teaparty
])
MH_CHECK([folder +mbox msg],[folder04 folder+mbox_msg],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail])
echo 'Current-Folder: inbox' > Mail/context
folder +teaparty 35
sed -n 's/^\(Current-Folder\): *\(.*\)/context: \1: \2/p' Mail/context
sed -n 's/^\(cur\): *\(.*\)/mh_sequences: \1: \2/p' Mail/teaparty/.mh_sequences
],
[0],
[dnl
teaparty+ has 95 messages ( 1- 95); cur= 35.
context: Current-Folder: teaparty
mh_sequences: cur: 35
])
MH_CHECK([folder -pack],[folder05 folder-pack],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
for i in 2 3 4 5
do
mv Mail/inbox/$i Mail/inbox/${i}0
done
folder -pack || exit $?
find Mail/inbox
],
[0],
[Mail/inbox
Mail/inbox/1
Mail/inbox/2
Mail/inbox/3
Mail/inbox/4
Mail/inbox/5
Mail/inbox/.mh_sequences
])
MH_CHECK([folder --pack=N],[folder06 folder--pack=N],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
for i in 1 2 3 4 5
do
mv Mail/inbox/$i Mail/inbox/${i}0
done
folder --pack=1 || exit $?
find Mail/inbox
],
[0],
[Mail/inbox
Mail/inbox/1
Mail/inbox/2
Mail/inbox/3
Mail/inbox/4
Mail/inbox/5
Mail/inbox/.mh_sequences
])
MH_CHECK([folder -push/-pop],[folder07 folder-push folder-pop folder-push-pop],
[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail])
folder -push +teaparty
folder -pop
folder -push +teaparty
folder -push
folder -pop
],
[0],
[teaparty inbox
inbox
teaparty inbox
inbox teaparty
teaparty
])
MH_CHECK([folder -create],[folder08 folder-create],[
folder -create +new
],
[0],
[ new+ has no messages.
])
m4_popdef[MH_KEYWORDS])
# End of folder.at
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2010 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef[MH_KEYWORDS],[inc])
MH_CHECK([inc -notruncate],[inc00 inc-notruncate],[
MUT_MBCOPY([$abs_top_srcdir/testsuite/spool/mbox1])
inc -notruncate -file ./mbox1 | sed 's/ *$//'
cmp $abs_top_srcdir/testsuite/spool/mbox1 mbox1
],
[0],
[ 1 12/28 Foo Bar <foobar@n Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar <bar@dontmail Re: Jabberwocky<<It seems very pretty, but it's
3 07/13 Sergey Poznyakoff Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
4 07/13 Sergey Poznyakoff Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
5 07/13 Sergey Poznyakoff Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
])
MH_CHECK([inc -truncate],[inc01 inc-truncate],[
MUT_MBCOPY([$abs_top_srcdir/testsuite/spool/mbox1])
inc -truncate -file ./mbox1 | sed 's/ *$//'
echo "Next"
inc -truncate -file ./mbox1 | sed 's/ *$//'
],
[0],
[ 1 12/28 Foo Bar <foobar@n Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar <bar@dontmail Re: Jabberwocky<<It seems very pretty, but it's
3 07/13 Sergey Poznyakoff Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
4 07/13 Sergey Poznyakoff Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
5 07/13 Sergey Poznyakoff Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
Next
])
MH_CHECK([inc -folder],[inc02 inc-folder],[
MUT_MBCOPY([$abs_top_srcdir/testsuite/spool/mbox1])
mkdir Mail/new
inc +new -file ./mbox1 | sed 's/ *$//'
],
[0],
[ 1 12/28 Foo Bar <foobar@n Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar <bar@dontmail Re: Jabberwocky<<It seems very pretty, but it's
3 07/13 Sergey Poznyakoff Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
4 07/13 Sergey Poznyakoff Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
5 07/13 Sergey Poznyakoff Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
])
m4_popdef[MH_KEYWORDS])
# End of inc.at
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2010 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef[MH_KEYWORDS],[mark])
MH_CHECK([mark -add],[mark00 mark-add],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo 'Current-Folder: inbox' > Mail/context
mark -sequence andro -add 2
mark -sequence andro -add 3-5
sed -n '/^andro:/{s/ */ /g;s/ $//;p}' Mail/inbox/.mh_sequences
],
[0],
[andro: 2 3 4 5
])
MH_CHECK([mark -add -zero],[mark01 mark-add-zero],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo 'Current-Folder: inbox' > Mail/context
mark -sequence andro -add 2
sed -n '/^andro:/{s/ */ /g;s/ $//;p}' Mail/inbox/.mh_sequences
mark -zero -sequence andro -add 1 3
sed -n '/^andro:/{s/ */ /g;s/ $//;p}' Mail/inbox/.mh_sequences
],
[0],
[andro: 2
andro: 1 3
])
MH_CHECK([mark -add -nopublic],[mark02 mark-add-nopublic],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo 'Current-Folder: inbox' > Mail/context
mark -nopublic -sequence andro -add 1 2 3
dir=`pwd`
sed -n '/^atr-andro/{s/ */ /g;s/ $//;s/^[[^:]]*:/atr-andro:/;p}' Mail/context
],
[0],
[atr-andro: 1 2 3
])
MH_CHECK([mark -del],[mark03 mark-del],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo 'Current-Folder: inbox' > Mail/context
echo 'andro: 2 3 4 5' > Mail/inbox/.mh_sequences
mark -sequence andro -del 3
sed -n '/^andro:/{s/ */ /g;s/ $//;p}' Mail/inbox/.mh_sequences
],
[0],
[andro: 2 4 5
])
MH_CHECK([mark -del -nopublic],[mark04 mark-del-nopublic],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo 'Current-Folder: inbox' > Mail/context
inbox=`pwd`/Mail/inbox
cat > Mail/context <<EOT
atr-andro-$inbox: 2 3 4 5
EOT
mark -nopublic -sequence andro -del 3
sed -n '/^atr-andro/{s/ */ /g;s/ $//;s/^[[^:]]*:/atr-andro:/;p}' Mail/context
],
[0],
[atr-andro: 2 4 5
])
MH_CHECK([mark -list],[mark05 mark-list],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo 'Current-Folder: inbox' > Mail/context
inbox=`pwd`/Mail/inbox
cat > Mail/context <<EOT
atr-andro-$inbox: 2 3
EOT
cat > Mail/inbox/.mh_sequences <<EOT
cur: 1
andro: 1 5
gwerz: 4
EOT
mark -list
],
[0],
[cur: 1
andro: 1 5
gwerz: 4
andro (private): 2 3
])
m4_popdef[MH_KEYWORDS])
# End of mark.at
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2010 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef[MH_KEYWORDS],[mhparam])
MH_CHECK([mhparam -all],[mhparam00 mhparam-all],[
cat >>$MH <<EOT
Sequence-Negation: not
Draft-Folder: Mail/drafts
Aliasfile: .mh_aliases
EOT
mhparam -all | tr '\t' ' ' | sed 's/^Path:.*/Path: Mail/;s/ */ /g'
],
[0],
[Path: Mail
Sequence-Negation: not
Draft-Folder: Mail/drafts
Aliasfile: .mh_aliases
])
MH_CHECK([mhparam comp],[mhparam01 mhparam_comp],[
cat >>$MH <<EOT
Sequence-Negation: not
Draft-Folder: Mail/drafts
Aliasfile: .mh_aliases
EOT
mhparam Sequence-Negation
],
[0],
[not
])
MH_CHECK([mhparam comp comp],[mhparam02 mhparam_comp_comp],[
cat >>$MH <<EOT
Sequence-Negation: not
Draft-Folder: Mail/drafts
Aliasfile: .mh_aliases
EOT
mhparam Sequence-Negation Aliasfile | tr '\t' ' '
],
[0],
[Sequence-Negation: not
Aliasfile: .mh_aliases
])
MH_CHECK([mhparam -component comp],[mhparam03 mhparam-component_comp],[
cat >>$MH <<EOT
Sequence-Negation: not
Draft-Folder: Mail/drafts
Aliasfile: .mh_aliases
EOT
mhparam -component Sequence-Negation | tr '\t' ' ' | sed 's/ */ /g'
],
[0],
[Sequence-Negation: not
])
m4_popdef[MH_KEYWORDS])
# End of mhparam.at
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2010 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef[MH_KEYWORDS],[mhpath])
MH_CHECK([mhpath],[mhpath00],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo 'Current-Folder: inbox' > Mail/context
mhpath | sed 's|^'"$dir"'/||'
],
[0],
[Mail/inbox
])
MH_CHECK([mhpath +],[mhpath01 mhpath+],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo 'Current-Folder: inbox' > Mail/context
mhpath +| sed 's|^'"$dir"'/||'
],
[0],
[Mail
])
MH_CHECK([mhpath msgs],[mhpath02 mhparam_msgs],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
dir=`pwd`
mhpath 1-3 | sed 's|^'"$dir"'/||'
],
[0],
[Mail/inbox/1
Mail/inbox/2
Mail/inbox/3
])
MH_CHECK([mhpath msgs (some nonexistent)],[mhpath03 mhparam_msgs_some_nonex],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
dir=`pwd`
mhpath 4-10 | sed 's|^'"$dir"'/||'
],
[0],
[Mail/inbox/4
Mail/inbox/5
])
MH_CHECK([mhpath msgs (all nonexistent)],[mhpath04 mhparam_msgs_all_nonex],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
dir=`pwd`
mhpath 8-10 | sed 's|^'"$dir"'/||'
],
[0],
[],
[mhpath: no messages in range 8-10
])
# FIXME: This test is dubious:
# 1. Both MH and nmh manuals claim that:
#
# 2) Within a message list, the following designations may refer to mes-
# sages that do not exist: a single numeric message name[...]
#
# However, neither mhpath implementation follows this claim. Should we?
# 2. If a single non-existent message number is given, both MH and nmh
# implementations of mhpath produce the following error message:
#
# mhpath: message N out of range X-Y
#
# The diagnostics produced by my implementation differs. This should
# be fixed, all the more that:
# 3. The rest of utilities, when given a single non-existent message number,
# produce the following error message:
#
# folder: message N doesn't exist
#
# Note the contracted negation, in place of a full one in MU diagnostics.
#
MH_CHECK([mhpath nonexistent],[mhpath05 mhparam_nonexistent],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
dir=`pwd`
mhpath 10 | sed 's|^'"$dir"'/||'
],
[0],
[],
[mhpath: message 10 does not exist
])
MH_CHECK([mhpath new],[mhpath06 mhparam_new],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
dir=`pwd`
mhpath new | sed 's|^'"$dir"'/||'
],
[0],
[Mail/inbox/6
])
m4_popdef[MH_KEYWORDS])
# End of mhpath.at
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2010 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef[MH_KEYWORDS],[refile])
MH_CHECK([refile],[refile00],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/teaparty])
echo 'Current-Folder: teaparty' > Mail/context
refile 3 4 +inbox || exit $?
find Mail/inbox -name '[[0-9]]' | sort
cmp Mail/inbox/6 Mail/teaparty/,3 >/dev/null || echo "Message 3 differs"
cmp Mail/inbox/7 Mail/teaparty/,4 >/dev/null || echo "Message 4 differs"
],
[0],
[Mail/inbox/1
Mail/inbox/2
Mail/inbox/3
Mail/inbox/4
Mail/inbox/5
Mail/inbox/6
Mail/inbox/7
])
MH_CHECK([refile -file],[refile01 refile-file],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo 'Current-Folder: inbox' > Mail/context
cp Mail/inbox/2 message
refile -file `pwd`/message +inbox || exit $?
find Mail/inbox -name '[[0-9]]' | sort
cmp Mail/inbox/2 Mail/inbox/6 >/dev/null || echo "Message differs"
],
[0],
[Mail/inbox/1
Mail/inbox/2
Mail/inbox/3
Mail/inbox/4
Mail/inbox/5
Mail/inbox/6
])
MH_CHECK([refile --copy],[refile02 refile--copy],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/teaparty])
echo 'Current-Folder: teaparty' > Mail/context
refile --copy 3 4 +inbox || exit $?
find Mail/inbox -name '[[0-9]]' | sort
cmp Mail/inbox/6 Mail/teaparty/3 >/dev/null || echo "Message 3 differs"
cmp Mail/inbox/7 Mail/teaparty/4 >/dev/null || echo "Message 4 differs"
],
[0],
[Mail/inbox/1
Mail/inbox/2
Mail/inbox/3
Mail/inbox/4
Mail/inbox/5
Mail/inbox/6
Mail/inbox/7
])
m4_popdef[MH_KEYWORDS])
# End of refile.at
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2010 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef[MH_KEYWORDS],[rmm])
MH_CHECK([rmf +folder],[rmf00 rmf+folder],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail])
echo 'Current-Folder: inbox' > Mail/context
rmf +teaparty || exit $?
find Mail -type d
],
[0],
[Mail
Mail/inbox
])
MH_CHECK([rmf],[rmf01 rmf_cur],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail])
echo 'Current-Folder: teaparty' > Mail/context
rmf || exit $?
find Mail -type d
],
[0],
[[[+inbox now current]]
Mail
Mail/inbox
])
m4_popdef[MH_KEYWORDS])
# End of rmf.at
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2010 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef[MH_KEYWORDS],[rmm])
MH_CHECK([rmm msg],[rmm00 rmm-msg],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo 'Current-Folder: inbox' > Mail/context
rmm 4 || exit $?
find Mail/inbox -name '[[0-9]]' | sort
],
[0],
[Mail/inbox/1
Mail/inbox/2
Mail/inbox/3
Mail/inbox/5
])
MH_CHECK([rmm seq],[rmm01 rmm-seq],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo 'Current-Folder: inbox' > Mail/context
cat > Mail/inbox/.mh_sequences <<EOT
test: 2 3 5
cur: 1
EOT
rmm test || exit $?
find Mail/inbox -name '[[0-9]]' | sort
sed '/^$/d' Mail/inbox/.mh_sequences
],
[0],
[Mail/inbox/1
Mail/inbox/4
test: 2 3 5
cur: 1
])
m4_popdef[MH_KEYWORDS])
# End of rmm.at
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2010 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef[MH_KEYWORDS],[scan])
MH_CHECK([scan],[scan00],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo "Current-Folder: inbox" > Mail/context
scan | sed 's/ *$//'
],
[0],
[ 1 12/28 Foo Bar <foobar@n Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar <bar@dontmail Re: Jabberwocky<<It seems very pretty, but it's
3 07/13 Sergey Poznyakoff Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
4 07/13 Sergey Poznyakoff Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
5 07/13 Sergey Poznyakoff Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
])
MH_CHECK([scan -folder],[scan01 scan-folder],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
scan +inbox | sed 's/ *$//'
],
[0],
[ 1 12/28 Foo Bar <foobar@n Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar <bar@dontmail Re: Jabberwocky<<It seems very pretty, but it's
3 07/13 Sergey Poznyakoff Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
4 07/13 Sergey Poznyakoff Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
5 07/13 Sergey Poznyakoff Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
])
MH_CHECK([scan -format],[scan02 scan-format],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail])
scan +mbox1 -format '%4(msg) %(decode(friendly{from})) - %(decode(friendly{to}))'
],
[0],
[ 1 Foo Bar <foobar@nonexistent.net> - Bar <bar@dontmailme.org>
2 Bar <bar@dontmailme.org> - Foo Bar <foobar@nonexistent.net>
3 Sergey Poznyakoff <gray@Mirddin.farlep.net> - Foo Bar <foobar@nonexistent.
4 Sergey Poznyakoff <gray@Mirddin.farlep.net> - Foo Bar <foobar@nonexistent.
5 Sergey Poznyakoff <gray@Mirddin.farlep.net> - Foo Bar <foobar@nonexistent.
])
MH_CHECK([scan -form],[scan03 scan-form],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail])
echo '%4(msg) %(decode(friendly{from})) - %(decode(friendly{to}))' > formfile
scan +mbox1 -form formfile
],
[0],
[ 1 Foo Bar <foobar@nonexistent.net> - Bar <bar@dontmailme.org>
2 Bar <bar@dontmailme.org> - Foo Bar <foobar@nonexistent.net>
3 Sergey Poznyakoff <gray@Mirddin.farlep.net> - Foo Bar <foobar@nonexistent.
4 Sergey Poznyakoff <gray@Mirddin.farlep.net> - Foo Bar <foobar@nonexistent.
5 Sergey Poznyakoff <gray@Mirddin.farlep.net> - Foo Bar <foobar@nonexistent.
])
MH_CHECK([scan -reverse],[scan04 scan-reverse],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail])
scan +mbox1 -reverse | sed 's/ *$//'
],
[0],
[ 5 07/13 Sergey Poznyakoff Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
4 07/13 Sergey Poznyakoff Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
3 07/13 Sergey Poznyakoff Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
2 12/28 Bar <bar@dontmail Re: Jabberwocky<<It seems very pretty, but it's
1 12/28 Foo Bar <foobar@n Jabberwocky<<`Twas brillig, and the slithy toves
])
m4_popdef[MH_KEYWORDS])
# End of scan.at
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2010 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
m4_include([testsuite.inc])
m4_define([MH_SETUP],[
test -d Mail || mkdir Mail
dir=`pwd`
MH=$dir/mh_profile
export MH
echo "Path: $dir/Mail" > $MH
exec <&-
])
m4_define([MH_KEYWORDS])
dnl --------------------------------------------------------------
dnl MH_CHECK(DESCR, [KW = `'], COMMANDS, [STATUS = `0'],
dnl [STDOUT = `'], [STDERR = `']
dnl
m4_define([MH_CHECK],[
AT_SETUP($1)
AT_KEYWORDS(MH_KEYWORDS[ $2])
MH_SETUP
AT_CHECK([$3],[$4],[$5],[$6])
AT_CLEANUP
])
AT_INIT
m4_include([folder.at])
m4_include([inc.at])
m4_include([scan.at])
m4_include([rmm.at])
m4_include([rmf.at])
m4_include([mark.at])
m4_include([mhparam.at])
m4_include([refile.at])
m4_include([mhpath.at])
......@@ -78,6 +78,9 @@ AM_CPPFLAGS = \
-DPYTHON_LIBS="\"$(PYTHON_LIBS)\"" \
-DI18NLIBS="\"$(LIBINTL)\""
BUILD_SOURCES=mu-setup.c mu-setup.h
EXTRA_DIST=mu-setup.c mu-setup.h
mu-setup.h: Makefile.am $(MODULES) $(IDLE_MODULES)
$(AM_V_GEN)$(AWK) -f $(top_srcdir)/mu/mu-setup.awk -v mode=h \
$(MODULES) $(IDLE_MODULES) > mu-setup.h
......
......@@ -44,14 +44,18 @@ AT_CLEANUP
])
dnl ------------------------------------------------------------
dnl MUT_MBCOPY(SRC, DST) -- Copy mailbox SRC to DST.
dnl MUT_MBCOPY(SRC, [DST = `.']) -- Copy mailbox SRC to DST.
dnl
dnl
m4_define([MUT_MBCOPY],[
m4_pushdef([__dst],[m4_if([$2],,[.],[$2])])
m4_pushdef([__basename],[m4_bregexp($1,[.*/\([^/]+\)$],\1)])
cp -r $1 __dst
chmod -R +w __dst/__basename
if test -e __dst/__basename; then
chmod -R +w __dst/__basename
else
chmod -R +w __dst
fi
m4_popdef([__basename])
m4_popdef([__dst])
])
......