Mercurial > hg
comparison tests/test-lock.py @ 26384:ad6e56d01c30
test-lock.py: add a lock wrapper that allows faking the PID
This will be used in upcoming patches to create locks that appear as if they're
being created by child processes.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Thu, 24 Sep 2015 20:22:59 -0700 |
parents | b673e89affc9 |
children | fb1a424e8bff |
comparison
equal
deleted
inserted
replaced
26383:0fceb34806e1 | 26384:ad6e56d01c30 |
---|---|
9 lock, | 9 lock, |
10 scmutil, | 10 scmutil, |
11 ) | 11 ) |
12 | 12 |
13 testlockname = 'testlock' | 13 testlockname = 'testlock' |
14 | |
15 class lockwrapper(lock.lock): | |
16 def __init__(self, pidoffset, *args, **kwargs): | |
17 # lock.lock.__init__() calls lock(), so the pidoffset assignment needs | |
18 # to be earlier | |
19 self._pidoffset = pidoffset | |
20 super(lockwrapper, self).__init__(*args, **kwargs) | |
21 def _getpid(self): | |
22 return os.getpid() + self._pidoffset | |
14 | 23 |
15 class teststate(object): | 24 class teststate(object): |
16 def __init__(self, testcase, dir): | 25 def __init__(self, testcase, dir): |
17 self._testcase = testcase | 26 self._testcase = testcase |
18 self._acquirecalled = False | 27 self._acquirecalled = False |