Mercurial > hg-stable
changeset 16965:91284af53508
test-alias: adapt for Windows
The test used 'echo' to test '!' style aliases. On Windows 'echo' is handled
by cmd and thus behaves very differently from the 'normal' echo command.
The simple workaround used here for using the same alias on all platforms
is to use 'printf' instead. Msys 'printf' will also handle sh quoting and
escaping in cmd.
Environment variable expansion with sh syntax is handled by launching sh.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Sat, 16 Jun 2012 21:57:42 +0200 |
parents | eecaeeca2106 |
children | 23f621ca04b5 |
files | contrib/check-code.py tests/test-alias.t |
diffstat | 2 files changed, 19 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/check-code.py Fri Jun 15 21:42:47 2012 +0200 +++ b/contrib/check-code.py Sat Jun 16 21:57:42 2012 +0200 @@ -47,7 +47,7 @@ (r'\W\$?\(\([^\)\n]*\)\)', "don't use (()) or $(()), use 'expr'"), (r'grep.*-q', "don't use 'grep -q', redirect to /dev/null"), (r'sed.*-i', "don't use 'sed -i', use a temporary file"), - (r'echo.*\\n', "don't use 'echo \\n', use printf"), + (r'\becho\b.*\\n', "don't use 'echo \\n', use printf"), (r'echo -n', "don't use 'echo -n', use printf"), (r'(^| )wc[^|]*$\n(?!.*\(re\))', "filter wc output"), (r'head -c', "don't use 'head -c', use 'dd'"),
--- a/tests/test-alias.t Fri Jun 15 21:42:47 2012 +0200 +++ b/tests/test-alias.t Sat Jun 16 21:57:42 2012 +0200 @@ -1,5 +1,3 @@ - $ "$TESTDIR/hghave" system-sh || exit 80 - $ HGFOO=BAR; export HGFOO $ cat >> $HGRCPATH <<EOF > [extensions] @@ -26,14 +24,14 @@ > dln = lognull --debug > nousage = rollback > put = export -r 0 -o "\$FOO/%R.diff" - > blank = !echo - > self = !echo '\$0' - > echo = !echo '\$@' - > echo1 = !echo '\$1' - > echo2 = !echo '\$2' - > echo13 = !echo '\$1' '\$3' - > count = !hg log -r '\$@' --template='.' | wc -c | sed -e 's/ //g' - > mcount = !hg log \$@ --template='.' | wc -c | sed -e 's/ //g' + > blank = !printf '\n' + > self = !printf '\$0\n' + > echoall = !printf '\$@\n' + > echo1 = !printf '\$1\n' + > echo2 = !printf '\$2\n' + > echo13 = !printf '\$1 \$3\n' + > count = !hg log -r "\$@" --template=. | wc -c | sed -e 's/ //g' + > mcount = !hg log \$@ --template=. | wc -c | sed -e 's/ //g' > rt = root > tglog = glog --template "{rev}:{node|short}: '{desc}' {branches}\n" > idalias = id @@ -41,10 +39,10 @@ > idaliasshell = !echo test > parentsshell1 = !echo one > parentsshell2 = !echo two - > escaped1 = !echo 'test\$\$test' - > escaped2 = !echo "HGFOO is \$\$HGFOO" - > escaped3 = !echo "\$1 is \$\$\$1" - > escaped4 = !echo '\$\$0' '\$\$@' + > escaped1 = !printf 'test\$\$test\n' + > escaped2 = !sh -c 'echo "HGFOO is \$\$HGFOO"' + > escaped3 = !sh -c 'echo "\$1 is \$\$\$1"' + > escaped4 = !printf '\$\$0 \$\$@\n' > > [defaults] > mylog = -q @@ -200,11 +198,11 @@ $ hg self self - $ hg echo + $ hg echoall - $ hg echo foo + $ hg echoall foo foo - $ hg echo 'test $2' foo + $ hg echoall 'test $2' foo test $2 foo $ hg echo1 foo bar baz foo @@ -270,7 +268,7 @@ 0 $ hg --cwd .. count 'branch(default)' 2 - $ hg echo --cwd .. + $ hg echoall --cwd .. @@ -278,11 +276,11 @@ $ cat >> .hg/hgrc <<EOF > [alias] - > subalias = !echo sub \$@ + > subalias = !echo sub > EOF $ cat >> ../.hg/hgrc <<EOF > [alias] - > mainalias = !echo main \$@ + > mainalias = !echo main > EOF