hghave: feature absence can be checked by prefixing with 'no-'
authorPatrick Mezard <pmezard@gmail.com>
Wed, 08 Aug 2007 23:07:39 +0200
changeset 5084 80309fa23cdb
parent 5083 f94dbc6c7eaf
child 5085 dcfd75502b82
hghave: feature absence can be checked by prefixing with 'no-'
tests/hghave
--- a/tests/hghave	Wed Aug 08 22:47:30 2007 +0200
+++ b/tests/hghave	Wed Aug 08 23:07:39 2007 +0200
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 """Test the running system for features availability. Exit with zero
-if all features are there, non-zero otherwise.
+if all features are there, non-zero otherwise. If a feature name is
+prefixed with "no-", the absence of feature is tested.
 """
 import optparse
 import os
@@ -67,13 +68,19 @@
         failures += 1
 
     for feature in args:
+        negate = feature.startswith('no-')
+        if negate:
+            feature = feature[3:]
+        
         if feature not in checks:
             error('hghave: unknown feature: ' + feature)
             continue
 
         check, desc = checks[feature]
-        if not check():
+        if not negate and not check():
             error('hghave: missing feature: ' + desc)
+        elif negate and check():
+            error('hghave: unexpected feature: ' + desc)
 
     if failures != 0:
         sys.exit(1)