changeset 26385:fb1a424e8bff

test-lock.py: allow PID to be changed in test state 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:40:00 -0700
parents ad6e56d01c30
children 146cccdb282b
files tests/test-lock.py
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-lock.py	Thu Sep 24 20:22:59 2015 -0700
+++ b/tests/test-lock.py	Thu Sep 24 20:40:00 2015 -0700
@@ -22,16 +22,18 @@
         return os.getpid() + self._pidoffset
 
 class teststate(object):
-    def __init__(self, testcase, dir):
+    def __init__(self, testcase, dir, pidoffset=0):
         self._testcase = testcase
         self._acquirecalled = False
         self._releasecalled = False
         self._postreleasecalled = False
         self.vfs = scmutil.vfs(dir, audit=False)
+        self._pidoffset = pidoffset
 
     def makelock(self, *args, **kwargs):
-        l = lock.lock(self.vfs, testlockname, releasefn=self.releasefn,
-                      acquirefn=self.acquirefn, *args, **kwargs)
+        l = lockwrapper(self._pidoffset, self.vfs, testlockname,
+                        releasefn=self.releasefn, acquirefn=self.acquirefn,
+                        *args, **kwargs)
         l.postrelease.append(self.postreleasefn)
         return l