Commit c2a94277 c2a942772fc73a7b6f48766982f12fbc3dee4f71 by Sergey Poznyakoff

mh: Add new tests.

* mh/mh_init.c (mh_install): Exit with code 1 on errors.
* mh/tests/install-mh.at: New file.
* mh/tests/pick.at: New file.
* mh/tests/Makefile.am (TESTSUITE_AT): Add install-mh.at, pick.at.
* mh/tests/testsuite.at: Include install-mh.at and pick.at.
1 parent 7a9a5c13
......@@ -808,13 +808,12 @@ mh_install (char *name, int automode)
else if ((st.st_mode & S_IFREG) || (st.st_mode & S_IFLNK))
{
mu_error(_("You already have an MH profile, use an editor to modify it"));
exit (0);
exit (1);
}
else
{
mu_error(_("You already have file %s which is not a regular file or a symbolic link.\n"
"Please remove it and try again"),
name);
mu_error (_("You already have file %s which is not a regular file or a symbolic link."), name);
mu_error (_("Please remove it and try again"));
exit (1);
}
}
......
......@@ -42,10 +42,12 @@ TESTSUITE_AT = \
anno.at\
folder.at\
inc.at\
install-mh.at\
mark.at\
mhl.at\
mhparam.at\
mhpath.at\
pick.at\
scan.at\
refile.at\
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/>.
AT_SETUP([install-mh -auto])
AT_KEYWORDS([install-mh install-mh00])
AT_CHECK([
mkdir home
dir=`cd home; pwd`
HOME=$dir MH=$dir/mh_profile install-mh -auto || exit $?
find home
HOME=$dir MH=$dir/mh_profile install-mh -auto 2>errout
echo $?
cat errout
],
[0],
[I'm going to create the standard MH path for you.
home
home/Mail
home/Mail/context
home/Mail/inbox
home/mh_profile
1
install-mh: You already have an MH profile, use an editor to modify it
])
AT_CLEANUP
# --------------------------------------------------
AT_SETUP([install-mh with invalid profile])
AT_KEYWORDS([install-mh install-mh01])
AT_CHECK([
mkdir home
dir=`cd home; pwd`
mkdir $dir/mh_profile
HOME=$dir MH=$dir/mh_profile install-mh -auto 2>errout
code=$?
cat errout | sed 's|[[^ ][^ ]*]/mh_profile|mh_profile|' >&2
exit $code
],
[1],
[],
[install-mh: You already have file mh_profile which is not a regular file or a symbolic link.
install-mh: Please remove it and try again
])
AT_CLEANUP
# End of install-mh.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],[pick])
MH_CHECK([pick -from],[pick00 pick-from],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
echo "Current-Folder: inbox" > Mail/context
echo "cur: 1" > Mail/inbox/.mh_sequences
pick -from dormouse
],
[0],
[17
31
49
61
65
67
69
77
79
81
83
88
89
91
92
])
MH_CHECK([pick -from -sequence],[pick01 pick-from-sequence],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
echo "Current-Folder: inbox" > Mail/context
echo "cur: 1" > Mail/inbox/.mh_sequences
pick -from dormouse -sequence dormouse || exit $?
sed -n '/^dormouse:/{s/ */ /g;s/ $//;p}' Mail/inbox/.mh_sequences
],
[0],
[dormouse: 17 31 49 61 65 67 69 77 79 81 83 88 89 91 92
])
MH_CHECK([pick -search],[pick02 pick-search],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
echo "Current-Folder: inbox" > Mail/context
echo "cur: 1" > Mail/inbox/.mh_sequences
pick -search 'Why not'
],
[0],
[91
])
MH_CHECK([pick -search regex],[pick03 pick-search-regex],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
echo "Current-Folder: inbox" > Mail/context
echo "cur: 1" > Mail/inbox/.mh_sequences
pick -search 'I.*think'
],
[0],
[36
86
93
])
MH_CHECK([pick -subject -from],[pick04 pick-subject-from],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
echo "Current-Folder: inbox" > Mail/context
echo "cur: 1" > Mail/inbox/.mh_sequences
pick -subject Story -from Dormouse
],
[0],
[61
65
67
69
77
79
81
83
88
89
91
92
])
MH_CHECK([pick -subject -and -from],[pick05 pick-subject-and-from],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
echo "Current-Folder: inbox" > Mail/context
echo "cur: 1" > Mail/inbox/.mh_sequences
pick -subject Story -and -from Dormouse
],
[0],
[61
65
67
69
77
79
81
83
88
89
91
92
])
MH_CHECK([pick -subject -or -from],[pick06 pick-subject-or-from],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
echo "Current-Folder: inbox" > Mail/context
echo "cur: 1" > Mail/inbox/.mh_sequences
pick -subject Story -or -from Dormouse
],
[0],
[17
31
49
58
59
60
61
62
63
64
65
66
67
68
69
70
76
77
78
79
80
81
82
83
85
86
87
88
89
90
91
92
93
])
MH_CHECK([pick -- default precedence],[pick07 pick-subject-and-from-or-from],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
echo "Current-Folder: inbox" > Mail/context
echo "cur: 1" > Mail/inbox/.mh_sequences
pick -subject Story -and -from Dormouse -or -from Alice
],
[0],
[2
4
6
8
10
12
14
20
25
27
29
33
36
38
40
43
45
47
51
53
55
57
59
61
63
65
66
67
68
69
70
72
74
76
77
78
79
80
81
82
83
85
87
88
89
90
91
92
93
95
])
MH_CHECK([pick -- explicit precedence (1)],[pick08 pick-expl-1],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
echo "Current-Folder: inbox" > Mail/context
echo "cur: 1" > Mail/inbox/.mh_sequences
pick -lbrace -subject Story -and -from Dormouse -rbrace -or -from Alice
],
[0],
[2
4
6
8
10
12
14
20
25
27
29
33
36
38
40
43
45
47
51
53
55
57
59
61
63
65
66
67
68
69
70
72
74
76
77
78
79
80
81
82
83
85
87
88
89
90
91
92
93
95
])
MH_CHECK([pick -- explicit precedence (2)],[pick09 pick-expl-2],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
echo "Current-Folder: inbox" > Mail/context
echo "cur: 1" > Mail/inbox/.mh_sequences
pick -subject Story -and -lbrace -from Dormouse -or -from Alice -rbrace
],
[0],
[59
61
63
65
66
67
68
69
70
76
77
78
79
80
81
82
83
85
87
88
89
90
91
92
93
])
m4_popdef[MH_KEYWORDS])
# End of pick.at
......@@ -41,6 +41,7 @@ AT_CLEANUP
AT_INIT
m4_include([install-mh.at])
m4_include([folder.at])
m4_include([inc.at])
m4_include([scan.at])
......@@ -52,3 +53,4 @@ m4_include([refile.at])
m4_include([mhpath.at])
m4_include([mhl.at])
m4_include([anno.at])
m4_include([pick.at])
......