Patchwork [5,of,7] test-lock.py: allow PID to be changed in test state

login
register
mail settings
Submitter Siddharth Agarwal
Date Sept. 25, 2015, 7 p.m.
Message ID <bb88105b0fe118eea54e.1443207639@dev6666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/10636/
State Accepted
Headers show

Comments

Siddharth Agarwal - Sept. 25, 2015, 7 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1443152400 25200
#      Thu Sep 24 20:40:00 2015 -0700
# Node ID bb88105b0fe118eea54e8043b999f9c813895bfa
# Parent  4c629e4a785b733bea314505fbdbe70704b704ba
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.

Patch

diff --git a/tests/test-lock.py b/tests/test-lock.py
--- a/tests/test-lock.py
+++ b/tests/test-lock.py
@@ -22,16 +22,18 @@  class lockwrapper(lock.lock):
         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