tests: consistently use a HGEDITOR pattern that works with msys on windows
authorMads Kiilerich <mads@kiilerich.com>
Sun, 10 Jun 2012 14:41:14 +0200
changeset 16901 5b89700cce30
parent 16900 3f1a153daadb
child 16902 7f1cec2f63ab
tests: consistently use a HGEDITOR pattern that works with msys on windows Removing the need for an executable sh script that can be run from a native windows application enables some tests for running on windows.
tests/test-commit-amend.t
tests/test-patchbomb.t
tests/test-record.t
tests/test-rollback.t
tests/test-tag.t
--- a/tests/test-commit-amend.t	Sun Jun 10 14:14:52 2012 +0200
+++ b/tests/test-commit-amend.t	Sun Jun 10 14:41:14 2012 +0200
@@ -1,5 +1,3 @@
-  $ "$TESTDIR/hghave" execbit || exit 80
-
   $ hg init
 
 Setup:
@@ -127,13 +125,12 @@
 
 Open editor with old commit message if a message isn't given otherwise:
 
-  $ cat > editor << '__EOF__'
+  $ cat > editor.sh << '__EOF__'
   > #!/bin/sh
   > cat $1
   > echo "another precious commit message" > "$1"
   > __EOF__
-  $ chmod +x editor
-  $ HGEDITOR="'`pwd`'"/editor hg commit --amend -v
+  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
   amending changeset 2c94e4a5756f
   copying changeset 2c94e4a5756f to ad120869acf0
   no changes, new message
@@ -160,7 +157,7 @@
 Same, but with changes in working dir (different code path):
 
   $ echo a >> a
-  $ HGEDITOR="'`pwd`'"/editor hg commit --amend -v
+  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
   amending changeset ffb49186f961
   another precious commit message
   
@@ -186,7 +183,7 @@
   added 1 changesets with 1 changes to 1 files
   committed changeset 1:fb6cca43446f
 
-  $ rm editor
+  $ rm editor.sh
   $ hg log -r .
   changeset:   1:fb6cca43446f
   tag:         tip
--- a/tests/test-patchbomb.t	Sun Jun 10 14:14:52 2012 +0200
+++ b/tests/test-patchbomb.t	Sun Jun 10 14:41:14 2012 +0200
@@ -1,5 +1,3 @@
-  $ "$TESTDIR/hghave" system-sh || exit 80
-
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "patchbomb=" >> $HGRCPATH
 
@@ -141,12 +139,10 @@
 
 .hg/last-email.txt
 
-  $ cat > editor << '__EOF__'
-  > #!/bin/sh
+  $ cat > editor.sh << '__EOF__'
   > echo "a precious introductory message" > "$1"
   > __EOF__
-  $ chmod +x editor
-  $ HGEDITOR="'`pwd`'"/editor hg email -n -t foo -s test -r 0:tip > /dev/null
+  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg email -n -t foo -s test -r 0:tip > /dev/null
   $ cat .hg/last-email.txt
   a precious introductory message
 
--- a/tests/test-record.t	Sun Jun 10 14:14:52 2012 +0200
+++ b/tests/test-record.t	Sun Jun 10 14:41:14 2012 +0200
@@ -1,5 +1,3 @@
-  $ "$TESTDIR/hghave" execbit || exit 80
-
 Set up a repo
 
   $ echo "[ui]" >> $HGRCPATH
@@ -1031,12 +1029,10 @@
 
 Editing patch
 
-  $ cat > editor << '__EOF__'
-  > #!/bin/sh
+  $ cat > editor.sh << '__EOF__'
   > sed -e 7d -e '5s/^-/ /' "$1" > tmp
   > mv tmp "$1"
   > __EOF__
-  $ chmod +x editor
   $ cat > editedfile << '__EOF__'
   > This is the first line
   > This is the second line
@@ -1049,7 +1045,7 @@
   > This change will be committed
   > This is the third line
   > __EOF__
-  $ HGEDITOR="'`pwd`'"/editor hg record -d '23 0' -medit-patch-2 <<EOF
+  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg record -d '23 0' -medit-patch-2 <<EOF
   > y
   > e
   > EOF
@@ -1094,13 +1090,11 @@
   $ sed -e '3s/third/second/' -e '2s/will/will not/' -e 1d editedfile > tmp
   $ mv tmp editedfile
   $ echo "This line has been added" >> editedfile
-  $ cat > editor << '__EOF__'
-  > #!/bin/sh
+  $ cat > editor.sh << '__EOF__'
   > sed -e 's/^[-+]/ /' "$1" > tmp
   > mv tmp "$1"
   > __EOF__
-  $ chmod +x editor
-  $ HGEDITOR="'`pwd`'"/editor hg record <<EOF
+  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg record <<EOF
   > y
   > e
   > EOF
@@ -1131,13 +1125,11 @@
   $ sed -e '3s/third/second/' -e '2s/will/will not/' -e 1d editedfile > tmp
   $ mv tmp editedfile
   $ echo "This line has been added" >> editedfile
-  $ cat > editor << '__EOF__'
-  > #!/bin/sh
+  $ cat > editor.sh << '__EOF__'
   > sed s/This/That/ "$1" > tmp
   > mv tmp "$1"
   > __EOF__
-  $ chmod +x editor
-  $ HGEDITOR="'`pwd`'"/editor hg record <<EOF
+  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg record <<EOF
   > y
   > e
   > EOF
--- a/tests/test-rollback.t	Sun Jun 10 14:14:52 2012 +0200
+++ b/tests/test-rollback.t	Sun Jun 10 14:41:14 2012 +0200
@@ -110,12 +110,10 @@
 
 same thing, but run $EDITOR
 
-  $ cat > editor << '__EOF__'
-  > #!/bin/sh
+  $ cat > editor.sh << '__EOF__'
   > echo "another precious commit message" > "$1"
   > __EOF__
-  $ chmod +x editor
-  $ HGEDITOR="'`pwd`'"/editor hg --config hooks.pretxncommit=false commit 2>&1
+  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg --config hooks.pretxncommit=false commit 2>&1
   transaction abort!
   rollback completed
   note: commit message saved in .hg/last-message.txt
--- a/tests/test-tag.t	Sun Jun 10 14:14:52 2012 +0200
+++ b/tests/test-tag.t	Sun Jun 10 14:41:14 2012 +0200
@@ -1,5 +1,3 @@
-  $ "$TESTDIR/hghave" system-sh || exit 80
-
   $ hg init test
   $ cd test
 
@@ -214,13 +212,11 @@
 
 test custom commit messages
 
-  $ cat > editor << '__EOF__'
-  > #!/bin/sh
+  $ cat > editor.sh << '__EOF__'
   > echo "custom tag message" > "$1"
   > echo "second line" >> "$1"
   > __EOF__
-  $ chmod +x editor
-  $ HGEDITOR="'`pwd`'"/editor hg tag custom-tag -e
+  $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg tag custom-tag -e
   $ hg log -l1 --template "{desc}\n"
   custom tag message
   second line
@@ -235,7 +231,7 @@
   $ hg st
   M .hgtags
   ? .hgtags.orig
-  ? editor
+  ? editor.sh
   $ hg tag --local baz
   $ hg revert --no-backup .hgtags
 
@@ -305,7 +301,7 @@
 
   $ hg init repo-tag
   $ hg init repo-tag-target
-  $ hg -R repo-tag --config hooks.commit="hg push \"`pwd`/repo-tag-target\"" tag tag
+  $ hg -R repo-tag --config hooks.commit="\"hg\" push \"`pwd`/repo-tag-target\"" tag tag
   pushing to $TESTTMP/repo-tag-target
   searching for changes
   adding changesets