summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2019-11-29 21:17:21 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-11-29 22:13:17 (GMT)
commit5ccef4cfd1eb3252430f04fa8418268a93ff8b08 (patch) (unidiff)
treefc823678dbb6131d37475f458361007a7951e277
parentb3bc4bafc0c4a26e7cdabae73564de8f3d6b2b2f (diff)
downloadmailutils-5ccef4cfd1eb3252430f04fa8418268a93ff8b08.tar.gz
mailutils-5ccef4cfd1eb3252430f04fa8418268a93ff8b08.tar.bz2
Fix the cwdrepl auxiliary tool.
Make sure the longest possible match is replaced. * testsuite/cwdrepl.c: Sort the translist by directory length, in descending order. * mail/tests/atlocal.in: Add $testsuitedir to $PATH * mail/tests/hold.at (MAIL_TEST): Use cwdrepl instead of sed rules. Correct expected outputs accordingly.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--mail/tests/atlocal.in2
-rw-r--r--mail/tests/hold.at32
-rw-r--r--testsuite/cwdrepl.c10
3 files changed, 26 insertions, 18 deletions
diff --git a/mail/tests/atlocal.in b/mail/tests/atlocal.in
index 80e3ea0..9bed5ac 100644
--- a/mail/tests/atlocal.in
+++ b/mail/tests/atlocal.in
@@ -2,7 +2,7 @@
2# Configurable variable values for Mailutils test suite. 2# Configurable variable values for Mailutils test suite.
3# Copyright (C) 2004-2019 Free Software Foundation, Inc. 3# Copyright (C) 2004-2019 Free Software Foundation, Inc.
4 4
5PATH=@abs_builddir@:@abs_top_builddir@/mail:$top_srcdir:$srcdir:$PATH 5PATH=@abs_top_builddir@/testsuite:@abs_builddir@:@abs_top_builddir@/mail:$top_srcdir:$srcdir:$PATH
6testsuitedir=@abs_top_srcdir@/testsuite 6testsuitedir=@abs_top_srcdir@/testsuite
7MALLOC_CHECK_=2 7MALLOC_CHECK_=2
8export MALLOC_CHECK_ 8export MALLOC_CHECK_
diff --git a/mail/tests/hold.at b/mail/tests/hold.at
index 1bf2531..dcd9bef 100644
--- a/mail/tests/hold.at
+++ b/mail/tests/hold.at
@@ -25,7 +25,7 @@ export MAIL=inbox
25export MBOX=mbox 25export MBOX=mbox
26> $MBOX 26> $MBOX
27CWD=$(pwd) 27CWD=$(pwd)
28MUT_MAIL_CMD -N -E "set folder=$CWD" < rc | sed -e 's/ *$//' -e "s|$CWD/||" 28MUT_MAIL_CMD -N -E "set folder=$CWD" < rc | cwdrepl | sed -e 's/ *$//'
29$3 29$3
30], 30],
31[0], 31[0],
@@ -67,8 +67,8 @@ To: Alice <alice@wonder.land>
67Subject: Invitation 67Subject: Invitation
68 68
69Have some wine 69Have some wine
70Saved 1 message in mbox 70Saved 1 message in ./mbox
71Held 1 message in inbox 71Held 1 message in ./inbox
72== inbox == 72== inbox ==
73From alice@wonder.land Mon Jul 29 22:00:09 2002 73From alice@wonder.land Mon Jul 29 22:00:09 2002
74From: Alice <alice@wonder.land> 74From: Alice <alice@wonder.land>
@@ -104,7 +104,7 @@ To: Alice <alice@wonder.land>
104Subject: Invitation 104Subject: Invitation
105 105
106Have some wine 106Have some wine
107Held 2 messages in inbox 107Held 2 messages in ./inbox
108== inbox == 108== inbox ==
109From hare@wonder.land Mon Jul 29 22:00:08 2002 109From hare@wonder.land Mon Jul 29 22:00:08 2002
110From: March Hare <hare@wonder.land> 110From: March Hare <hare@wonder.land>
@@ -136,8 +136,8 @@ catmbox mbox
136touch 1 136touch 1
137quit 137quit
138], 138],
139[Saved 1 message in mbox 139[Saved 1 message in ./mbox
140Held 1 message in inbox 140Held 1 message in ./inbox
141== inbox == 141== inbox ==
142From alice@wonder.land Mon Jul 29 22:00:09 2002 142From alice@wonder.land Mon Jul 29 22:00:09 2002
143From: Alice <alice@wonder.land> 143From: Alice <alice@wonder.land>
@@ -168,7 +168,7 @@ catmbox mbox
168touch 1 168touch 1
169quit 169quit
170], 170],
171[Held 2 messages in inbox 171[Held 2 messages in ./inbox
172== inbox == 172== inbox ==
173From hare@wonder.land Mon Jul 29 22:00:08 2002 173From hare@wonder.land Mon Jul 29 22:00:08 2002
174From: March Hare <hare@wonder.land> 174From: March Hare <hare@wonder.land>
@@ -202,8 +202,8 @@ catmbox dest
202save 1 +dest 202save 1 +dest
203quit 203quit
204], 204],
205["dest" 7/152 205["./dest" 7/152
206Held 1 message in inbox 206Held 1 message in ./inbox
207== inbox == 207== inbox ==
208From alice@wonder.land Mon Jul 29 22:00:09 2002 208From alice@wonder.land Mon Jul 29 22:00:09 2002
209From: Alice <alice@wonder.land> 209From: Alice <alice@wonder.land>
@@ -237,9 +237,9 @@ catmbox dest
237save 1 +dest 237save 1 +dest
238quit 238quit
239], 239],
240["dest" 7/152 240["./dest" 7/152
241Saved 1 message in mbox 241Saved 1 message in ./mbox
242Held 1 message in inbox 242Held 1 message in ./inbox
243== inbox == 243== inbox ==
244From alice@wonder.land Mon Jul 29 22:00:09 2002 244From alice@wonder.land Mon Jul 29 22:00:09 2002
245From: Alice <alice@wonder.land> 245From: Alice <alice@wonder.land>
@@ -280,8 +280,8 @@ catmbox dest
280save 1 +dest 280save 1 +dest
281quit 281quit
282], 282],
283["dest" 7/152 283["./dest" 7/152
284Held 2 messages in inbox 284Held 2 messages in ./inbox
285== inbox == 285== inbox ==
286From hare@wonder.land Mon Jul 29 22:00:08 2002 286From hare@wonder.land Mon Jul 29 22:00:08 2002
287From: March Hare <hare@wonder.land> 287From: March Hare <hare@wonder.land>
@@ -323,8 +323,8 @@ catmbox dest
323save 1 +dest 323save 1 +dest
324quit 324quit
325], 325],
326["dest" 7/152 326["./dest" 7/152
327Held 1 message in inbox 327Held 1 message in ./inbox
328== inbox == 328== inbox ==
329From alice@wonder.land Mon Jul 29 22:00:09 2002 329From alice@wonder.land Mon Jul 29 22:00:09 2002
330From: Alice <alice@wonder.land> 330From: Alice <alice@wonder.land>
diff --git a/testsuite/cwdrepl.c b/testsuite/cwdrepl.c
index 44fcfd7..31de06b 100644
--- a/testsuite/cwdrepl.c
+++ b/testsuite/cwdrepl.c
@@ -66,7 +66,13 @@ transcmp (const void *a, const void *b)
66{ 66{
67 struct dirtrans const *trans1 = a; 67 struct dirtrans const *trans1 = a;
68 struct dirtrans const *trans2 = b; 68 struct dirtrans const *trans2 = b;
69 return strcmp (trans1->dir, trans2->dir); 69 size_t l1 = strlen (trans1->dir);
70 size_t l2 = strlen (trans2->dir);
71 if (l1 < l2)
72 return 1;
73 else if (l1 > l2)
74 return -1;
75 return strcmp (trans2->dir, trans1->dir);
70} 76}
71 77
72static void 78static void
@@ -128,6 +134,8 @@ main (int argc, char **argv)
128 newdir (getenv ("PWD"), "."); 134 newdir (getenv ("PWD"), ".");
129 newdir (mu_getcwd (), "."); 135 newdir (mu_getcwd (), ".");
130 136
137 mu_list_sort (translist, NULL);
138
131 MU_ASSERT (mu_list_get_iterator (translist, &itr)); 139 MU_ASSERT (mu_list_get_iterator (translist, &itr));
132 while ((rc = mu_stream_getline (mu_strin, &buf, &size, &n)) == 0 && n > 0) 140 while ((rc = mu_stream_getline (mu_strin, &buf, &size, &n)) == 0 && n > 0)
133 { 141 {

Return to:

Send suggestions and report system problems to the System administrator.