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) (side-by-side diff)
treefc823678dbb6131d37475f458361007a7951e277
parentb3bc4bafc0c4a26e7cdabae73564de8f3d6b2b2f (diff)
downloadmailutils-master.tar.gz
mailutils-master.tar.bz2
Fix the cwdrepl auxiliary tool.HEADmaster
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 @@
# Configurable variable values for Mailutils test suite.
# Copyright (C) 2004-2019 Free Software Foundation, Inc.
-PATH=@abs_builddir@:@abs_top_builddir@/mail:$top_srcdir:$srcdir:$PATH
+PATH=@abs_top_builddir@/testsuite:@abs_builddir@:@abs_top_builddir@/mail:$top_srcdir:$srcdir:$PATH
testsuitedir=@abs_top_srcdir@/testsuite
MALLOC_CHECK_=2
export 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
export MBOX=mbox
> $MBOX
CWD=$(pwd)
-MUT_MAIL_CMD -N -E "set folder=$CWD" < rc | sed -e 's/ *$//' -e "s|$CWD/||"
+MUT_MAIL_CMD -N -E "set folder=$CWD" < rc | cwdrepl | sed -e 's/ *$//'
$3
],
[0],
@@ -67,8 +67,8 @@ To: Alice <alice@wonder.land>
Subject: Invitation
Have some wine
-Saved 1 message in mbox
-Held 1 message in inbox
+Saved 1 message in ./mbox
+Held 1 message in ./inbox
== inbox ==
From alice@wonder.land Mon Jul 29 22:00:09 2002
From: Alice <alice@wonder.land>
@@ -104,7 +104,7 @@ To: Alice <alice@wonder.land>
Subject: Invitation
Have some wine
-Held 2 messages in inbox
+Held 2 messages in ./inbox
== inbox ==
From hare@wonder.land Mon Jul 29 22:00:08 2002
From: March Hare <hare@wonder.land>
@@ -136,8 +136,8 @@ catmbox mbox
touch 1
quit
],
-[Saved 1 message in mbox
-Held 1 message in inbox
+[Saved 1 message in ./mbox
+Held 1 message in ./inbox
== inbox ==
From alice@wonder.land Mon Jul 29 22:00:09 2002
From: Alice <alice@wonder.land>
@@ -168,7 +168,7 @@ catmbox mbox
touch 1
quit
],
-[Held 2 messages in inbox
+[Held 2 messages in ./inbox
== inbox ==
From hare@wonder.land Mon Jul 29 22:00:08 2002
From: March Hare <hare@wonder.land>
@@ -202,8 +202,8 @@ catmbox dest
save 1 +dest
quit
],
-["dest" 7/152
-Held 1 message in inbox
+["./dest" 7/152
+Held 1 message in ./inbox
== inbox ==
From alice@wonder.land Mon Jul 29 22:00:09 2002
From: Alice <alice@wonder.land>
@@ -237,9 +237,9 @@ catmbox dest
save 1 +dest
quit
],
-["dest" 7/152
-Saved 1 message in mbox
-Held 1 message in inbox
+["./dest" 7/152
+Saved 1 message in ./mbox
+Held 1 message in ./inbox
== inbox ==
From alice@wonder.land Mon Jul 29 22:00:09 2002
From: Alice <alice@wonder.land>
@@ -280,8 +280,8 @@ catmbox dest
save 1 +dest
quit
],
-["dest" 7/152
-Held 2 messages in inbox
+["./dest" 7/152
+Held 2 messages in ./inbox
== inbox ==
From hare@wonder.land Mon Jul 29 22:00:08 2002
From: March Hare <hare@wonder.land>
@@ -323,8 +323,8 @@ catmbox dest
save 1 +dest
quit
],
-["dest" 7/152
-Held 1 message in inbox
+["./dest" 7/152
+Held 1 message in ./inbox
== inbox ==
From alice@wonder.land Mon Jul 29 22:00:09 2002
From: 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)
{
struct dirtrans const *trans1 = a;
struct dirtrans const *trans2 = b;
- return strcmp (trans1->dir, trans2->dir);
+ size_t l1 = strlen (trans1->dir);
+ size_t l2 = strlen (trans2->dir);
+ if (l1 < l2)
+ return 1;
+ else if (l1 > l2)
+ return -1;
+ return strcmp (trans2->dir, trans1->dir);
}
static void
@@ -128,6 +134,8 @@ main (int argc, char **argv)
newdir (getenv ("PWD"), ".");
newdir (mu_getcwd (), ".");
+ mu_list_sort (translist, NULL);
+
MU_ASSERT (mu_list_get_iterator (translist, &itr));
while ((rc = mu_stream_getline (mu_strin, &buf, &size, &n)) == 0 && n > 0)
{

Return to:

Send suggestions and report system problems to the System administrator.