Skip to content

Commit

Permalink
Add tests for m_mu module.
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandRosenfeld committed Dec 13, 2024
1 parent 6ec19b4 commit 6e46cfd
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/buildtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt install libauthen-sasl-perl libnet-ldap-perl libpalm-perl abook
- run: sudo apt install libauthen-sasl-perl libnet-ldap-perl libpalm-perl abook maildir-utils
- run: ./configure
- run: make
- run: make test
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.xx] -

### Added

- Add testsuite for m_mu.

## [0.54] - 2024-07-27

### Changed
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ top_srcdir = @top_srcdir@
abs_top_srcdir = @abs_top_srcdir@
AUTOM4TE = @AUTOM4TE@

TESTSUITE_AT = m_muttalias.at m_abook.at m_inmail.at m_vcf.at
TESTSUITE_AT = m_muttalias.at m_abook.at m_inmail.at m_vcf.at m_mu.at
EXTRA_DIST = testsuite.at testsuite $(TESTSUITE_AT)
TESTSUITE = $(srcdir)/testsuite

Expand Down
15 changes: 15 additions & 0 deletions tests/data/from-addresses
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
First1 Family1 <[email protected]>
[email protected] (First2 Family2)
<[email protected]> (First3 Family3)
"First4 Family4" <[email protected]>
[email protected] ("First5 Family5")
<[email protected]> ("First6 Family6")
<[email protected]>
[email protected]
[email protected] ()
"" <[email protected]>
Short11 <[email protected]>
"Short12" <[email protected]>
[email protected] (Short13)
[email protected] ("Short14")
Other Other <[email protected]>
9 changes: 9 additions & 0 deletions tests/data/m_mu.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
lbdbq: 8 matches
"[email protected]" "Short11" mu cfind
"[email protected]" "Short12" mu cfind
"[email protected]" "Short13" mu cfind
"[email protected]" "Short14" mu cfind
"[email protected]" "First1 Family1" mu cfind
"[email protected]" "First2 Family2" mu cfind
"[email protected]" "First4 Family4" mu cfind
"[email protected]" "First5 Family5" mu cfind
53 changes: 53 additions & 0 deletions tests/gen-maildir
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/perl
#
# Copyright (c) 2024 Roland Rosenfeld <[email protected]>
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.

use strict;
use warnings;

if ($#ARGV != 0) {
die "Usage: $0 datainputdir\n";
}

my $maildir = "maildir";
my $muhome = "muhome";
my $mailaddrfile = "$ARGV[0]/from-addresses";

system "rm -rf $maildir $muhome";
mkdir $maildir;

for my $d ('cur', 'new', 'tmp') {
mkdir "$maildir/$d";
}

open (my $fhfrom, "<", "$mailaddrfile") || die "cannot open $mailaddrfile";
my $count = 0;
while (<$fhfrom>) {
chomp;
my $filename = "$maildir/cur/$count.test:2,S";
open (my $fhmail, ">", "$filename") || die "cannot write $filename";
print $fhmail "From: $_\n";
print $fhmail "To: me\@example.org\n";
print $fhmail "Subject: test $count\n";
print $fhmail "\n\nbody\n";
close $fhmail;
$count++;
}
close $fhfrom;

system "mu init --maildir=$maildir --muhome=$muhome >/dev/null";
system "mu index --muhome=$muhome >/dev/null";
27 changes: 27 additions & 0 deletions tests/m_mu.at
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
dnl Copyright (c) 2024 Roland Rosenfeld <[email protected]>
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software Foundation,
dnl Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.

AT_BANNER([Test m_mu])
AT_SETUP(m_mu)
AT_SKIP_IF([! which mu])

AT_CHECK([perl $abs_srcdir/gen-maildir $abs_srcdir/data])
AT_CHECK([cat $abs_srcdir/data/m_mu.expected > expout])
AT_CHECK([env LBDB_OVERRIDE_METHODS=m_mu \
OVERRIDE_MU_HOME=muhome \
lbdbq example.com], [], [expout])

AT_CLEANUP
67 changes: 66 additions & 1 deletion tests/testsuite
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ at_help_all="1;m_muttalias.at:19;m_muttalias;;
11;m_vcf.at:35;m_vcf name components;;
12;m_vcf.at:43;m_vcf no realname;;
13;m_vcf.at:51;m_vcf crlf lineending;;
14;m_mu.at:18;m_mu;;
"
# List of the all the test groups.
at_groups_all=`printf "%s\n" "$at_help_all" | sed 's/;.*//'`
Expand All @@ -636,7 +637,7 @@ at_fn_validate_ranges ()
for at_grp
do
eval at_value=\$$at_grp
if test $at_value -lt 1 || test $at_value -gt 13; then
if test $at_value -lt 1 || test $at_value -gt 14; then
printf "%s\n" "invalid test group: $at_value" >&2
exit 1
fi
Expand Down Expand Up @@ -1006,6 +1007,9 @@ at_banner_text_3="Test m_inmail/fetchmail"
# Banner 4. m_vcf.at:17
# Category starts at test group 9.
at_banner_text_4="Test m_vcf"
# Banner 5. m_mu.at:17
# Category starts at test group 14.
at_banner_text_5="Test m_mu"

# Take any -C into account.
if $at_change_dir ; then
Expand Down Expand Up @@ -2808,3 +2812,64 @@ $at_traceon; }
) 5>&1 2>&1 7>&- | eval $at_tee_pipe
read at_status <"$at_status_file"
#AT_STOP_13
#AT_START_14
at_fn_group_banner 14 'm_mu.at:18' \
"m_mu" " " 5
at_xfail=no
(
printf "%s\n" "14. $at_setup_line: testing $at_desc ..."
$at_traceon

printf "%s\n" "m_mu.at:19" >"$at_check_line_file"
(! which mu) \
&& at_fn_check_skip 77 "$at_srcdir/m_mu.at:19"

{ set +x
printf "%s\n" "$at_srcdir/m_mu.at:21: perl \$abs_srcdir/gen-maildir \$abs_srcdir/data"
at_fn_check_prepare_dynamic "perl $abs_srcdir/gen-maildir $abs_srcdir/data" "m_mu.at:21"
( $at_check_trace; perl $abs_srcdir/gen-maildir $abs_srcdir/data
) >>"$at_stdout" 2>>"$at_stderr" 5>&-
at_status=$? at_failed=false
$at_check_filter
at_fn_diff_devnull "$at_stderr" || at_failed=:
at_fn_diff_devnull "$at_stdout" || at_failed=:
at_fn_check_status 0 $at_status "$at_srcdir/m_mu.at:21"
$at_failed && at_fn_log_failure
$at_traceon; }

{ set +x
printf "%s\n" "$at_srcdir/m_mu.at:22: cat \$abs_srcdir/data/m_mu.expected > expout"
at_fn_check_prepare_dynamic "cat $abs_srcdir/data/m_mu.expected > expout" "m_mu.at:22"
( $at_check_trace; cat $abs_srcdir/data/m_mu.expected > expout
) >>"$at_stdout" 2>>"$at_stderr" 5>&-
at_status=$? at_failed=false
$at_check_filter
at_fn_diff_devnull "$at_stderr" || at_failed=:
at_fn_diff_devnull "$at_stdout" || at_failed=:
at_fn_check_status 0 $at_status "$at_srcdir/m_mu.at:22"
$at_failed && at_fn_log_failure
$at_traceon; }

{ set +x
printf "%s\n" "$at_srcdir/m_mu.at:23: env LBDB_OVERRIDE_METHODS=m_mu \\
OVERRIDE_MU_HOME=muhome \\
lbdbq example.com"
at_fn_check_prepare_notrace 'an embedded newline' "m_mu.at:23"
( $at_check_trace; env LBDB_OVERRIDE_METHODS=m_mu \
OVERRIDE_MU_HOME=muhome \
lbdbq example.com
) >>"$at_stdout" 2>>"$at_stderr" 5>&-
at_status=$? at_failed=false
$at_check_filter
at_fn_diff_devnull "$at_stderr" || at_failed=:
$at_diff expout "$at_stdout" || at_failed=:
at_fn_check_status 0 $at_status "$at_srcdir/m_mu.at:23"
$at_failed && at_fn_log_failure
$at_traceon; }


set +x
$at_times_p && times >"$at_times_file"
) 5>&1 2>&1 7>&- | eval $at_tee_pipe
read at_status <"$at_status_file"
#AT_STOP_14
1 change: 1 addition & 0 deletions tests/testsuite.at
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ m4_include(m_muttalias.at)
m4_include(m_abook.at)
m4_include(m_inmail.at)
m4_include(m_vcf.at)
m4_include(m_mu.at)

0 comments on commit 6e46cfd

Please sign in to comment.