test-lock.py: allow PID to be changed in test state
authorSiddharth Agarwal <sid0@fb.com>
Thu, 24 Sep 2015 20:40:00 -0700
changeset 26385 fb1a424e8bff
parent 26384 ad6e56d01c30
child 26386 146cccdb282b
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.
tests/test-lock.py
--- 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