Patchwork [8,of,8,v2] tests: mock getpid to reduce glob usage

login
register
mail settings
Submitter timeless@mozdev.org
Date Feb. 8, 2016, 6:15 a.m.
Message ID <e478b6be3c8fdf4cf61a.1454912110@waste.org>
Download mbox | patch
Permalink /patch/13043/
State Superseded
Commit e8ad56d95fbb0586e63c400e386d4af2c93ee9e8
Headers show

Comments

timeless@mozdev.org - Feb. 8, 2016, 6:15 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1454474224 0
#      Wed Feb 03 04:37:04 2016 +0000
# Node ID e478b6be3c8fdf4cf61ab764eb7fd5bb36b3bb80
# Parent  b4852035c31ec65a5ad4f936780e6ef1865091e5
tests: mock getpid to reduce glob usage

With util.getpid, it is now possible to define fixed pids.

Future iterations can define a map of pids on a locked
first come first serve basis to create a more realistic
harness, but for now this is good enough.

This applies to blackbox, but could apply to other
tests as well.

Patch

diff --git a/tests/mockblackbox.py b/tests/mockblackbox.py
--- a/tests/mockblackbox.py
+++ b/tests/mockblackbox.py
@@ -4,8 +4,11 @@ 
     return 0, 0
 def getuser():
     return 'bob'
+def getpid():
+    return 5000
 
 # mock the date and user apis so the output is always the same
 def uisetup(ui):
     util.makedate = makedate
     util.getuser = getuser
+    util.getpid = getpid
diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -108,7 +108,7 @@ 
   saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob)
   $ hg blackbox -l 6
   1970/01/01 00:00:00 bob (*)> strip tip (glob)
-  1970/01/01 00:00:00 bob (*)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob)
+  1970/01/01 00:00:00 bob (*)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg (glob)
   1970/01/01 00:00:00 bob (*)> updated base branch cache in * seconds (glob)
   1970/01/01 00:00:00 bob (*)> wrote base branch cache with 1 labels and 2 nodes (glob)
   1970/01/01 00:00:00 bob (*)> strip tip exited 0 after * seconds (glob)