[PATCH] Tests with spaces in paths
mads at kiilerich.com
mads at kiilerich.com
Tue Mar 23 19:48:12 CDT 2010
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1269391404 -3600
# Branch stable
# Node ID ea4b5ccfc558cb6bcacc7f5a08189ebc1a3f6dc6
# Parent 129e96f7a87aecffecc0aca9d32f4a84b609aa51
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
diff --git a/tests/test-bisect b/tests/test-bisect
--- a/tests/test-bisect
+++ b/tests/test-bisect
@@ -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
diff --git a/tests/test-convert b/tests/test-convert
--- a/tests/test-convert
+++ b/tests/test-convert
@@ -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
diff --git a/tests/test-convert-hg-svn b/tests/test-convert-hg-svn
--- a/tests/test-convert-hg-svn
+++ b/tests/test-convert-hg-svn
@@ -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
diff --git a/tests/test-convert-svn-move b/tests/test-convert-svn-move
--- a/tests/test-convert-svn-move
+++ b/tests/test-convert-svn-move
@@ -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'
diff --git a/tests/test-convert-svn-source b/tests/test-convert-svn-source
--- a/tests/test-convert-svn-source
+++ b/tests/test-convert-svn-source
@@ -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.
diff --git a/tests/test-extdiff b/tests/test-extdiff
--- a/tests/test-extdiff
+++ b/tests/test-extdiff
@@ -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
diff --git a/tests/test-import b/tests/test-import
--- a/tests/test-import
+++ b/tests/test-import
@@ -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'"
diff --git a/tests/test-keyword b/tests/test-keyword
--- a/tests/test-keyword
+++ b/tests/test-keyword
@@ -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
diff --git a/tests/test-merge-tools b/tests/test-merge-tools
--- a/tests/test-merge-tools
+++ b/tests/test-merge-tools
@@ -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
diff --git a/tests/test-merge-tools.out b/tests/test-merge-tools.out
--- a/tests/test-merge-tools.out
+++ b/tests/test-merge-tools.out
@@ -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
diff --git a/tests/test-mq-merge b/tests/test-mq-merge
--- a/tests/test-mq-merge
+++ b/tests/test-mq-merge
@@ -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
diff --git a/tests/test-mq-merge.out b/tests/test-mq-merge.out
--- a/tests/test-mq-merge.out
+++ b/tests/test-mq-merge.out
@@ -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
diff --git a/tests/test-mq-qimport b/tests/test-mq-qimport
--- a/tests/test-mq-qimport
+++ b/tests/test-mq-qimport
@@ -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
diff --git a/tests/test-progress b/tests/test-progress
--- a/tests/test-progress
+++ b/tests/test-progress
@@ -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
diff --git a/tests/test-pull b/tests/test-pull
--- a/tests/test-pull
+++ b/tests/test-pull
@@ -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"
diff --git a/tests/test-rebase-pull b/tests/test-rebase-pull
--- a/tests/test-rebase-pull
+++ b/tests/test-rebase-pull
@@ -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
diff --git a/tests/test-rollback b/tests/test-rollback
--- a/tests/test-rollback
+++ b/tests/test-rollback
@@ -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
diff --git a/tests/test-subrepo b/tests/test-subrepo
--- a/tests/test-subrepo
+++ b/tests/test-subrepo
@@ -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 ..
diff --git a/tests/test-subrepo-svn b/tests/test-subrepo-svn
--- a/tests/test-subrepo-svn
+++ b/tests/test-subrepo-svn
@@ -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"
diff --git a/tests/test-symlinks b/tests/test-symlinks
--- a/tests/test-symlinks
+++ b/tests/test-symlinks
@@ -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
More information about the Mercurial-devel
mailing list