tests/hghave
changeset 5248 c0281c6b40b0
parent 5230 4fa0f2dff643
child 5249 d82ebcdf20e1
child 5302 961876838de0
equal deleted inserted replaced
5247:90919a6f5c8f 5248:c0281c6b40b0
     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 os
     7 import os
       
     8 import re
     8 import sys
     9 import sys
     9 import tempfile
    10 import tempfile
    10 
    11 
    11 tempprefix = 'hg-hghave-'
    12 tempprefix = 'hg-hghave-'
       
    13 
       
    14 def matchoutput(cmd, regexp):
       
    15     """Return True if cmd executes successfully and its output
       
    16     is matched by the supplied regular expression.
       
    17     """
       
    18     r = re.compile(regexp)
       
    19     fh = os.popen(cmd)
       
    20     s = fh.read()
       
    21     ret = fh.close()
       
    22     return ret is None and r.search(s)
    12 
    23 
    13 def has_symlink():
    24 def has_symlink():
    14     return hasattr(os, "symlink")
    25     return hasattr(os, "symlink")
    15 
    26 
    16 def has_fifo():
    27 def has_fifo():
    50         return True
    61         return True
    51     except ImportError:
    62     except ImportError:
    52         return False
    63         return False
    53 
    64 
    54 def has_git():
    65 def has_git():
    55     fh = os.popen('git --version 2>&1')
    66     return matchoutput('git --version 2>&1', r'^git version')
    56     s = fh.read()
       
    57     ret = fh.close()
       
    58     return ret is None and s.startswith('git version')
       
    59 
    67 
    60 checks = {
    68 checks = {
    61     "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"),
    69     "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"),
    62     "execbit": (has_executablebit, "executable bit"),
    70     "execbit": (has_executablebit, "executable bit"),
    63     "git": (has_git, "git command line client"),
    71     "git": (has_git, "git command line client"),