writing tests for an extension
Dov Feldstern
dfeldstern at fastimap.com
Fri Dec 5 06:59:58 CST 2008
Dov Feldstern wrote:
> 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...
>
Well, I totally got the path names here mixed up :/
It seems to me I'd need the following structure in my repo, which seems sort of
weird:
myext-repo/
test-myext-1.py
test-myext-2.py
myext/
__init__.py
myext.py
myext-util.py
and in .hgrc:
myext=/path/to/myext-repo/myext
I guess that's not so bad, it's just weird to have the tests in root of the
repo, and the actual code underneath it...
More information about the Mercurial-devel
mailing list