[PATCH] test-tag: enable for Windows
Mads Kiilerich
mads at kiilerich.com
Sun Jun 3 15:04:45 UTC 2012
Adrian Buehlmann wrote, On 06/02/2012 04:55 PM:
> # HG changeset patch
> # User Adrian Buehlmann<adrian at cadifra.com>
> # Date 1338648404 -7200
> # Node ID 2c1cb3d59c43581cb6d27a8216005ee862498f9c
> # Parent 96f6639987c2bc61c959ef9983b7d5221671e7fc
> test-tag: enable for Windows
>
> diff --git a/tests/dummyeditor.py b/tests/dummyeditor.py
> new file mode 100644
> --- /dev/null
> +++ b/tests/dummyeditor.py
> @@ -0,0 +1,5 @@
> +import sys
> +f = open(sys.argv[1], 'wb')
> +f.write("first line written by dummyeditor\n")
> +f.write("second line written by dummyeditor\n")
> +f.close()
I agree with the general direction. Many other tests needs a HGEDITOR
that is a bit more useful than the one defined by run-tests.py, and it
would perhaps be less work in the short and long term to find some
generic mechanism. It should however be able to handle different needs
for different tests.
It could perhaps be something like wrapping 'sed' and make it read a
command file somewhere.
Or perhaps even simpler, a editor.sh:
mv $1 hgeditor.old
mv hgeditor.new $1
and populate hgeditor.new each time before using the editor.
This dummyeditor.py as shown here doesn't have much advantage compared
to what you proposed earlier. I would prefer
- $ chmod +x editor
- $ HGEDITOR="'`pwd`'"/editor hg tag custom-tag -e
+ $ HGEDITOR="sh `pwd`/editor" hg tag custom-tag -e
> diff --git a/tests/test-tag.t b/tests/test-tag.t
> --- a/tests/test-tag.t
> +++ b/tests/test-tag.t
> @@ -1,5 +1,3 @@
> - $ "$TESTDIR/hghave" system-sh || exit 80
> -
> $ hg init test
> $ cd test
>
> @@ -214,16 +212,10 @@
>
> test custom commit messages
>
> - $ cat> editor<< '__EOF__'
> -> #!/bin/sh
> -> echo "custom tag message"> "$1"
> -> echo "second line">> "$1"
> -> __EOF__
> - $ chmod +x editor
> - $ HGEDITOR="'`pwd`'"/editor hg tag custom-tag -e
> + $ HGEDITOR="python \"$TESTDIR/dummyeditor.py\"" hg tag custom-tag -e
> $ hg log -l1 --template "{desc}\n"
> - custom tag message
> - second line
> + first line written by dummyeditor
> + second line written by dummyeditor
>
>
> local tag with .hgtags modified
> @@ -235,7 +227,6 @@
> $ hg st
> M .hgtags
> ? .hgtags.orig
> - ? editor
> $ hg tag --local baz
> $ hg revert --no-backup .hgtags
>
> @@ -303,9 +294,11 @@
>
> commit hook on tag used to be run without write lock - issue3344
>
> + $ HGPATH="$TESTDIR/../hg"
That will not work if you follow the instructions on the wiki and remove
hg (or rename it to hg.py where it can be found by the hg.exe exewrapper).
If you use exewrapper then you are testing exactly like cmd.exe would
invoke hg.exe, without any msys magic.
If you don't use exewrapper then you will rely on msys/bash doing
hash-bang expansion. That might make sense too and might perform a bit
better ... but also rely a bit more on msys magic.
Doing it differently (no exewrapper) might make sense, but then the wiki
should be updated.
> $ 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="python \"$HGPATH\" push \"`pwd`/repo-tag-target\"" tag tag
It should probably be described in the test or commit message what kind
of workaround we are doing here and why it is needed.
In short: you are testing without exewrapper, and cmd.exe and system()
can thus not invoke 'hg' directly.
But again: testing that a hg.exe can invoke another hg.exe in a hook
would also make sense and probably find some real problems ... that
might however not be what we want to test here.
/Mads
More information about the Mercurial-devel
mailing list