[PATCH 2 of 2 RFC] tests/run-tests: use hghave.py

Adrian Buehlmann adrian at cadifra.com
Tue Jun 12 06:23:03 CDT 2012


On 2012-06-12 13:17, Adrian Buehlmann wrote:
> # HG changeset patch
> # User Adrian Buehlmann <adrian at cadifra.com>
> # Date 1339495296 -7200
> # Node ID 7284bfac8225399e3f16c06bdb6d6d9ab88be5eb
> # Parent  a52c543f0523f83d0c313b934646e9692fae254a
> tests/run-tests: use hghave.py
> 
> diff --git a/tests/hghave.py b/tests/hghave.py
> --- a/tests/hghave.py
> +++ b/tests/hghave.py
> @@ -272,3 +272,32 @@
>      "windows": (has_windows, "Windows"),
>      "msys": (has_msys, "Windows with MSYS"),
>  }
> +
> +class TestError(Exception):
> +     def __init__(self, msg):
> +         self.msg = msg
> +     def __str__(self):
> +         return self.msg
> +
> +def testfeatures(features):
> +
> +    for feature in features:
> +        negate = feature.startswith('no-')
> +        if negate:
> +            feature = feature[3:]
> +
> +        if feature not in checks:
> +            raise TestError('unknown feature: ' + feature)
> + 
> +        check, desc = checks[feature]
> +        try:
> +            available = check()
> +        except Exception, e:
> +            raise TestError('hghave check failed: ' + featur)
                                                               ^ typo
> +
> +        if not negate and not available:
> +            return False
> +        elif negate and available:
> +            return False
> +    
> +    return True

I'm still cooking this. Seems to work not so bad.

Comments welcome.


More information about the Mercurial-devel mailing list