tests/hghave
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
Sat, 09 Feb 2008 18:38:54 -0200
changeset 6063 b74a0c4bfb30
parent 5685 57d29a45ffbc
child 6078 ebc23d34102f
permissions -rwxr-xr-x
hghave: detect unix-style permissions By "unix-style" I mean: - user/group/other permissions - umask determines original permissions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4881
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/env python
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     2
"""Test the running system for features availability. Exit with zero
5084
80309fa23cdb hghave: feature absence can be checked by prefixing with 'no-'
Patrick Mezard <pmezard@gmail.com>
parents: 5081
diff changeset
     3
if all features are there, non-zero otherwise. If a feature name is
80309fa23cdb hghave: feature absence can be checked by prefixing with 'no-'
Patrick Mezard <pmezard@gmail.com>
parents: 5081
diff changeset
     4
prefixed with "no-", the absence of feature is tested.
4881
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     5
"""
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     6
import optparse
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     7
import os
5252
c0281c6b40b0 hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents: 5218
diff changeset
     8
import re
4881
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     9
import sys
5072
7e2385a31933 hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents: 5070
diff changeset
    10
import tempfile
4881
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    11
5090
bf60e4bd6672 hghave: prefix temporary files with "hg-hghave-"
Patrick Mezard <pmezard@gmail.com>
parents: 5084
diff changeset
    12
tempprefix = 'hg-hghave-'
bf60e4bd6672 hghave: prefix temporary files with "hg-hghave-"
Patrick Mezard <pmezard@gmail.com>
parents: 5084
diff changeset
    13
5302
961876838de0 hghave: detect cvs and cvsps availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
    14
def matchoutput(cmd, regexp, ignorestatus=False):
5252
c0281c6b40b0 hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents: 5218
diff changeset
    15
    """Return True if cmd executes successfully and its output
c0281c6b40b0 hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents: 5218
diff changeset
    16
    is matched by the supplied regular expression.
c0281c6b40b0 hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents: 5218
diff changeset
    17
    """
c0281c6b40b0 hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents: 5218
diff changeset
    18
    r = re.compile(regexp)
c0281c6b40b0 hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents: 5218
diff changeset
    19
    fh = os.popen(cmd)
c0281c6b40b0 hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents: 5218
diff changeset
    20
    s = fh.read()
c0281c6b40b0 hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents: 5218
diff changeset
    21
    ret = fh.close()
5302
961876838de0 hghave: detect cvs and cvsps availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
    22
    return (ignorestatus or ret is None) and r.search(s)
5252
c0281c6b40b0 hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents: 5218
diff changeset
    23
5302
961876838de0 hghave: detect cvs and cvsps availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
    24
def has_cvs():
961876838de0 hghave: detect cvs and cvsps availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
    25
    return matchoutput('cvs --version 2>&1', r'Concurrent Versions System')
961876838de0 hghave: detect cvs and cvsps availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
    26
961876838de0 hghave: detect cvs and cvsps availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
    27
def has_cvsps():
961876838de0 hghave: detect cvs and cvsps availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
    28
    return matchoutput('cvsps -h -q 2>&1', r'cvsps version', True)
961876838de0 hghave: detect cvs and cvsps availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
    29
5410
2daecf3d2582 hghave: detect darcs client
Patrick Mezard <pmezard@gmail.com>
parents: 5409
diff changeset
    30
def has_darcs():
2daecf3d2582 hghave: detect darcs client
Patrick Mezard <pmezard@gmail.com>
parents: 5409
diff changeset
    31
    return matchoutput('darcs', 'darcs version', True)
2daecf3d2582 hghave: detect darcs client
Patrick Mezard <pmezard@gmail.com>
parents: 5409
diff changeset
    32
5409
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
    33
def has_eol_in_paths():
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
    34
    try:
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
    35
        fd, path = tempfile.mkstemp(prefix=tempprefix, suffix='\n\r')
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
    36
        os.close(fd)
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
    37
        os.remove(path)
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
    38
        return True
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
    39
    except:
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
    40
        return False
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
    41
5072
7e2385a31933 hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents: 5070
diff changeset
    42
def has_executablebit():
5090
bf60e4bd6672 hghave: prefix temporary files with "hg-hghave-"
Patrick Mezard <pmezard@gmail.com>
parents: 5084
diff changeset
    43
    fd, path = tempfile.mkstemp(prefix=tempprefix)
5072
7e2385a31933 hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents: 5070
diff changeset
    44
    os.close(fd)
7e2385a31933 hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents: 5070
diff changeset
    45
    try:
7e2385a31933 hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents: 5070
diff changeset
    46
        s = os.lstat(path).st_mode
7e2385a31933 hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents: 5070
diff changeset
    47
        os.chmod(path, s | 0100)
7e2385a31933 hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents: 5070
diff changeset
    48
        return (os.lstat(path).st_mode & 0100 != 0)
7e2385a31933 hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents: 5070
diff changeset
    49
    finally:
7e2385a31933 hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents: 5070
diff changeset
    50
        os.remove(path)
7e2385a31933 hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents: 5070
diff changeset
    51
5409
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
    52
def has_fifo():
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
    53
    return hasattr(os, "mkfifo")
5074
e86788af599a hghave: detect support for EOL in paths.
Patrick Mezard <pmezard@gmail.com>
parents: 5072
diff changeset
    54
5102
9b0efeb725f4 test-profile: fix grep, check hotshot availability
Patrick Mezard <pmezard@gmail.com>
parents: 5099
diff changeset
    55
def has_hotshot():
9b0efeb725f4 test-profile: fix grep, check hotshot availability
Patrick Mezard <pmezard@gmail.com>
parents: 5099
diff changeset
    56
    try:
5103
e5b21a549cc5 hghave: test hotshot dependencies (debian does not provide profile)
Patrick Mezard <pmezard@gmail.com>
parents: 5102
diff changeset
    57
        # hotshot.stats tests hotshot and many problematic dependencies
e5b21a549cc5 hghave: test hotshot dependencies (debian does not provide profile)
Patrick Mezard <pmezard@gmail.com>
parents: 5102
diff changeset
    58
        # like profile.
e5b21a549cc5 hghave: test hotshot dependencies (debian does not provide profile)
Patrick Mezard <pmezard@gmail.com>
parents: 5102
diff changeset
    59
        import hotshot.stats
5102
9b0efeb725f4 test-profile: fix grep, check hotshot availability
Patrick Mezard <pmezard@gmail.com>
parents: 5099
diff changeset
    60
        return True
9b0efeb725f4 test-profile: fix grep, check hotshot availability
Patrick Mezard <pmezard@gmail.com>
parents: 5099
diff changeset
    61
    except ImportError:
9b0efeb725f4 test-profile: fix grep, check hotshot availability
Patrick Mezard <pmezard@gmail.com>
parents: 5099
diff changeset
    62
        return False
9b0efeb725f4 test-profile: fix grep, check hotshot availability
Patrick Mezard <pmezard@gmail.com>
parents: 5099
diff changeset
    63
5099
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
    64
def has_lsprof():
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
    65
    try:
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
    66
        import _lsprof
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
    67
        return True
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
    68
    except ImportError:
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
    69
        return False
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
    70
5218
4fa0f2dff643 hghave: detect git availability
Patrick Mezard <pmezard@gmail.com>
parents: 5103
diff changeset
    71
def has_git():
5252
c0281c6b40b0 hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents: 5218
diff changeset
    72
    return matchoutput('git --version 2>&1', r'^git version')
5218
4fa0f2dff643 hghave: detect git availability
Patrick Mezard <pmezard@gmail.com>
parents: 5103
diff changeset
    73
5253
d82ebcdf20e1 hghave: detect subversion client and admin tools availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
    74
def has_svn():
d82ebcdf20e1 hghave: detect subversion client and admin tools availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
    75
    return matchoutput('svn --version 2>&1', r'^svn, version') and \
d82ebcdf20e1 hghave: detect subversion client and admin tools availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
    76
        matchoutput('svnadmin --version 2>&1', r'^svnadmin, version')
d82ebcdf20e1 hghave: detect subversion client and admin tools availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
    77
5254
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
    78
def has_svn_bindings():
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
    79
    try:
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
    80
        import svn.core
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
    81
        return True
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
    82
    except ImportError:
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
    83
        return False
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
    84
5409
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
    85
def has_symlink():
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
    86
    return hasattr(os, "symlink")
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
    87
6063
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
    88
def has_unix_permissions():
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
    89
    d = tempfile.mkdtemp(prefix=tempprefix, dir=".")
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
    90
    try:
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
    91
        fname = os.path.join(d, 'foo')
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
    92
        for umask in (077, 007, 022):
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
    93
            os.umask(umask)
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
    94
            f = open(fname, 'w')
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
    95
            f.close()
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
    96
            mode = os.stat(fname).st_mode
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
    97
            os.unlink(fname)
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
    98
            if mode & 0777 != ~umask & 0666:
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
    99
                return False
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
   100
        return True
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
   101
    finally:
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
   102
        os.rmdir(d)
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
   103
4881
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   104
checks = {
5302
961876838de0 hghave: detect cvs and cvsps availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
   105
    "cvs": (has_cvs, "cvs client"),
961876838de0 hghave: detect cvs and cvsps availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
   106
    "cvsps": (has_cvsps, "cvsps utility"),
5410
2daecf3d2582 hghave: detect darcs client
Patrick Mezard <pmezard@gmail.com>
parents: 5409
diff changeset
   107
    "darcs": (has_darcs, "darcs client"),
5099
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
   108
    "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"),
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
   109
    "execbit": (has_executablebit, "executable bit"),
5409
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
   110
    "fifo": (has_fifo, "named pipes"),
5218
4fa0f2dff643 hghave: detect git availability
Patrick Mezard <pmezard@gmail.com>
parents: 5103
diff changeset
   111
    "git": (has_git, "git command line client"),
5102
9b0efeb725f4 test-profile: fix grep, check hotshot availability
Patrick Mezard <pmezard@gmail.com>
parents: 5099
diff changeset
   112
    "hotshot": (has_hotshot, "python hotshot module"),
5099
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
   113
    "lsprof": (has_lsprof, "python lsprof module"),
5253
d82ebcdf20e1 hghave: detect subversion client and admin tools availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
   114
    "svn": (has_svn, "subversion client and admin tools"),
5254
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
   115
    "svn-bindings": (has_svn_bindings, "subversion python bindings"),
5099
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
   116
    "symlink": (has_symlink, "symbolic links"),
6063
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
   117
    "unix-permissions": (has_unix_permissions, "unix-style permissions"),
4881
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   118
}
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   119
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   120
def list_features():
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   121
    for name, feature in checks.iteritems():
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   122
        desc = feature[1]
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   123
        print name + ':', desc
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   124
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   125
parser = optparse.OptionParser("%prog [options] [features]")
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   126
parser.add_option("--list-features", action="store_true",
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   127
                  help="list available features")
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   128
parser.add_option("-q", "--quiet", action="store_true",
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   129
                  help="check features silently")
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   130
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   131
if __name__ == '__main__':
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   132
    options, args = parser.parse_args()
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   133
    if options.list_features:
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   134
        list_features()
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   135
        sys.exit(0)
5081
ea7b982b6c08 Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5074
diff changeset
   136
4881
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   137
    quiet = options.quiet
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   138
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   139
    failures = 0
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   140
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   141
    def error(msg):
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   142
        global failures
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   143
        if not quiet:
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   144
            sys.stderr.write(msg + '\n')
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   145
        failures += 1
5081
ea7b982b6c08 Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5074
diff changeset
   146
4881
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   147
    for feature in args:
5084
80309fa23cdb hghave: feature absence can be checked by prefixing with 'no-'
Patrick Mezard <pmezard@gmail.com>
parents: 5081
diff changeset
   148
        negate = feature.startswith('no-')
80309fa23cdb hghave: feature absence can be checked by prefixing with 'no-'
Patrick Mezard <pmezard@gmail.com>
parents: 5081
diff changeset
   149
        if negate:
80309fa23cdb hghave: feature absence can be checked by prefixing with 'no-'
Patrick Mezard <pmezard@gmail.com>
parents: 5081
diff changeset
   150
            feature = feature[3:]
5091
fc6106267198 Hide absolute path from test-no-symlinks output.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5090
diff changeset
   151
4881
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   152
        if feature not in checks:
5685
57d29a45ffbc Use skipped: instead of hghave: for skipping tests, use this in test-merge-types
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5410
diff changeset
   153
            error('skipped: unknown feature: ' + feature)
4881
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   154
            continue
5081
ea7b982b6c08 Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5074
diff changeset
   155
ea7b982b6c08 Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5074
diff changeset
   156
        check, desc = checks[feature]
5084
80309fa23cdb hghave: feature absence can be checked by prefixing with 'no-'
Patrick Mezard <pmezard@gmail.com>
parents: 5081
diff changeset
   157
        if not negate and not check():
5685
57d29a45ffbc Use skipped: instead of hghave: for skipping tests, use this in test-merge-types
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5410
diff changeset
   158
            error('skipped: missing feature: ' + desc)
5084
80309fa23cdb hghave: feature absence can be checked by prefixing with 'no-'
Patrick Mezard <pmezard@gmail.com>
parents: 5081
diff changeset
   159
        elif negate and check():
5685
57d29a45ffbc Use skipped: instead of hghave: for skipping tests, use this in test-merge-types
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5410
diff changeset
   160
            error('skipped: system supports %s' % desc)
4881
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   161
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   162
    if failures != 0:
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   163
        sys.exit(1)
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   164
5081
ea7b982b6c08 Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5074
diff changeset
   165