summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-06-07 12:05:19 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2017-06-07 13:06:17 +0300
commit453cd17f7a4be5ceaa8411a8a3ebd9fddd88df8e (patch)
tree3c919d804a8df24c01bc26854bcec4e0c5db21b6
parent491bec23a77b19df8b9c0442696ce57e3fc5c604 (diff)
downloadmailutils-453cd17f7a4be5ceaa8411a8a3ebd9fddd88df8e.tar.gz
mailutils-453cd17f7a4be5ceaa8411a8a3ebd9fddd88df8e.tar.bz2
Fix tests when logical and physical CWD differ
MH testsuite produced false negatives when run in a directory accessed by its logical name (symlink). To fix this, avoiding at the same time the use of non-portable "pwd -P" & "pwd -L", this commit adds a filter utility that replaces both logical and physical cwd with a dot on output. The MH testsuite is updated to use this utility. * testsuite/cwdrepl.c: New utility * testsuite/Makefile.am: Build cwdrepl * testsuite/.gitignore: Update. * testsuite/cwdrepl.at: New test. * testsuite/testsuite.at: Include new test. * mh/tests/atlocal.in (PATH): Add testsuite (remove_curdir): Remove function. * mh/tests/comp.at: Use cwdrepl, fix expected output. * mh/tests/forw.at: Likewise. * mh/tests/mhn.at: Likewise. * mh/tests/mhpath.at: Likewise. * mh/tests/repl.at: Likewise.
-rw-r--r--mh/tests/atlocal.in6
-rw-r--r--mh/tests/comp.at34
-rw-r--r--mh/tests/forw.at38
-rw-r--r--mh/tests/mhn.at38
-rw-r--r--mh/tests/mhpath.at30
-rw-r--r--mh/tests/repl.at12
-rw-r--r--testsuite/.gitignore1
-rw-r--r--testsuite/Makefile.am4
-rw-r--r--testsuite/cwdrepl.at59
-rw-r--r--testsuite/cwdrepl.c176
-rw-r--r--testsuite/testsuite.at1
11 files changed, 319 insertions, 80 deletions
diff --git a/mh/tests/atlocal.in b/mh/tests/atlocal.in
index 508e03f28..6a7f40528 100644
--- a/mh/tests/atlocal.in
+++ b/mh/tests/atlocal.in
@@ -1,21 +1,19 @@
# @configure_input@ -*- shell-script -*-
# Configurable variable values for Mailutils test suite.
# Copyright (C) 2004, 2010-2012, 2014-2017 Free Software Foundation,
# Inc.
-PATH=@abs_builddir@:@abs_top_builddir@/mh:$top_srcdir:$srcdir:$PATH
-remove_curdir() {
- sed "s|$HOME/*||;s| *$||" $*
-}
+PATH=@abs_builddir@:@abs_top_builddir@/testsuite:@abs_top_builddir@/mh:$top_srcdir:$srcdir:$PATH
+
# mimeflt [FILE]
# Filter out all variable information from a MIME message in FILE.
# If FILE is not given, filter stdin.
# "Variable information" means part boundary and Content-ID header values.
# These elements are likely to change between invocations of mhn -build.
#
# Stderr is redirected to /dev/null because "one true awk" (used, in
# particular, on FreeBSD) complains when closing stdin fails, even if
# it did not use it at all (it fails because stdin is closed earlier by
# MH_SETUP).
mimeflt() {
awk '
diff --git a/mh/tests/comp.at b/mh/tests/comp.at
index a8d4a4129..563310cca 100644
--- a/mh/tests/comp.at
+++ b/mh/tests/comp.at
@@ -10,190 +10,190 @@
# 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_BANNER(comp)
m4_pushdef([MH_KEYWORDS],[comp])
m4_pushdef([compcmd],[comp -editor $abs_top_srcdir/mh/tests/mhed])
MH_CHECK([comp -file],[comp00 comp-file],[
-echo quit | compcmd -file ./infile | remove_curdir | sed 's/ *$//'
+echo quit | compcmd -file $HOME/infile | cwdrepl | sed 's/ *$//'
sed 's/ *$//' infile
],
[0],
[-- Editor invocation: ./infile
-- Input file:
To:
cc:
Subject:
--------
-- Input file end
What now? draft left on "./infile".
To:
cc:
Subject:
--------
Seen by mhed
])
MH_CHECK([comp -file (del)],[comp01 comp-file_del],[
-echo 'quit -delete' | compcmd -file ./infile | remove_curdir
+echo 'quit -delete' | compcmd -file $HOME/infile | cwdrepl | sed 's/ *$//'
],
[0],
[-- Editor invocation: ./infile
-- Input file:
To:
cc:
Subject:
--------
-- Input file end
What now?
])
MH_CHECK([comp file],[comp02 comp_file],[
-echo 'quit' | compcmd file | remove_curdir | sed 's/ *$//'
+echo 'quit' | compcmd file | cwdrepl | sed 's/ *$//'
sed 's/ *$//' Mail/file
],
[0],
-[-- Editor invocation: Mail/file
+[-- Editor invocation: ./Mail/file
-- Input file:
To:
cc:
Subject:
--------
-- Input file end
-What now? draft left on "Mail/file".
+What now? draft left on "./Mail/file".
To:
cc:
Subject:
--------
Seen by mhed
])
MH_CHECK([comp -use file],[comp03 comp-use_file],[
AT_DATA([Mail/file],[From: gray
To: root
Subject: test input
message body
])
-echo 'quit' | compcmd -use file | remove_curdir | sed 's/ *$//'
+echo 'quit' | compcmd -use file | cwdrepl | sed 's/ *$//'
sed 's/ *$//' Mail/file
],
[0],
-[-- Editor invocation: Mail/file
+[-- Editor invocation: ./Mail/file
-- Input file:
From: gray
To: root
Subject: test input
message body
-- Input file end
-What now? draft left on "Mail/file".
+What now? draft left on "./Mail/file".
From: gray
To: root
Subject: test input
message body
Seen by mhed
])
MH_CHECK([comp +folder msg],[comp04 comp+folder_msg],[
mkdir Mail/inbox
AT_DATA([Mail/inbox/1],[From: gray
To: root
Subject: test input
message body
])
-echo 'quit' | compcmd +inbox 1 | remove_curdir | sed 's/ *$//'
+echo 'quit' | compcmd +inbox 1 | cwdrepl | sed 's/ *$//'
echo Mail/draft
sed 's/ *$//' Mail/draft
echo Message
sed 's/ *$//' Mail/inbox/1
],
[0],
-[-- Editor invocation: Mail/draft
+[-- Editor invocation: ./Mail/draft
-- Input file:
From: gray
To: root
Subject: test input
message body
-- Input file end
-What now? draft left on "Mail/draft".
+What now? draft left on "./Mail/draft".
Mail/draft
From: gray
To: root
Subject: test input
message body
Seen by mhed
Message
From: gray
To: root
Subject: test input
message body
])
MH_CHECK([comp -draftfolder],[comp05 comp-draftfolder draftfolder],[
mkdir Mail/drafts
-echo 'quit' | compcmd -draftfolder drafts | remove_curdir | sed 's/ *$//'
+echo 'quit' | compcmd -draftfolder drafts | cwdrepl | sed 's/ *$//'
sed 's/ *$//' Mail/drafts/1
],
[0],
-[-- Editor invocation: Mail/drafts/1
+[-- Editor invocation: ./Mail/drafts/1
-- Input file:
To:
cc:
Subject:
--------
-- Input file end
-What now? draft left on "Mail/drafts/1".
+What now? draft left on "./Mail/drafts/1".
To:
cc:
Subject:
--------
Seen by mhed
])
MH_CHECK([comp +draftfolder -use],[comp06 comp-draftfolder-use draftfolder],[
mkdir Mail/drafts
AT_DATA([Mail/drafts/1],[From: gray
To: root
Subject: test input
message body
])
echo "cur: 1" > Mail/drafts/.mh_sequences
-echo 'quit' | compcmd -draftfolder drafts -use| remove_curdir | sed 's/ *$//'
+echo 'quit' | compcmd -draftfolder drafts -use| cwdrepl | sed 's/ *$//'
sed 's/ *$//' Mail/drafts/1
],
[0],
-[-- Editor invocation: Mail/drafts/1
+[-- Editor invocation: ./Mail/drafts/1
-- Input file:
From: gray
To: root
Subject: test input
message body
-- Input file end
-What now? draft left on "Mail/drafts/1".
+What now? draft left on "./Mail/drafts/1".
From: gray
To: root
Subject: test input
message body
Seen by mhed
])
m4_popdef([compcmd])
m4_popdef([MH_KEYWORDS])
diff --git a/mh/tests/forw.at b/mh/tests/forw.at
index 4392fa2b9..e0566dfe7 100644
--- a/mh/tests/forw.at
+++ b/mh/tests/forw.at
@@ -18,51 +18,51 @@ AT_BANNER(forw)
m4_pushdef([MH_KEYWORDS],[forw])
m4_pushdef([forwcmd],[forw -editor $abs_top_srcdir/mh/tests/mhed])
MH_CHECK([forw msg],[forw00 forw-msg],[
mkdir Mail/inbox
AT_DATA([Mail/inbox/1],[From: gray
To: root
Subject: test input
message body
])
-echo quit | forwcmd +inbox 1 | remove_curdir
+echo quit | forwcmd +inbox 1 | cwdrepl
echo == Mail/draft ==
cat Mail/draft
echo == Message ==
# FIXME: AMD adds this header to the first message. Find a better way.
# See also the same sed hacks below.
sed '/^X-IMAPbase/d' Mail/inbox/1
],
[0],
-[-- Editor invocation: Mail/draft
+[-- Editor invocation: ./Mail/draft
-- Input file:
To:
cc:
Subject:
--------
------- Forwarded message
From: gray
To: root
Subject: test input
message body
------- End of Forwarded message
-- Input file end
-What now? draft left on "Mail/draft".
+What now? draft left on "./Mail/draft".
== Mail/draft ==
To:
cc:
Subject:
--------
------- Forwarded message
From: gray
To: root
Subject: test input
message body
@@ -78,51 +78,51 @@ Subject: test input
message body
])
MH_CHECK([forw -format msg],[forw01 forw-format-msg],[
mkdir Mail/inbox
AT_DATA([Mail/inbox/1],[From: gray
To: root
Subject: test input
message body
])
-echo quit | forwcmd -format +inbox 1 | remove_curdir
+echo quit | forwcmd -format +inbox 1 | cwdrepl
echo == Mail/draft ==
cat Mail/draft
echo == Message ==
# FIXME: AMD adds this header to the first message. Find a better way.
# See also the same sed hacks below.
sed '/^X-IMAPbase/d' Mail/inbox/1
],
[0],
-[-- Editor invocation: Mail/draft
+[-- Editor invocation: ./Mail/draft
-- Input file:
To:
cc:
Subject:
--------
------- Forwarded message
From: gray
To: root
Subject: test input
message body
------- End of Forwarded message
-- Input file end
-What now? draft left on "Mail/draft".
+What now? draft left on "./Mail/draft".
== Mail/draft ==
To:
cc:
Subject:
--------
------- Forwarded message
From: gray
To: root
Subject: test input
message body
@@ -144,34 +144,34 @@ AT_DATA([Mail/inbox/1],[From: gray
To: root
Subject: test input
message body
])
AT_DATA([Mail/inbox/2],[From: gray
To: marlow
Subject: 2nd message
2nd message body
])
-echo quit | forwcmd +inbox 1 2 | remove_curdir
+echo quit | forwcmd +inbox 1 2 | cwdrepl
echo == Mail/draft ==
cat Mail/draft
echo == Message 1 ==
sed '/^X-IMAPbase/d' Mail/inbox/1
echo == Message 2 ==
cat Mail/inbox/2
],
[0],
-[-- Editor invocation: Mail/draft
+[-- Editor invocation: ./Mail/draft
-- Input file:
To:
cc:
Subject:
--------
------- Forwarded messages
------- Message 1
From: gray
To: root
Subject: test input
@@ -179,25 +179,25 @@ Subject: test input
message body
------- Message 2
From: gray
To: marlow
Subject: 2nd message
2nd message body
------- End of Forwarded messages
-- Input file end
-What now? draft left on "Mail/draft".
+What now? draft left on "./Mail/draft".
== Mail/draft ==
To:
cc:
Subject:
--------
------- Forwarded messages
------- Message 1
From: gray
To: root
Subject: test input
@@ -228,25 +228,25 @@ Subject: 2nd message
2nd message body
])
MH_CHECK([forw -build msg],[forw03 forw-build-msg],[
mkdir Mail/inbox
AT_DATA([Mail/inbox/1],[From: gray
To: root
Subject: test input
message body
])
-forwcmd -build +inbox 1 | remove_curdir
+forwcmd -build +inbox 1 | cwdrepl
echo == Mail/draft ==
cat Mail/draft
echo == Message ==
sed '/^X-IMAPbase/d' Mail/inbox/1
],
[0],
[== Mail/draft ==
To:
cc:
Subject:
--------
@@ -273,39 +273,39 @@ AT_DATA([Mail/inbox/1],[From: gray
To: root
Subject: test input
message body
])
AT_DATA([Mail/inbox/2],[From: gray
To: marlow
Subject: 2nd message
2nd message body
])
-forwcmd -build -mime +inbox 1 2 | remove_curdir
+forwcmd -build -mime +inbox 1 2 | cwdrepl
echo == Mail/draft ==
-remove_curdir Mail/draft
+cwdrepl < Mail/draft
echo == Message 1 ==
sed '/^X-IMAPbase/d' Mail/inbox/1
echo == Message 2 ==
cat Mail/inbox/2
],
[0],
[== Mail/draft ==
To:
cc:
Subject:
--------
-#forw [] +Mail/inbox 1 2
+#forw [] +./Mail/inbox 1 2
== Message 1 ==
From: gray
To: root
Subject: test input
message body
== Message 2 ==
From: gray
To: marlow
Subject: 2nd message
@@ -313,49 +313,49 @@ Subject: 2nd message
])
MH_CHECK([forw -draftfolder],[forw05 forw-draftfolder draftfolder],[
mkdir Mail/inbox
mkdir Mail/drafts
AT_DATA([Mail/inbox/1],[From: gray
To: root
Subject: test input
message body
])
-echo "quit" | forwcmd -draftfolder drafts 1 | remove_curdir
+echo "quit" | forwcmd -draftfolder drafts 1 | cwdrepl
echo == Mail/drafts/1 ==
cat Mail/drafts/1
echo == Message ==
sed '/^X-IMAPbase/d' Mail/inbox/1
],
[0],
-[-- Editor invocation: Mail/drafts/1
+[-- Editor invocation: ./Mail/drafts/1
-- Input file:
To:
cc:
Subject:
--------
------- Forwarded message
From: gray
To: root
Subject: test input
message body
------- End of Forwarded message
-- Input file end
-What now? draft left on "Mail/drafts/1".
+What now? draft left on "./Mail/drafts/1".
== Mail/drafts/1 ==
To:
cc:
Subject:
--------
------- Forwarded message
From: gray
To: root
Subject: test input
message body
@@ -370,34 +370,34 @@ Subject: test input
message body
])
MH_CHECK([forw -file],[forw06 forw-file],[
AT_DATA([infile],[From: gray
To: root
Subject: test input
message body
])
-echo "quit" | forwcmd -file infile | remove_curdir
+echo "quit" | forwcmd -file infile | cwdrepl
],
[0],
-[-- Editor invocation: Mail/draft
+[-- Editor invocation: ./Mail/draft
-- Input file:
To:
cc:
Subject:
--------
From: gray
To: root
Subject: test input
message body
-- Input file end
-What now? draft left on "Mail/draft".
+What now? draft left on "./Mail/draft".
])
m4_popdef([forwcmd])
m4_popdef([MH_KEYWORDS])
# End of forw.at
diff --git a/mh/tests/mhn.at b/mh/tests/mhn.at
index 51d579abf..30755ecb7 100644
--- a/mh/tests/mhn.at
+++ b/mh/tests/mhn.at
@@ -121,39 +121,39 @@ Has lasted the rest of my life.'
That your eye was as steady as ever;
Yet you balanced an eel on the end of your nose--
What made you so awfully clever?'
`I have answered three questions, and that is enough,'
Said his father; `don't give yourself airs!
Do you think I can listen all day to such stuff?
Be off, or I'll kick you down stairs!'
])
MH_CHECK([mhn -store -auto],[mhn03 mhn-store-auto],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
-mhn +inbox -store -auto 4 | remove_curdir || exit $?
+mhn +inbox -store -auto 4 | cwdrepl || exit $?
],
[0],
-[storing message 4 part 1 as file msg.21
-storing message 4 part 2.1 as file msg.22
-storing message 4 part 2.2.1 as file msg.23
-storing message 4 part 2.2.2 as file msg.24
+[storing message 4 part 1 as file ./msg.21
+storing message 4 part 2.1 as file ./msg.22
+storing message 4 part 2.2.1 as file ./msg.23
+storing message 4 part 2.2.2 as file ./msg.24
])
MH_CHECK([mhn -store -auto -part],[mhn04 mhn-store-auto-part],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox],[700])
-mhn +inbox -store -auto -part 2.2.1 4 | remove_curdir || exit $?
+mhn +inbox -store -auto -part 2.2.1 4 | cwdrepl || exit $?
],
[0],
-[storing message 4 part 2.2.1 as file msg.23
+[storing message 4 part 2.2.1 as file ./msg.23
])
MH_CHECK([mhn -store -auto (pathname safety)],[mhn05 mhn-store-auto-safety],[
mkdir Mail/inbox
sed 's|; *name="msg|; name="../msg|' \
$abs_top_srcdir/testsuite/mh/mbox1/4 > Mail/inbox/4
MUT_MBCHMOD(Mail/inbox, 700)
mhn +inbox -store -auto -part 2.1 4 || echo $?
echo == 4.2.1.octet-stream ==
cat 4.2.1.octet-stream
],
[0],
@@ -169,94 +169,94 @@ Pray, what is the reason of that?'
By the use of this ointment--one shilling the box--
Allow me to sell you a couple?'
])
MH_CHECK([mhn-storage],[mhn06 mhn-store-auto],[
mkdir Mail/inbox
cp $abs_top_srcdir/testsuite/mh/mbox1/4 Mail/inbox
MUT_MBCHMOD(Mail/inbox, 700)
mkdir out
echo "mhn-storage: $HOME/out" >> $MH
-mhn +inbox -store 4 | remove_curdir || echo $?
+mhn +inbox -store 4 | cwdrepl || echo $?
],
[0],
-[storing message 4 part 1 as file out/4.1.plain
-storing message 4 part 2.1 as file out/4.2.1.octet-stream
-storing message 4 part 2.2.1 as file out/4.2.2.1.octet-stream
-storing message 4 part 2.2.2 as file out/4.2.2.2.octet-stream
+[storing message 4 part 1 as file ./out/4.1.plain
+storing message 4 part 2.1 as file ./out/4.2.1.octet-stream
+storing message 4 part 2.2.1 as file ./out/4.2.2.1.octet-stream
+storing message 4 part 2.2.2 as file ./out/4.2.2.2.octet-stream
])
MH_CHECK([mhn-store-: all escapes],[mhn07 mhn-store_escapes],[
mkdir Mail/inbox
cp $abs_top_srcdir/testsuite/mh/mbox1/4 Mail/inbox
MUT_MBCHMOD(Mail/inbox, 700)
echo "mhn-store-application: %%-%m%P.%s-%p" >> $MH
-mhn +inbox -store 4 | remove_curdir || exit $?
+mhn +inbox -store 4 || exit $?
find . -name '%*' | sort
],
[0],
[storing message 4 part 1 as file 4.1.plain
storing message 4 part 2.1 as file %4.2.1.octet-stream-2.1
storing message 4 part 2.2.1 as file %4.2.2.1.octet-stream-2.2.1
storing message 4 part 2.2.2 as file %4.2.2.2.octet-stream-2.2.2
./%4.2.1.octet-stream-2.1
./%4.2.2.1.octet-stream-2.2.1
./%4.2.2.2.octet-stream-2.2.2
])
MH_CHECK([mhn-store-: absolute path],[mhn08 mhn-store_abspath],[
mkdir Mail/inbox
mkdir out
cp $abs_top_srcdir/testsuite/mh/mbox1/4 Mail/inbox
MUT_MBCHMOD(Mail/inbox, 700)
echo "mhn-store-application: $HOME/out/%m%P.%s" >> $MH
-mhn +inbox -store 4 | remove_curdir || exit $?
+mhn +inbox -store 4 | cwdrepl || exit $?
],
[0],
[storing message 4 part 1 as file 4.1.plain
-storing message 4 part 2.1 as file out/4.2.1.octet-stream
-storing message 4 part 2.2.1 as file out/4.2.2.1.octet-stream
-storing message 4 part 2.2.2 as file out/4.2.2.2.octet-stream
+storing message 4 part 2.1 as file ./out/4.2.1.octet-stream
+storing message 4 part 2.2.1 as file ./out/4.2.2.1.octet-stream
+storing message 4 part 2.2.2 as file ./out/4.2.2.2.octet-stream
])
MH_CHECK([mhn-store-: +folder],[mhn09 mhn-store+folder],[
mkdir Mail/inbox
mkdir Mail/app
cp $abs_top_srcdir/testsuite/mh/mbox1/4 Mail/inbox
MUT_MBCHMOD(Mail, 700)
echo "mhn-store-application: +app" >> $MH
-mhn +inbox -store 4 | remove_curdir || exit $?
+mhn +inbox -store 4 | cwdrepl || exit $?
],
[0],
[storing message 4 part 1 as file 4.1.plain
storing message 4 part 2.1 to folder +app as message 1
storing message 4 part 2.2.1 to folder +app as message 2
storing message 4 part 2.2.2 to folder +app as message 3
])
MH_CHECK([mhn-store-: +],[mhn10 mhn-store+],[
mkdir Mail/inbox
cp $abs_top_srcdir/testsuite/mh/mbox1/4 Mail/inbox
MUT_MBCHMOD(Mail/inbox, 700)
echo "Current-Folder: inbox" > Mail/context
cat >> $MH <<EOT
mhn-store-application/octet-stream: +
EOT
-mhn +inbox -store -part 2.2.1 4 | remove_curdir || exit $?
+mhn +inbox -store -part 2.2.1 4 | cwdrepl || exit $?
],
[0],
[storing message 4 part 2.2.1 to folder inbox as message 5
])
MH_CHECK([mhn-store-: pipe],[mhn11 mhn-store-pipe],[
mkdir Mail/inbox
cp $abs_top_srcdir/testsuite/mh/mbox1/4 Mail/inbox
MUT_MBCHMOD(Mail/inbox, 700)
echo "Current-Folder: inbox" > Mail/context
echo "mhn-store-text: | $abs_top_srcdir/mh/tests/mhed -" >> $MH
diff --git a/mh/tests/mhpath.at b/mh/tests/mhpath.at
index a04868710..d07a7c765 100644
--- a/mh/tests/mhpath.at
+++ b/mh/tests/mhpath.at
@@ -11,61 +11,61 @@
# 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_BANNER(mhpath)
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 | remove_curdir
+mhpath | cwdrepl
],
[0],
-[Mail/inbox
+[./Mail/inbox
])
MH_CHECK([mhpath +],[mhpath01 mhpath+],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
echo 'Current-Folder: inbox' > Mail/context
-mhpath +| remove_curdir
+mhpath +| cwdrepl
],
[0],
-[Mail
+[./Mail
])
MH_CHECK([mhpath msgs],[mhpath02 mhparam_msgs],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
-mhpath 1-3 | remove_curdir
+mhpath 1-3 | cwdrepl
],
[0],
-[Mail/inbox/1
-Mail/inbox/2
-Mail/inbox/3
+[./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])
-mhpath 4-10 | remove_curdir
+mhpath 4-10 | cwdrepl
],
[0],
-[Mail/inbox/4
-Mail/inbox/5
+[./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])
-mhpath 8-10 | remove_curdir
+mhpath 8-10 | cwdrepl
],
[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[...]
#
@@ -78,29 +78,29 @@ mhpath 8-10 | remove_curdir
# 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])
-mhpath 10 | remove_curdir
+mhpath 10 | cwdrepl
],
[0],
[],
[mhpath: message 10 does not exist
])
MH_CHECK([mhpath new],[mhpath06 mhparam_new],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
-mhpath new | remove_curdir
+mhpath new | cwdrepl
],
[0],
-[Mail/inbox/6
+[./Mail/inbox/6
])
m4_popdef[MH_KEYWORDS])
# End of mhpath.at
diff --git a/mh/tests/repl.at b/mh/tests/repl.at
index 3520c631b..bd58e9f33 100644
--- a/mh/tests/repl.at
+++ b/mh/tests/repl.at
@@ -19,66 +19,66 @@ AT_BANNER(repl)
m4_pushdef([MH_KEYWORDS],[repl])
m4_pushdef([replcmd],[repl dnl
-editor $abs_top_srcdir/mh/tests/mhed])
MH_CHECK([repl msg],[repl00 repl-msg],[
mkdir Mail/inbox
AT_DATA([Mail/inbox/1],[From: gray@example.com
To: root@example.com
Subject: test input
message body
])
-echo "quit" | replcmd +inbox 1 | remove_curdir
+echo "quit" | replcmd +inbox 1 | cwdrepl
echo == Mail/draft ==
cat Mail/draft
],
[0],
-[-- Editor invocation: Mail/draft
+[-- Editor invocation: ./Mail/draft
-- Input file:
To: <gray@example.com>
Subject: Re: test input
X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
--------
-- Input file end
-What now? draft left on "Mail/draft".
+What now? draft left on "./Mail/draft".
== Mail/draft ==
To: <gray@example.com>
Subject: Re: test input
X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
--------
Seen by mhed
])
MH_CHECK([repl -draftfolder],[repl01 repl-draftfolder],[
mkdir Mail/inbox
mkdir Mail/drafts
AT_DATA([Mail/inbox/1],[From: gray@example.com
To: root@example.com
Subject: test input
message body
])
-echo "quit" | replcmd -draftfolder drafts +inbox 1 | remove_curdir
+echo "quit" | replcmd -draftfolder drafts +inbox 1 | cwdrepl
echo == Mail/drafts/1 ==
cat Mail/drafts/1
],
[0],
-[-- Editor invocation: Mail/drafts/1
+[-- Editor invocation: ./Mail/drafts/1
-- Input file:
To: <gray@example.com>
Subject: Re: test input
X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
--------
-- Input file end
-What now? draft left on "Mail/drafts/1".
+What now? draft left on "./Mail/drafts/1".
== Mail/drafts/1 ==
To: <gray@example.com>
Subject: Re: test input
X-Mailer: MH (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
--------
Seen by mhed
])
m4_popdef([replcmd])
m4_popdef([MH_KEYWORDS])
# End of repl.at
diff --git a/testsuite/.gitignore b/testsuite/.gitignore
index 60475e825..d58c1e299 100644
--- a/testsuite/.gitignore
+++ b/testsuite/.gitignore
@@ -1,14 +1,15 @@
atconfig
atlocal
bs
+cwdrepl
fldel
lstuid
package.m4
testsuite
testsuite.dir
testsuite.log
mbdel
mimetest
msgset
smtpsend
ufms
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 403cde207..e0eeba031 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -42,24 +42,25 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
} >$(srcdir)/package.m4
#
## -------------------------- ##
## Non-installable programs
## -------------------------- ##
AM_CPPFLAGS = @MU_LIB_COMMON_INCLUDES@
noinst_PROGRAMS = \
bs\
+ cwdrepl\
fldel\
lstuid\
mbdel\
msgset\
mimetest\
smtpsend\
ufms
LDADD = \
${MU_LIB_MBOX}\
${MU_LIB_IMAP}\
${MU_LIB_POP}\
@@ -67,29 +68,32 @@ LDADD = \
${MU_LIB_MH}\
${MU_LIB_MAILDIR}\
${MU_LIB_MAILER}\
${MU_LIB_AUTH}\
@MU_AUTHLIBS@\
${MU_LIB_MAILUTILS}
smtpsend_LDADD = \
${MU_LIB_MAILER} \
@MU_AUTHLIBS@\
${MU_LIB_MAILUTILS}
+cwdrepl_LDADD = ${MU_LIB_MAILUTILS}
+
## ------------ ##
## Test suite. ##
## ------------ ##
TESTSUITE_AT = \
+ cwdrepl.at\
fldel.at\
lstuid00.at\
lstuid01.at\
lstuid02.at\
mbdel.at\
mime.at\
smtp-msg.at\
smtp-str.at\
ufms.at\
testsuite.at
TESTSUITE = $(srcdir)/testsuite
diff --git a/testsuite/cwdrepl.at b/testsuite/cwdrepl.at
new file mode 100644
index 000000000..9cd15a903
--- /dev/null
+++ b/testsuite/cwdrepl.at
@@ -0,0 +1,59 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2017 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([cwdrepl tool])
+AT_KEYWORDS([cwdrepl])
+
+AT_CHECK([
+pwd -P >/dev/null 2>&1 || AT_SKIP_TEST
+cwd=`pwd -P`
+cwdrepl <<EOT
+$cwd
+CWD is "$cwd"
+$cwd/foo "$cwd" end
+EOT
+],
+[0],
+[.
+CWD is "."
+./foo "." end
+])
+
+AT_CHECK([
+pwd -P >/dev/null 2>&1 || AT_SKIP_TEST
+pwd -L >/dev/null 2>&1 || AT_SKIP_TEST
+mkdir physical logical
+ln -s physical logical || AT_SKIP_TEST
+cd logical
+phy=`pwd -P`
+log=`pwd -L`
+cwdrepl <<EOT
+$phy $log
+LOG is "$log", PHY is "$phy"
+$log/foo "$log" end
+$phy/foo "$phy" end
+EOT
+],
+[0],
+[. .
+LOG is ".", PHY is "."
+./foo "." end
+./foo "." end
+])
+
+AT_CLEANUP
+
+
diff --git a/testsuite/cwdrepl.c b/testsuite/cwdrepl.c
new file mode 100644
index 000000000..9f6525f18
--- /dev/null
+++ b/testsuite/cwdrepl.c
@@ -0,0 +1,176 @@
+/* This file is part of GNU Mailutils testsuite.
+ Copyright (C) 2017 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/>. */
+
+/*
+
+NAME
+
+ cwdrepl - replace occurrences of CWD with .
+
+SYNOPSIS
+
+ COMMAND | cwdrepl [DIR REPL]...
+
+DESCRIPTION
+
+ Some testcases operate programs that produce full file names as part
+ of their output. To make this output independent of the actual file
+ location, this tool replaces every occurrence of the current working
+ directory with dot. Both logical (as given by the PWD environment
+ variable) and physical (as returned by getcwd(3)) locations are replaced.
+
+ The same effect could have been achieved by using "pwd -P", "pwd -L"
+ and sed, but this would pose portability problems.
+
+ Additionally, any number of DIR REPL pairs can be supplied in the command
+ line. Each pair instructs the tool to replace every occurrence of DIR
+ with REPL on output. Note that these pairs take precedence over the
+ default ones, so running "cwdrepl $PWD 'PWD'" will replace occurrences
+ of the logical current working directory name with the string PWS, instead
+ of the default dot.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <mailutils/mailutils.h>
+
+struct dirtrans
+{
+ char *dir;
+ size_t dirlen;
+ char const *trans;
+ ssize_t translen;
+};
+
+mu_list_t translist;
+
+static int
+transcmp (const void *a, const void *b)
+{
+ struct dirtrans const *trans1 = a;