changeset 10775:c52057614c72 stable

Tests with spaces in paths This allows most tests to succeed with ./run-tests.py --tmpdir='/tmp/hg test' and introduces other tests for spaces and shell quoting
author Mads Kiilerich <mads@kiilerich.com>
date Wed, 24 Mar 2010 01:43:24 +0100
parents 1e819576e926
children 08870cf7d388
files tests/test-bisect tests/test-convert tests/test-convert-hg-svn tests/test-convert-svn-move tests/test-convert-svn-source tests/test-extdiff tests/test-import tests/test-keyword tests/test-merge-tools tests/test-merge-tools.out tests/test-mq-merge tests/test-mq-merge.out tests/test-mq-qimport tests/test-progress tests/test-pull tests/test-rebase-pull tests/test-rollback tests/test-subrepo tests/test-subrepo-svn tests/test-symlinks
diffstat 20 files changed, 99 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-bisect	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-bisect	Wed Mar 24 01:43:24 2010 +0100
@@ -103,5 +103,5 @@
 hg bisect -r
 hg bisect --good tip
 hg bisect --bad 0
-hg bisect --command "`pwd`/script.py"
+hg bisect --command "'`pwd`/script.py' and some parameters"
 true
--- a/tests/test-convert	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-convert	Wed Mar 24 01:43:24 2010 +0100
@@ -49,7 +49,7 @@
 mkdir emptydir
 # override $PATH to ensure p4 not visible; use $PYTHON in case we're
 # running from a devel copy, not a temp installation
-PATH=$BINDIR $PYTHON $BINDIR/hg convert emptydir 2>&1 | sed 's,file://.*/emptydir,.../emptydir,g'
+PATH="$BINDIR" $PYTHON "$BINDIR"/hg convert emptydir 2>&1 | sed 's,file://.*/emptydir,.../emptydir,g'
 
 echo % convert with imaginary source type
 hg convert --source-type foo a a-foo
--- a/tests/test-convert-hg-svn	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-convert-hg-svn	Wed Mar 24 01:43:24 2010 +0100
@@ -12,9 +12,9 @@
 echo "mq = " >> $HGRCPATH
 
 svnpath=`pwd | fix_path`/svn-repo
-svnadmin create $svnpath
+svnadmin create "$svnpath"
 
-cat > $svnpath/hooks/pre-revprop-change <<'EOF'
+cat > "$svnpath"/hooks/pre-revprop-change <<'EOF'
 #!/bin/sh
 
 REPOS="$1"
@@ -30,19 +30,19 @@
 echo "Changing prohibited revision property" >&2
 exit 1
 EOF
-chmod +x $svnpath/hooks/pre-revprop-change
+chmod +x "$svnpath"/hooks/pre-revprop-change
 
 # SVN wants all paths to start with a slash. Unfortunately,
 # Windows ones don't. Handle that.
-svnurl=$svnpath
-expr $svnurl : "\/" > /dev/null
+svnurl="$svnpath"
+expr "$svnurl" : "\/" > /dev/null
 if [ $? -ne 0 ]; then
-    svnurl='/'$svnurl
+    svnurl="/$svnurl"
 fi
-svnurl=file://$svnurl
-svn co $svnurl $svnpath-wc
+svnurl="file://$svnurl"
+svn co "$svnurl" "$svnpath"-wc
 
-cd $svnpath-wc
+cd "$svnpath"-wc
 echo a > a
 svn add a
 svn ci -m'added a' a
@@ -50,17 +50,17 @@
 cd ..
 
 echo % initial roundtrip
-hg convert -s svn -d hg $svnpath-wc $svnpath-hg | grep -v initializing
-hg convert -s hg -d svn $svnpath-hg $svnpath-wc
+hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg | grep -v initializing
+hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc
 
 echo % second roundtrip should do nothing
-hg convert -s svn -d hg $svnpath-wc $svnpath-hg
-hg convert -s hg -d svn $svnpath-hg $svnpath-wc
+hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg
+hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc
 
 echo % new hg rev
 
-hg clone $svnpath-hg $svnpath-work
-cd $svnpath-work
+hg clone "$svnpath"-hg "$svnpath"-work
+cd "$svnpath"-work
 echo b > b
 hg add b
 hg ci -mb
@@ -70,10 +70,10 @@
 cd ..
 
 echo % echo hg to svn
-hg --cwd $svnpath-hg pull -q $svnpath-work
-hg convert -s hg -d svn $svnpath-hg $svnpath-wc
+hg --cwd "$svnpath"-hg pull -q "$svnpath"-work
+hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc
 
 echo % svn back to hg should do nothing
-hg convert -s svn -d hg $svnpath-wc $svnpath-hg
+hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg
 echo % hg back to svn should do nothing
-hg convert -s hg -d svn $svnpath-hg $svnpath-wc
+hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc
--- a/tests/test-convert-svn-move	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-convert-svn-move	Wed Mar 24 01:43:24 2010 +0100
@@ -17,14 +17,14 @@
 svnpath=`pwd | fix_path`
 # SVN wants all paths to start with a slash. Unfortunately,
 # Windows ones don't. Handle that.
-expr $svnpath : "\/" > /dev/null
+expr "$svnpath" : "\/" > /dev/null
 if [ $? -ne 0 ]; then
-    svnpath='/'$svnpath
+    svnpath="/$svnpath"
 fi
-svnurl=file://$svnpath/svn-repo
+svnurl="file://$svnpath/svn-repo"
 
 echo % convert trunk and branches
-hg convert --datesort $svnurl/subproject A-hg
+hg convert --datesort "$svnurl"/subproject A-hg
 
 cd A-hg
 hg glog --template '{rev} {desc|firstline} files: {files}\n'
--- a/tests/test-convert-svn-source	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-convert-svn-source	Wed Mar 24 01:43:24 2010 +0100
@@ -16,9 +16,9 @@
 svnpath=`pwd | fix_path`
 # SVN wants all paths to start with a slash. Unfortunately,
 # Windows ones don't. Handle that.
-expr $svnpath : "\/" > /dev/null
+expr "$svnpath" : "\/" > /dev/null
 if [ $? -ne 0 ]; then
-    svnpath='/'$svnpath
+    svnpath="/$svnpath"
 fi
 
 echo "# now tests that it works with trunk/tags layout, but no branches yet"
@@ -30,12 +30,12 @@
 mkdir tags
 cd ..
 
-svnurl=file://$svnpath/svn-repo/proj%20B
-svn import -m "init projB" projB $svnurl | fix_path
+svnurl="file://$svnpath/svn-repo/proj%20B"
+svn import -m "init projB" projB "$svnurl" | fix_path
 
 
 echo % update svn repository
-svn co $svnurl/trunk B | fix_path
+svn co "$svnurl"/trunk B | fix_path
 cd B
 echo hello > 'letter .txt'
 svn add 'letter .txt'
@@ -44,14 +44,14 @@
 "$TESTDIR/svn-safe-append.py" world 'letter .txt'
 svn ci -m world
 
-svn copy -m "tag v0.1" $svnurl/trunk $svnurl/tags/v0.1
+svn copy -m "tag v0.1" "$svnurl"/trunk "$svnurl"/tags/v0.1
 
 "$TESTDIR/svn-safe-append.py" 'nice day today!' 'letter .txt'
 svn ci -m "nice day"
 cd ..
 
 echo % convert to hg once
-hg convert $svnurl B-hg
+hg convert "$svnurl" B-hg
 
 echo % update svn repository again
 cd B
@@ -60,7 +60,7 @@
 svn add letter2.txt
 svn ci -m "second letter"
 
-svn copy -m "tag v0.2" $svnurl/trunk $svnurl/tags/v0.2
+svn copy -m "tag v0.2" "$svnurl"/trunk "$svnurl"/tags/v0.2
 
 "$TESTDIR/svn-safe-append.py" "blah-blah-blah" letter2.txt
 svn ci -m "work in progress"
@@ -69,7 +69,7 @@
 ########################################
 
 echo % test incremental conversion
-hg convert $svnurl B-hg
+hg convert "$svnurl" B-hg
 
 cd B-hg
 hg glog --template '{rev} {desc|firstline} files: {files}\n'
@@ -78,11 +78,11 @@
 
 echo % test filemap
 echo 'include letter2.txt' > filemap
-hg convert --filemap filemap $svnurl/trunk fmap
+hg convert --filemap filemap "$svnurl"/trunk fmap
 hg glog -R fmap --template '{rev} {desc|firstline} files: {files}\n'
 
 echo % test stop revision
-hg convert --rev 1 $svnurl/trunk stoprev
+hg convert --rev 1 "$svnurl"/trunk stoprev
 # Check convert_revision extra-records.
 # This is also the only place testing more than one extra field
 # in a revision.
--- a/tests/test-extdiff	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-extdiff	Wed Mar 24 01:43:24 2010 +0100
@@ -36,7 +36,7 @@
 # should diff cloned file against wc file
 hg falabala > out
 # cleanup the output since the wc is a tmp directory
-sed  's:\(.* \).*\(\/test-extdiff\):\1[tmp]\2:' out
+sed  's:\(diffing [^ ]* \).*\(\/test-extdiff\):\1[tmp]\2:' out
 # test --change option
 hg ci -d '2 0' -mtest3
 hg falabala -c 1
@@ -54,15 +54,15 @@
 hg diff --git
 echo '% edit with extdiff -p'
 # prepare custom diff/edit tool
-cat > differ.py << EOT
+cat > 'diff tool.py' << EOT
 #!/usr/bin/env python
 import time
 time.sleep(1) # avoid unchanged-timestamp problems
 file('a/a', 'ab').write('edited\n')
 file('a/b', 'ab').write('edited\n')
 EOT
-chmod +x differ.py
-hg extdiff -p `pwd`/differ.py # will change to /tmp/extdiff.TMP and populate directories a.TMP and a and start tool
+chmod +x 'diff tool.py'
+hg extdiff -p "`pwd`/diff tool.py" # will change to /tmp/extdiff.TMP and populate directories a.TMP and a and start tool
 echo '% diff in working directory, after'
 hg diff --git
 
--- a/tests/test-import	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-import	Wed Mar 24 01:43:24 2010 +0100
@@ -167,7 +167,7 @@
 dir=`pwd`
 cd b/d1/d2 2>&1 > /dev/null
 hg import  ../../../tip.patch
-cd $dir
+cd "$dir"
 echo "% message should be 'subdir change'"
 hg --cwd b tip | grep 'subdir change'
 echo "% committer should be 'someoneelse'"
--- a/tests/test-keyword	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-keyword	Wed Mar 24 01:43:24 2010 +0100
@@ -87,8 +87,8 @@
 diff a hooktest
 
 echo % removing commit hook from config
-sed -e '/\[hooks\]/,$ d' $HGRCPATH > $HGRCPATH.nohook
-mv $HGRCPATH.nohook $HGRCPATH
+sed -e '/\[hooks\]/,$ d' "$HGRCPATH" > $HGRCPATH.nohook
+mv "$HGRCPATH".nohook "$HGRCPATH"
 rm hooktest
 
 echo % bundle
@@ -115,8 +115,8 @@
 hg pull -u ../kw.hg 2>&1 | sed -e '/^Content-Type:/,/^diffs (/ d'
 
 echo % remove notify config
-sed -e '/\[hooks\]/,$ d' $HGRCPATH > $HGRCPATH.nonotify
-mv $HGRCPATH.nonotify $HGRCPATH
+sed -e '/\[hooks\]/,$ d' "$HGRCPATH" > $HGRCPATH.nonotify
+mv "$HGRCPATH".nonotify "$HGRCPATH"
 
 echo % touch
 touch a b
@@ -364,7 +364,7 @@
 echo % hg cat
 hg cat sym a b
 echo
-rm $HGRCPATH
+rm "$HGRCPATH"
 echo % cat
 cat a b
 echo % hg cat
--- a/tests/test-merge-tools	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-merge-tools	Wed Mar 24 01:43:24 2010 +0100
@@ -62,7 +62,7 @@
 echo "# hg merge -r 2"
 # override $PATH to ensure hgmerge not visible; use $PYTHON in case we're
 # running from a devel copy, not a temp installation
-PATH=$BINDIR $PYTHON $BINDIR/hg merge -r 2
+PATH="$BINDIR" $PYTHON "$BINDIR"/hg merge -r 2
 aftermerge
 
 echo "# simplest hgrc using false for merge:"
@@ -177,6 +177,17 @@
 hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $output'
 aftermerge
 
+echo '# Merge using tool with a path that must be quoted:'
+beforemerge
+cat <<EOF > 'my merge tool'
+#!/bin/sh
+cat "\$1" "\$2" "\$3" > "\$4"
+EOF
+chmod +x 'my merge tool'
+hg merge -r 2 --config merge-tools.true.executable='./my merge tool' --config merge-tools.true.args='$base $local $other $output'
+rm -f 'my merge tool'
+aftermerge
+
 
 echo
 echo Merge post-processing
--- a/tests/test-merge-tools.out	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-merge-tools.out	Wed Mar 24 01:43:24 2010 +0100
@@ -497,6 +497,25 @@
 # hg stat
 M f
 
+# Merge using tool with a path that must be quoted:
+[merge-tools]
+false.whatever=
+true.priority=1
+true.executable=cat
+# hg update -C 1
+merging f
+0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+(branch merge, don't forget to commit)
+# cat f
+revision 0
+space
+revision 1
+space
+revision 2
+space
+# hg stat
+M f
+
 
 Merge post-processing
 
--- a/tests/test-mq-merge	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-mq-merge	Wed Mar 24 01:43:24 2010 +0100
@@ -2,11 +2,6 @@
 
 # Test issue 529 - mq aborts when merging patch deleting files
 
-rewrite_path()
-{
-    sed -e 's:\\:/:g' -e 's:[^ ]*/t/::g'
-}
-
 checkundo()
 {
     if [ -f .hg/store/undo ]; then
@@ -33,7 +28,7 @@
 hg qrefresh -m "rm a"
 
 # Save the patch queue so we can merge it later
-hg qsave -c -e 2>&1 | rewrite_path
+hg qsave -c -e 2>&1 | grep -v ^copy
 checkundo qsave
 
 # Update b and commit in an "update" changeset
@@ -45,7 +40,7 @@
 # Here, qpush used to abort with :
 # The system cannot find the file specified => a
 hg manifest
-hg qpush -a -m 2>&1 | rewrite_path
+hg qpush -a -m 2>&1 | grep -v ^merging
 checkundo 'qpush -m'
 hg manifest
 
--- a/tests/test-mq-merge.out	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-mq-merge.out	Wed Mar 24 01:43:24 2010 +0100
@@ -1,12 +1,10 @@
 adding a
 adding b
-copy .hg/patches to .hg/patches.1
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 M b
 created new head
 a
 b
-merging with queue at: .hg/patches.1
 applying rm_a
 now at: rm_a
 b
--- a/tests/test-mq-qimport	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-mq-qimport	Wed Mar 24 01:43:24 2010 +0100
@@ -68,12 +68,12 @@
 rm foo
 # Under unix: file:///foobar/blah
 # Under windows: file:///c:/foobar/blah
-patchurl=`echo $HGTMP/url.diff | tr '\\\\' /`
-expr $patchurl : "\/" > /dev/null
+patchurl=`echo "$HGTMP"/url.diff | tr '\\\\' /`
+expr "$patchurl" : "\/" > /dev/null
 if [ $? -ne 0 ]; then
-    patchurl='/'$patchurl
+    patchurl="/$patchurl"
 fi
-hg qimport file://$patchurl
+hg qimport file://"$patchurl"
 hg qun
 
 echo % import patch that already exists
--- a/tests/test-progress	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-progress	Wed Mar 24 01:43:24 2010 +0100
@@ -30,7 +30,7 @@
 
 echo "[extensions]" >> $HGRCPATH
 echo "progress=" >> $HGRCPATH
-echo "loop=" `pwd`/loop.py >> $HGRCPATH
+echo "loop=`pwd`/loop.py" >> $HGRCPATH
 echo "[ui]" >> $HGRCPATH
 echo "interactive=1" >> $HGRCPATH
 
--- a/tests/test-pull	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-pull	Wed Mar 24 01:43:24 2010 +0100
@@ -32,4 +32,4 @@
 # It's tricky to make file:// URLs working on every platforms
 # with regular shell commands.
 URL=`python -c "import os; print 'file://foobar' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test'"`
-hg pull -q $URL
+hg pull -q "$URL"
--- a/tests/test-rebase-pull	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-rebase-pull	Wed Mar 24 01:43:24 2010 +0100
@@ -4,8 +4,6 @@
 echo "graphlog=" >> $HGRCPATH
 echo "rebase=" >> $HGRCPATH
 
-BASE=`pwd`
-
 addcommit () {
     echo $1 > $1
     hg add $1
@@ -16,7 +14,6 @@
     hg commit -d "${2} 0" -m $1
 }
 
-cd $BASE
 rm -rf a
 hg init a
 cd a
--- a/tests/test-rollback	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-rollback	Wed Mar 24 01:43:24 2010 +0100
@@ -42,7 +42,7 @@
 #!/bin/sh
 echo "another precious commit message" > "$1"
 __EOF__
-chmod +x $HGTMP/editor
-HGEDITOR=$HGTMP/editor hg --config hooks.pretxncommit=false commit 2>&1 | sed 's,exited with status .*,exited ...,g'
+chmod +x "$HGTMP"/editor
+HGEDITOR="'$HGTMP'"/editor hg --config hooks.pretxncommit=false commit 2>&1 | sed 's,exited with status .*,exited ...,g'
 echo '.hg/last-message.txt:'
 cat .hg/last-message.txt
--- a/tests/test-subrepo	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-subrepo	Wed Mar 24 01:43:24 2010 +0100
@@ -196,8 +196,8 @@
 hg -R nested_relative add
 hg -R nested_relative ci -mtest2
 hg init main
-echo nested_relative = ../nested_relative > main/.hgsub
-echo nested_absolute = `pwd`/nested_absolute >> main/.hgsub
+echo "nested_relative = ../nested_relative" > main/.hgsub
+echo "nested_absolute = `pwd`/nested_absolute" >> main/.hgsub
 hg -R main add
 hg -R main ci -m "add subrepos"
 cd ..
--- a/tests/test-subrepo-svn	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-subrepo-svn	Wed Mar 24 01:43:24 2010 +0100
@@ -10,11 +10,11 @@
 escapedwd=`pwd | fix_path`
 # SVN wants all paths to start with a slash. Unfortunately,
 # Windows ones don't. Handle that.
-expr $escapedwd : "\/" > /dev/null
+expr "$escapedwd" : "\/" > /dev/null
 if [ $? -ne 0 ]; then
-    escapedwd='/'$escapedwd
+    escapedwd="/$escapedwd"
 fi
-filterpath="sed s|$escapedwd|/root|"
+filterpath="s|$escapedwd|/root|"
 filtersvn='s/ in transaction.*/ is out of date/;s/Out of date: /File /'
 
 echo % create subversion repo
@@ -22,7 +22,7 @@
 SVNREPO="file://$escapedwd/svn-repo"
 WCROOT="`pwd`/svn-wc"
 svnadmin create svn-repo
-svn co $SVNREPO svn-wc
+svn co "$SVNREPO" svn-wc
 cd svn-wc
 mkdir src
 echo alpha > src/alpha
@@ -33,7 +33,7 @@
 svn ci -m 'Add alpha'
 svn up
 cat > extdef <<EOF
-externals -r1 $SVNREPO/externals
+externals -r1 "$SVNREPO/externals"
 EOF
 svn propset -F extdef svn:externals src
 svn ci -m 'Setting externals'
@@ -51,18 +51,18 @@
 
 echo % add first svn sub with leading whitespaces
 echo "s = [svn]       $SVNREPO/src" >> .hgsub
-svn co --quiet $SVNREPO/src s
+svn co --quiet "$SVNREPO"/src s
 hg add .hgsub
 hg ci -m1
 echo % debugsub
-hg debugsub | $filterpath
+hg debugsub | sed "$filterpath"
 
 echo
 echo % change file in svn and hg, commit
 echo a >> a
 echo alpha >> s/alpha
 hg commit -m 'Message!'
-hg debugsub | $filterpath
+hg debugsub | sed "$filterpath"
 
 echo
 echo a > s/a
@@ -104,4 +104,4 @@
 hg clone t tc | fix_path
 cd tc
 echo % debugsub in clone
-hg debugsub | $filterpath
+hg debugsub | sed "$filterpath"
--- a/tests/test-symlinks	Fri Mar 26 17:02:49 2010 +0100
+++ b/tests/test-symlinks	Wed Mar 24 01:43:24 2010 +0100
@@ -51,7 +51,7 @@
 cd x
 touch f
 hg add f
-hg status $p/y/f
+hg status "$p"/y/f
 
 echo '# try symlink outside repo to file inside'
 ln -s x/f ../z