##// END OF EJS Templates
testing: do not stop waiting if timeout is 0 (issue6541)...
Cédric Krier -
r48457:1bad89a6 default
parent child Browse files
Show More
@@ -1,37 +1,37 b''
1 from __future__ import (
1 from __future__ import (
2 absolute_import,
2 absolute_import,
3 division,
3 division,
4 )
4 )
5
5
6 import os
6 import os
7 import time
7 import time
8
8
9
9
10 # work around check-code complains
10 # work around check-code complains
11 #
11 #
12 # This is a simple log level module doing simple test related work, we can't
12 # This is a simple log level module doing simple test related work, we can't
13 # import more things, and we do not need it.
13 # import more things, and we do not need it.
14 environ = getattr(os, 'environ')
14 environ = getattr(os, 'environ')
15
15
16
16
17 def _timeout_factor():
17 def _timeout_factor():
18 """return the current modification to timeout"""
18 """return the current modification to timeout"""
19 default = int(environ.get('HGTEST_TIMEOUT_DEFAULT', 360))
19 default = int(environ.get('HGTEST_TIMEOUT_DEFAULT', 360))
20 current = int(environ.get('HGTEST_TIMEOUT', default))
20 current = int(environ.get('HGTEST_TIMEOUT', default))
21 if current == 0:
21 if current == 0:
22 return 1
22 return 1
23 return current / float(default)
23 return current / float(default)
24
24
25
25
26 def wait_file(path, timeout=10):
26 def wait_file(path, timeout=10):
27 timeout *= _timeout_factor()
27 timeout *= _timeout_factor()
28 start = time.time()
28 start = time.time()
29 while not os.path.exists(path):
29 while not os.path.exists(path):
30 if time.time() - start > timeout:
30 if timeout and time.time() - start > timeout:
31 raise RuntimeError(b"timed out waiting for file: %s" % path)
31 raise RuntimeError(b"timed out waiting for file: %s" % path)
32 time.sleep(0.01)
32 time.sleep(0.01)
33
33
34
34
35 def write_file(path, content=b''):
35 def write_file(path, content=b''):
36 with open(path, 'wb') as f:
36 with open(path, 'wb') as f:
37 f.write(content)
37 f.write(content)
General Comments 0
You need to be logged in to leave comments. Login now