writing tests for an extension
Dov Feldstern
dfeldstern at fastimap.com
Fri Dec 5 06:54:39 CST 2008
Dov Feldstern wrote:
> Patrick Mézard wrote:
>> Dov Feldstern a écrit :
>>> Hi!
>>>
>>> I see that tests of an extension need to add the extension to the hgrc, like so:
>>>
>>> [extensions]
>>> convert=
>>>
>>> However, that only works if the extension is placed within the the hgext
>>> directory; otherwise, it's necessary to provide a full path to the extension's
>>> location. But I don't want to hard code that into the tests. I also want this to
>>> work, say, with a binary installation on Windows, where there may not even be an
>>> hgext directory (is that true?).
>>>
>>> Any ideas on how to deal with this?
>> It works if you run the tests from the extension directory. For instance, the forest extension repository contains the extension file and a single test file. The test is run with:
>>
>> $ python ../your-hg-repo/tests/run-tests.py test-forest
>>
>> and the test itself registers the extension like:
>>
>> """
>> echo "[extensions]" >> $HGRCPATH
>> echo "mq=" >> $HGRCPATH
>> echo "forest=" >> $HGRCPATH
>> """
>>
>> --
>> Patrick Mézard
>
> My situation is a little more complicated, for two reasons: (1) my extension
> contains multiple files, so it's a package with __init__.py; (2) my tests are in
> a tests directory (which is currently *inside* the package directory). So from
> within the tests directory, the package is not found.
>
> So I guess I should move the tests directory to be placed alongside the
> directory containing the package itself? Something like this:
>
> myext-repo/
> myext/
> __init__.py
> myext.py
> myext-utils.py
> tests/
> test-myext.py
>
> and then in .hgrc:
> myext=/path/to/myrepo-ext/myrepo
>
> Thanks!
> Dov
>
Or rather:
myext-repo/
tests/
test-myext.py
my-ext/
__init__.py
myext.py
myext-utils.py
and then .hgrc would have to read:
myext=path/to/myrepo-ext/tests/myrepo
which seems sort of weird...
More information about the Mercurial-devel
mailing list