Patchwork [5,of,5,STABLE] tests: use bat script as sendmail program on Windows for test portability

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Oct. 28, 2016, 6:16 p.m.
Message ID <d9ddb5fcfe76494a324b.1477678610@juju>
Download mbox | patch
Permalink /patch/17216/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Oct. 28, 2016, 6:16 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1477678088 -32400
#      Sat Oct 29 03:08:08 2016 +0900
# Branch stable
# Node ID d9ddb5fcfe76494a324bcffb4bc4516dcc0378fb
# Parent  51b14d2127fbd214c5ec57f9c1ef17457c61f93d
tests: use bat script as sendmail program on Windows for test portability

On Windows platform, unless binding between *.sh suffix and sh.exe or
so, *.sh script can't be spawned by just name (or full path) of it.

In addition to it, mail.py of Mercurial requires that email.method
value itself can be found as an executable file on PATH.

Therefore, "sh /path/to/sendmail/script.sh" configuration doesn't work
in this case.

Patch

diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t
--- a/tests/test-patchbomb.t
+++ b/tests/test-patchbomb.t
@@ -2730,6 +2730,18 @@  dest#branch URIs:
 
 Set up a fake sendmail program
 
+#if windows
+  $ cat > $TESTTMP/t2/pretendmail.bat <<EOF
+  > @echo off
+  > echo %*
+  > cat
+  > EOF
+
+  $ cat >> $HGRCPATH <<EOF
+  > [email]
+  > method = $TESTTMP\t2\pretendmail.bat
+  > EOF
+#else
   $ cat > pretendmail.sh << 'EOF'
   > #!/bin/sh
   > echo "$@"
@@ -2739,6 +2751,7 @@  Set up a fake sendmail program
 
   $ echo '[email]' >> $HGRCPATH
   $ echo "method=`pwd`/pretendmail.sh" >> $HGRCPATH
+#endif
 
 Test introduction configuration
 =================================
@@ -2833,7 +2846,7 @@  single rev
   (should be one of always, never, auto)
   
   sending [PATCH] test ...
-  sending mail: $TESTTMP/t2/pretendmail.sh -f test foo
+  sending mail: $TESTTMP/t2/pretendmail.* -f test foo (glob)
   -f test foo
   Content-Type: text/plain; charset="us-ascii"
   MIME-Version: 1.0