tests/hghave.py
author Augie Fackler <raf@durin42.com>
Wed, 06 Nov 2013 18:19:04 -0500
branchstable
changeset 1315 e3461e819922
parent 1311 1fed120bfa04
child 1323 aeb658c7dbc7
permissions -rwxr-xr-x
pathutil: tease out a new library to break an import cycle from canonpath use [ original upstream message ]
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1101
89f984505cbb tests/hghave: test that the inotify unix socket actually can be created
Mads Kiilerich <mads@kiilerich.com>
parents: 1100
diff changeset
     1
import os, stat, socket
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     2
import re
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     3
import sys
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     4
import tempfile
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     5
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     6
tempprefix = 'hg-hghave-'
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     7
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     8
def matchoutput(cmd, regexp, ignorestatus=False):
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     9
    """Return True if cmd executes successfully and its output
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    10
    is matched by the supplied regular expression.
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    11
    """
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    12
    r = re.compile(regexp)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    13
    fh = os.popen(cmd)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    14
    s = fh.read()
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    15
    try:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    16
        ret = fh.close()
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    17
    except IOError:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    18
        # Happen in Windows test environment
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    19
        ret = 1
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    20
    return (ignorestatus or ret is None) and r.search(s)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    21
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    22
def has_baz():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    23
    return matchoutput('baz --version 2>&1', r'baz Bazaar version')
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    24
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    25
def has_bzr():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    26
    try:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    27
        import bzrlib
1070
838e4146e763 cleanup: "x != None" -> "x is not None"
Brodie Rao <brodie@sf.io>
parents: 1069
diff changeset
    28
        return bzrlib.__doc__ is not None
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    29
    except ImportError:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    30
        return False
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    31
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    32
def has_bzr114():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    33
    try:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    34
        import bzrlib
1070
838e4146e763 cleanup: "x != None" -> "x is not None"
Brodie Rao <brodie@sf.io>
parents: 1069
diff changeset
    35
        return (bzrlib.__doc__ is not None
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    36
                and bzrlib.version_info[:2] >= (1, 14))
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    37
    except ImportError:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    38
        return False
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    39
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    40
def has_cvs():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    41
    re = r'Concurrent Versions System.*?server'
1032
5923d03569b3 tests: skip cvs tests with msys on windows
Mads Kiilerich <mads@kiilerich.com>
parents: 1031
diff changeset
    42
    return matchoutput('cvs --version 2>&1', re) and not has_msys()
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    43
1190
ecb744c2a199 hghave: introduce a test (unused) for cvs >= 1.12
Bryan O'Sullivan <bryano@fb.com>
parents: 1136
diff changeset
    44
def has_cvs112():
ecb744c2a199 hghave: introduce a test (unused) for cvs >= 1.12
Bryan O'Sullivan <bryano@fb.com>
parents: 1136
diff changeset
    45
    re = r'Concurrent Versions System \(CVS\) 1.12.*?server'
ecb744c2a199 hghave: introduce a test (unused) for cvs >= 1.12
Bryan O'Sullivan <bryano@fb.com>
parents: 1136
diff changeset
    46
    return matchoutput('cvs --version 2>&1', re) and not has_msys()
ecb744c2a199 hghave: introduce a test (unused) for cvs >= 1.12
Bryan O'Sullivan <bryano@fb.com>
parents: 1136
diff changeset
    47
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    48
def has_darcs():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    49
    return matchoutput('darcs --version', r'2\.[2-9]', True)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    50
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    51
def has_mtn():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    52
    return matchoutput('mtn --version', r'monotone', True) and not matchoutput(
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    53
        'mtn --version', r'monotone 0\.', True)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    54
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    55
def has_eol_in_paths():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    56
    try:
1099
55c85631631b tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents: 1098
diff changeset
    57
        fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix, suffix='\n\r')
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    58
        os.close(fd)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    59
        os.remove(path)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    60
        return True
1072
bbf056e756cc cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents: 1071
diff changeset
    61
    except (IOError, OSError):
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    62
        return False
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    63
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    64
def has_executablebit():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    65
    try:
1056
0e6cee08a2f8 tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 1055
diff changeset
    66
        EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
1099
55c85631631b tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents: 1098
diff changeset
    67
        fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix)
1056
0e6cee08a2f8 tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 1055
diff changeset
    68
        try:
0e6cee08a2f8 tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 1055
diff changeset
    69
            os.close(fh)
0e6cee08a2f8 tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 1055
diff changeset
    70
            m = os.stat(fn).st_mode & 0777
0e6cee08a2f8 tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 1055
diff changeset
    71
            new_file_has_exec = m & EXECFLAGS
0e6cee08a2f8 tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 1055
diff changeset
    72
            os.chmod(fn, m ^ EXECFLAGS)
0e6cee08a2f8 tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 1055
diff changeset
    73
            exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0777) == m)
0e6cee08a2f8 tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 1055
diff changeset
    74
        finally:
0e6cee08a2f8 tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 1055
diff changeset
    75
            os.unlink(fn)
0e6cee08a2f8 tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 1055
diff changeset
    76
    except (IOError, OSError):
0e6cee08a2f8 tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 1055
diff changeset
    77
        # we don't care, the user probably won't be able to commit anyway
0e6cee08a2f8 tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 1055
diff changeset
    78
        return False
0e6cee08a2f8 tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 1055
diff changeset
    79
    return not (new_file_has_exec or exec_flags_cannot_flip)
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    80
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    81
def has_icasefs():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    82
    # Stolen from mercurial.util
1099
55c85631631b tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents: 1098
diff changeset
    83
    fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix)
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    84
    os.close(fd)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    85
    try:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    86
        s1 = os.stat(path)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    87
        d, b = os.path.split(path)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    88
        p2 = os.path.join(d, b.upper())
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    89
        if path == p2:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    90
            p2 = os.path.join(d, b.lower())
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    91
        try:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    92
            s2 = os.stat(p2)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    93
            return s2 == s1
1072
bbf056e756cc cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents: 1071
diff changeset
    94
        except OSError:
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    95
            return False
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    96
    finally:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    97
        os.remove(path)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    98
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
    99
def has_inotify():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   100
    try:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   101
        import hgext.inotify.linux.watcher
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   102
    except ImportError:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   103
        return False
1101
89f984505cbb tests/hghave: test that the inotify unix socket actually can be created
Mads Kiilerich <mads@kiilerich.com>
parents: 1100
diff changeset
   104
    name = tempfile.mktemp(dir='.', prefix=tempprefix)
89f984505cbb tests/hghave: test that the inotify unix socket actually can be created
Mads Kiilerich <mads@kiilerich.com>
parents: 1100
diff changeset
   105
    sock = socket.socket(socket.AF_UNIX)
89f984505cbb tests/hghave: test that the inotify unix socket actually can be created
Mads Kiilerich <mads@kiilerich.com>
parents: 1100
diff changeset
   106
    try:
89f984505cbb tests/hghave: test that the inotify unix socket actually can be created
Mads Kiilerich <mads@kiilerich.com>
parents: 1100
diff changeset
   107
        sock.bind(name)
1279
9dac69d57f75 cleanup: drop unused variables and an unused import
Simon Heimberg <simohe@besonet.ch>
parents: 1278
diff changeset
   108
    except socket.error:
1101
89f984505cbb tests/hghave: test that the inotify unix socket actually can be created
Mads Kiilerich <mads@kiilerich.com>
parents: 1100
diff changeset
   109
        return False
89f984505cbb tests/hghave: test that the inotify unix socket actually can be created
Mads Kiilerich <mads@kiilerich.com>
parents: 1100
diff changeset
   110
    sock.close()
89f984505cbb tests/hghave: test that the inotify unix socket actually can be created
Mads Kiilerich <mads@kiilerich.com>
parents: 1100
diff changeset
   111
    os.unlink(name)
89f984505cbb tests/hghave: test that the inotify unix socket actually can be created
Mads Kiilerich <mads@kiilerich.com>
parents: 1100
diff changeset
   112
    return True
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   113
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   114
def has_fifo():
1100
59a99457aa65 tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents: 1099
diff changeset
   115
    if getattr(os, "mkfifo", None) is None:
59a99457aa65 tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents: 1099
diff changeset
   116
        return False
59a99457aa65 tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents: 1099
diff changeset
   117
    name = tempfile.mktemp(dir='.', prefix=tempprefix)
59a99457aa65 tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents: 1099
diff changeset
   118
    try:
59a99457aa65 tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents: 1099
diff changeset
   119
        os.mkfifo(name)
59a99457aa65 tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents: 1099
diff changeset
   120
        os.unlink(name)
59a99457aa65 tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents: 1099
diff changeset
   121
        return True
59a99457aa65 tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents: 1099
diff changeset
   122
    except OSError:
59a99457aa65 tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents: 1099
diff changeset
   123
        return False
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   124
1133
82f74372516e test-http-branchmap: enable on Windows
Patrick Mezard <patrick@mezard.eu>
parents: 1105
diff changeset
   125
def has_killdaemons():
82f74372516e test-http-branchmap: enable on Windows
Patrick Mezard <patrick@mezard.eu>
parents: 1105
diff changeset
   126
    return True
82f74372516e test-http-branchmap: enable on Windows
Patrick Mezard <patrick@mezard.eu>
parents: 1105
diff changeset
   127
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   128
def has_cacheable_fs():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   129
    from mercurial import util
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   130
1099
55c85631631b tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents: 1098
diff changeset
   131
    fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix)
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   132
    os.close(fd)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   133
    try:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   134
        return util.cachestat(path).cacheable()
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   135
    finally:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   136
        os.remove(path)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   137
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   138
def has_lsprof():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   139
    try:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   140
        import _lsprof
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   141
        return True
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   142
    except ImportError:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   143
        return False
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   144
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   145
def has_gettext():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   146
    return matchoutput('msgfmt --version', 'GNU gettext-tools')
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   147
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   148
def has_git():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   149
    return matchoutput('git --version 2>&1', r'^git version')
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   150
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   151
def has_docutils():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   152
    try:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   153
        from docutils.core import publish_cmdline
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   154
        return True
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   155
    except ImportError:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   156
        return False
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   157
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   158
def getsvnversion():
1136
294cea906d3a subrepo, hghave: use "svn --version --quiet" to determine version number
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1133
diff changeset
   159
    m = matchoutput('svn --version --quiet 2>&1', r'^(\d+)\.(\d+)')
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   160
    if not m:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   161
        return (0, 0)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   162
    return (int(m.group(1)), int(m.group(2)))
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   163
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   164
def has_svn15():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   165
    return getsvnversion() >= (1, 5)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   166
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   167
def has_svn13():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   168
    return getsvnversion() >= (1, 3)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   169
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   170
def has_svn():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   171
    return matchoutput('svn --version 2>&1', r'^svn, version') and \
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   172
        matchoutput('svnadmin --version 2>&1', r'^svnadmin, version')
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   173
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   174
def has_svn_bindings():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   175
    try:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   176
        import svn.core
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   177
        version = svn.core.SVN_VER_MAJOR, svn.core.SVN_VER_MINOR
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   178
        if version < (1, 4):
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   179
            return False
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   180
        return True
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   181
    except ImportError:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   182
        return False
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   183
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   184
def has_p4():
1069
4e0cef7a70cf cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 1063
diff changeset
   185
    return (matchoutput('p4 -V', r'Rev\. P4/') and
4e0cef7a70cf cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 1063
diff changeset
   186
            matchoutput('p4d -V', r'Rev\. P4D/'))
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   187
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   188
def has_symlink():
1071
f0ce3dcd5c87 cleanup: replace hasattr() usage with getattr() in hghave
Brodie Rao <brodie@sf.io>
parents: 1070
diff changeset
   189
    if getattr(os, "symlink", None) is None:
1055
dabed2cabd5e tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents: 1032
diff changeset
   190
        return False
1099
55c85631631b tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents: 1098
diff changeset
   191
    name = tempfile.mktemp(dir='.', prefix=tempprefix)
1055
dabed2cabd5e tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents: 1032
diff changeset
   192
    try:
dabed2cabd5e tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents: 1032
diff changeset
   193
        os.symlink(".", name)
dabed2cabd5e tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents: 1032
diff changeset
   194
        os.unlink(name)
dabed2cabd5e tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents: 1032
diff changeset
   195
        return True
dabed2cabd5e tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents: 1032
diff changeset
   196
    except (OSError, AttributeError):
dabed2cabd5e tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents: 1032
diff changeset
   197
        return False
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   198
1102
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   199
def has_hardlink():
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   200
    from mercurial import util
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   201
    fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix)
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   202
    os.close(fh)
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   203
    name = tempfile.mktemp(dir='.', prefix=tempprefix)
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   204
    try:
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   205
        try:
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   206
            util.oslink(fn, name)
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   207
            os.unlink(name)
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   208
            return True
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   209
        except OSError:
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   210
            return False
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   211
    finally:
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   212
        os.unlink(fn)
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   213
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   214
def has_tla():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   215
    return matchoutput('tla --version 2>&1', r'The GNU Arch Revision')
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   216
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   217
def has_gpg():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   218
    return matchoutput('gpg --version 2>&1', r'GnuPG')
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   219
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   220
def has_unix_permissions():
1099
55c85631631b tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents: 1098
diff changeset
   221
    d = tempfile.mkdtemp(dir='.', prefix=tempprefix)
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   222
    try:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   223
        fname = os.path.join(d, 'foo')
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   224
        for umask in (077, 007, 022):
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   225
            os.umask(umask)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   226
            f = open(fname, 'w')
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   227
            f.close()
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   228
            mode = os.stat(fname).st_mode
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   229
            os.unlink(fname)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   230
            if mode & 0777 != ~umask & 0666:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   231
                return False
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   232
        return True
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   233
    finally:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   234
        os.rmdir(d)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   235
1303
94e35118a756 tests: skip tests that require not having root (issue4089)
Matt Mackall <mpm@selenic.com>
parents: 1301
diff changeset
   236
def has_root():
1311
1fed120bfa04 tests: fix `hghave root` on windows
Simon Heimberg <simohe@besonet.ch>
parents: 1303
diff changeset
   237
    return getattr(os, 'geteuid', None) and os.geteuid() == 0
1303
94e35118a756 tests: skip tests that require not having root (issue4089)
Matt Mackall <mpm@selenic.com>
parents: 1301
diff changeset
   238
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   239
def has_pyflakes():
1089
f26e9129f65b hghave: wrap command in 'sh -c "..."' for has_pyflakes()
Adrian Buehlmann <adrian@cadifra.com>
parents: 1072
diff changeset
   240
    return matchoutput("sh -c \"echo 'import re' 2>&1 | pyflakes\"",
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   241
                       r"<stdin>:1: 're' imported but unused",
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   242
                       True)
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   243
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   244
def has_pygments():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   245
    try:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   246
        import pygments
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   247
        return True
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   248
    except ImportError:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   249
        return False
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   250
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   251
def has_outer_repo():
1105
9b2932ca75fd tests: hghave outer-repo should be true even if a bad repo is found
Mads Kiilerich <mads@kiilerich.com>
parents: 1102
diff changeset
   252
    # failing for other reasons than 'no repo' imply that there is a repo
9b2932ca75fd tests: hghave outer-repo should be true even if a bad repo is found
Mads Kiilerich <mads@kiilerich.com>
parents: 1102
diff changeset
   253
    return not matchoutput('hg root 2>&1',
9b2932ca75fd tests: hghave outer-repo should be true even if a bad repo is found
Mads Kiilerich <mads@kiilerich.com>
parents: 1102
diff changeset
   254
                           r'abort: no repository found', True)
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   255
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   256
def has_ssl():
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   257
    try:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   258
        import ssl
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   259
        import OpenSSL
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   260
        OpenSSL.SSL.Context
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   261
        return True
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   262
    except ImportError:
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   263
        return False
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   264
1012
018ef69bbe2f tests: use 'hghave no-windows' to avoid testing reserved file names on windows
Mads Kiilerich <mads@kiilerich.com>
parents: 1010
diff changeset
   265
def has_windows():
018ef69bbe2f tests: use 'hghave no-windows' to avoid testing reserved file names on windows
Mads Kiilerich <mads@kiilerich.com>
parents: 1010
diff changeset
   266
    return os.name == 'nt'
018ef69bbe2f tests: use 'hghave no-windows' to avoid testing reserved file names on windows
Mads Kiilerich <mads@kiilerich.com>
parents: 1010
diff changeset
   267
1013
e00f51032041 tests: use 'hghave system-sh' to guard tests that requires sh in system()
Mads Kiilerich <mads@kiilerich.com>
parents: 1012
diff changeset
   268
def has_system_sh():
e00f51032041 tests: use 'hghave system-sh' to guard tests that requires sh in system()
Mads Kiilerich <mads@kiilerich.com>
parents: 1012
diff changeset
   269
    return os.name != 'nt'
e00f51032041 tests: use 'hghave system-sh' to guard tests that requires sh in system()
Mads Kiilerich <mads@kiilerich.com>
parents: 1012
diff changeset
   270
1014
58b7f58ae08c tests: use 'hghave serve' to guard tests that requires serve daemon management
Mads Kiilerich <mads@kiilerich.com>
parents: 1013
diff changeset
   271
def has_serve():
58b7f58ae08c tests: use 'hghave serve' to guard tests that requires serve daemon management
Mads Kiilerich <mads@kiilerich.com>
parents: 1013
diff changeset
   272
    return os.name != 'nt' # gross approximation
58b7f58ae08c tests: use 'hghave serve' to guard tests that requires serve daemon management
Mads Kiilerich <mads@kiilerich.com>
parents: 1013
diff changeset
   273
1027
f8c2547c8f16 tests: skip color test on platforms without tic
Mads Kiilerich <mads@kiilerich.com>
parents: 1014
diff changeset
   274
def has_tic():
f8c2547c8f16 tests: skip color test on platforms without tic
Mads Kiilerich <mads@kiilerich.com>
parents: 1014
diff changeset
   275
    return matchoutput('test -x "`which tic`"', '')
f8c2547c8f16 tests: skip color test on platforms without tic
Mads Kiilerich <mads@kiilerich.com>
parents: 1014
diff changeset
   276
1031
b914fc162545 tests: introduce 'hghave msys' to skip tests that would fail because of msys
Mads Kiilerich <mads@kiilerich.com>
parents: 1027
diff changeset
   277
def has_msys():
b914fc162545 tests: introduce 'hghave msys' to skip tests that would fail because of msys
Mads Kiilerich <mads@kiilerich.com>
parents: 1027
diff changeset
   278
    return os.getenv('MSYSTEM')
b914fc162545 tests: introduce 'hghave msys' to skip tests that would fail because of msys
Mads Kiilerich <mads@kiilerich.com>
parents: 1027
diff changeset
   279
1278
9ff91ff2797d tests: AIX can't handle negative date in test-dirstate.t
Jim Hague <jim.hague@acm.org>
parents: 1190
diff changeset
   280
def has_aix():
9ff91ff2797d tests: AIX can't handle negative date in test-dirstate.t
Jim Hague <jim.hague@acm.org>
parents: 1190
diff changeset
   281
    return sys.platform.startswith("aix")
9ff91ff2797d tests: AIX can't handle negative date in test-dirstate.t
Jim Hague <jim.hague@acm.org>
parents: 1190
diff changeset
   282
1300
bf0c37b32582 hghave: add "absimport" feature to check "absolute_import" in __future__
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 1279
diff changeset
   283
def has_absimport():
bf0c37b32582 hghave: add "absimport" feature to check "absolute_import" in __future__
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 1279
diff changeset
   284
    import __future__
bf0c37b32582 hghave: add "absimport" feature to check "absolute_import" in __future__
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 1279
diff changeset
   285
    from mercurial import util
bf0c37b32582 hghave: add "absimport" feature to check "absolute_import" in __future__
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 1279
diff changeset
   286
    return util.safehasattr(__future__, "absolute_import")
bf0c37b32582 hghave: add "absimport" feature to check "absolute_import" in __future__
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 1279
diff changeset
   287
1301
761641fc16a6 hghave: add "py3k" feature to check whether test runs with Python 3.x
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 1300
diff changeset
   288
def has_py3k():
761641fc16a6 hghave: add "py3k" feature to check whether test runs with Python 3.x
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 1300
diff changeset
   289
    return 3 == sys.version_info[0]
761641fc16a6 hghave: add "py3k" feature to check whether test runs with Python 3.x
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 1300
diff changeset
   290
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   291
checks = {
1091
15dc93f78ecd tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 1089
diff changeset
   292
    "true": (lambda: True, "yak shaving"),
15dc93f78ecd tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 1089
diff changeset
   293
    "false": (lambda: False, "nail clipper"),
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   294
    "baz": (has_baz, "GNU Arch baz client"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   295
    "bzr": (has_bzr, "Canonical's Bazaar client"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   296
    "bzr114": (has_bzr114, "Canonical's Bazaar client >= 1.14"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   297
    "cacheable": (has_cacheable_fs, "cacheable filesystem"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   298
    "cvs": (has_cvs, "cvs client/server"),
1190
ecb744c2a199 hghave: introduce a test (unused) for cvs >= 1.12
Bryan O'Sullivan <bryano@fb.com>
parents: 1136
diff changeset
   299
    "cvs112": (has_cvs112, "cvs client/server >= 1.12"),
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   300
    "darcs": (has_darcs, "darcs client"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   301
    "docutils": (has_docutils, "Docutils text processing library"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   302
    "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   303
    "execbit": (has_executablebit, "executable bit"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   304
    "fifo": (has_fifo, "named pipes"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   305
    "gettext": (has_gettext, "GNU Gettext (msgfmt)"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   306
    "git": (has_git, "git command line client"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   307
    "gpg": (has_gpg, "gpg client"),
1102
51afb47e2399 tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 1101
diff changeset
   308
    "hardlink": (has_hardlink, "hardlinks"),
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   309
    "icasefs": (has_icasefs, "case insensitive file system"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   310
    "inotify": (has_inotify, "inotify extension support"),
1133
82f74372516e test-http-branchmap: enable on Windows
Patrick Mezard <patrick@mezard.eu>
parents: 1105
diff changeset
   311
    "killdaemons": (has_killdaemons, 'killdaemons.py support'),
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   312
    "lsprof": (has_lsprof, "python lsprof module"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   313
    "mtn": (has_mtn, "monotone client (>= 1.0)"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   314
    "outer-repo": (has_outer_repo, "outer repo"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   315
    "p4": (has_p4, "Perforce server and client"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   316
    "pyflakes": (has_pyflakes, "Pyflakes python linter"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   317
    "pygments": (has_pygments, "Pygments source highlighting library"),
1303
94e35118a756 tests: skip tests that require not having root (issue4089)
Matt Mackall <mpm@selenic.com>
parents: 1301
diff changeset
   318
    "root": (has_root, "root permissions"),
1014
58b7f58ae08c tests: use 'hghave serve' to guard tests that requires serve daemon management
Mads Kiilerich <mads@kiilerich.com>
parents: 1013
diff changeset
   319
    "serve": (has_serve, "platform and python can manage 'hg serve -d'"),
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   320
    "ssl": (has_ssl, "python >= 2.6 ssl module and python OpenSSL"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   321
    "svn": (has_svn, "subversion client and admin tools"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   322
    "svn13": (has_svn13, "subversion client and admin tools >= 1.3"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   323
    "svn15": (has_svn15, "subversion client and admin tools >= 1.5"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   324
    "svn-bindings": (has_svn_bindings, "subversion python bindings"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   325
    "symlink": (has_symlink, "symbolic links"),
1013
e00f51032041 tests: use 'hghave system-sh' to guard tests that requires sh in system()
Mads Kiilerich <mads@kiilerich.com>
parents: 1012
diff changeset
   326
    "system-sh": (has_system_sh, "system() uses sh"),
1027
f8c2547c8f16 tests: skip color test on platforms without tic
Mads Kiilerich <mads@kiilerich.com>
parents: 1014
diff changeset
   327
    "tic": (has_tic, "terminfo compiler"),
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   328
    "tla": (has_tla, "GNU Arch tla client"),
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   329
    "unix-permissions": (has_unix_permissions, "unix-style permissions"),
1012
018ef69bbe2f tests: use 'hghave no-windows' to avoid testing reserved file names on windows
Mads Kiilerich <mads@kiilerich.com>
parents: 1010
diff changeset
   330
    "windows": (has_windows, "Windows"),
1031
b914fc162545 tests: introduce 'hghave msys' to skip tests that would fail because of msys
Mads Kiilerich <mads@kiilerich.com>
parents: 1027
diff changeset
   331
    "msys": (has_msys, "Windows with MSYS"),
1278
9ff91ff2797d tests: AIX can't handle negative date in test-dirstate.t
Jim Hague <jim.hague@acm.org>
parents: 1190
diff changeset
   332
    "aix": (has_aix, "AIX"),
1300
bf0c37b32582 hghave: add "absimport" feature to check "absolute_import" in __future__
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 1279
diff changeset
   333
    "absimport": (has_absimport, "absolute_import in __future__"),
1301
761641fc16a6 hghave: add "py3k" feature to check whether test runs with Python 3.x
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 1300
diff changeset
   334
    "py3k": (has_py3k, "running with Python 3.x"),
1007
4fad25af75dd Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
   335
}