tests/hghave
changeset 25732 b94df10cc3b5
parent 22762 05b3238ba901
child 26067 8107c308ff22
equal deleted inserted replaced
25731:cd1daab5d036 25732:b94df10cc3b5
     2 """Test the running system for features availability. Exit with zero
     2 """Test the running system for features availability. Exit with zero
     3 if all features are there, non-zero otherwise. If a feature name is
     3 if all features are there, non-zero otherwise. If a feature name is
     4 prefixed with "no-", the absence of feature is tested.
     4 prefixed with "no-", the absence of feature is tested.
     5 """
     5 """
     6 import optparse
     6 import optparse
     7 import sys
     7 import os, sys
     8 import hghave
     8 import hghave
     9 
     9 
    10 checks = hghave.checks
    10 checks = hghave.checks
    11 
    11 
    12 def list_features():
    12 def list_features():
    31 parser.add_option("--list-features", action="store_true",
    31 parser.add_option("--list-features", action="store_true",
    32                   help="list available features")
    32                   help="list available features")
    33 parser.add_option("-q", "--quiet", action="store_true",
    33 parser.add_option("-q", "--quiet", action="store_true",
    34                   help="check features silently")
    34                   help="check features silently")
    35 
    35 
       
    36 def _loadaddon(quiet):
       
    37     if 'TESTDIR' in os.environ:
       
    38         # loading from '.' isn't needed, because `hghave` should be
       
    39         # running at TESTTMP in this case
       
    40         path = os.environ['TESTDIR']
       
    41     else:
       
    42         path = '.'
       
    43 
       
    44     if not os.path.exists(os.path.join(path, 'hghaveaddon.py')):
       
    45         return
       
    46 
       
    47     sys.path.insert(0, path)
       
    48     try:
       
    49         import hghaveaddon
       
    50     except BaseException, inst:
       
    51         if not quiet:
       
    52             sys.stderr.write('failed to import hghaveaddon.py from %r: %s\n'
       
    53                              % (path, inst))
       
    54         sys.exit(2)
       
    55     sys.path.pop(0)
       
    56 
    36 if __name__ == '__main__':
    57 if __name__ == '__main__':
    37     options, args = parser.parse_args()
    58     options, args = parser.parse_args()
       
    59     _loadaddon(options.quiet)
    38     if options.list_features:
    60     if options.list_features:
    39         list_features()
    61         list_features()
    40         sys.exit(0)
    62         sys.exit(0)
    41 
    63 
    42     if options.test_features:
    64     if options.test_features: