[PATCH RFC, V3] run-tests: use hghave.py

Mads Kiilerich mads at kiilerich.com
Mon Jun 18 17:38:46 CDT 2012


Adrian Buehlmann wrote, On 06/19/2012 12:00 AM:
> # HG changeset patch
> # User Adrian Buehlmann <adrian at cadifra.com>
> # Date 1340041060 -7200
> # Node ID 94a761427a57b21e47ed9bdc3293337cb2885c55
> # Parent  132ea1736751cb02b16992cf421e7de8bad888a1
> run-tests: use hghave.py
>
> Eliminates the start of a subprocess for #if requirements checking.
>
> The has_xxx functions in hghave.py now get the path where they should do their
> check in.

Thanks, this looks good, but testing revealed a couple of show stoppers.

> diff --git a/tests/hghave.py b/tests/hghave.py
> --- a/tests/hghave.py
> +++ b/tests/hghave.py
> @@ -37,30 +37,30 @@
>       except ImportError:
>           return False
>   
> -def has_cvs():
> +def has_cvs(wd):
>       re = r'Concurrent Versions System.*?server'
>       return matchoutput('cvs --version 2>&1', re) and not has_msys()

This way of disabling cvs on msys is an ugly hack that probably should 
be removed, but the way it is now it lacks a wd, and test-hghave.t and 
the cvs tests will thus fail when cvs is available.

> @@ -118,30 +118,30 @@
>       except OSError:
>           return False
>   
> -def has_cacheable_fs():
> +def has_cacheable_fs(wd):
>       from mercurial import util

hghave is run in the test environment where PYTHONPATH is set so the 
right mercurial can be imported. But PYTHONPATH is probably not set 
correctly when run-tests is invoked, so when imported in run-tests it 
will use the wrong mercurial or fail to import it.

> -    fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix)
> +    fd, path = tempfile.mkstemp(dir=wd, prefix=tempprefix)
>       os.close(fd)
>       try:
>           return util.cachestat(path).cacheable()
>       finally:
>           os.remove(path)
>   

/Mads


More information about the Mercurial-devel mailing list