comparison tests/hghave.py @ 16970:8be2a28cc782

tests/hghave: test that the inotify unix socket actually can be created Inotify do not work on FAT filesystems.
author Mads Kiilerich <mads@kiilerich.com>
date Fri, 15 Jun 2012 00:02:27 +0200
parents 6d1673107143
children 8aeb2f1ae94c
comparison
equal deleted inserted replaced
16969:6d1673107143 16970:8be2a28cc782
1 import os, stat 1 import os, stat, socket
2 import re 2 import re
3 import sys 3 import sys
4 import tempfile 4 import tempfile
5 5
6 tempprefix = 'hg-hghave-' 6 tempprefix = 'hg-hghave-'
93 os.remove(path) 93 os.remove(path)
94 94
95 def has_inotify(): 95 def has_inotify():
96 try: 96 try:
97 import hgext.inotify.linux.watcher 97 import hgext.inotify.linux.watcher
98 return True 98 except ImportError:
99 except ImportError: 99 return False
100 return False 100 name = tempfile.mktemp(dir='.', prefix=tempprefix)
101 sock = socket.socket(socket.AF_UNIX)
102 try:
103 sock.bind(name)
104 except socket.error, err:
105 return False
106 sock.close()
107 os.unlink(name)
108 return True
101 109
102 def has_fifo(): 110 def has_fifo():
103 if getattr(os, "mkfifo", None) is None: 111 if getattr(os, "mkfifo", None) is None:
104 return False 112 return False
105 name = tempfile.mktemp(dir='.', prefix=tempprefix) 113 name = tempfile.mktemp(dir='.', prefix=tempprefix)