##// END OF EJS Templates
test-lock: use synchronisation file instead of sleep...
marmoute -
r52390:9da3fcc5 stable
parent child Browse files
Show More
@@ -583,6 +583,11 b' default-type = "list_type"'
583 583
584 584 [[items]]
585 585 section = "devel"
586 name = "lock-wait-sync-file"
587 default = ""
588
589 [[items]]
590 section = "devel"
586 591 name = "persistent-nodemap"
587 592 default = false
588 593 documentation = """When true, revlogs use a special reference version of the \
@@ -3072,6 +3072,9 b' class localrepository:'
3072 3072 warntimeout = self.ui.configint(b"ui", b"timeout.warn")
3073 3073 # internal config: ui.signal-safe-lock
3074 3074 signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock')
3075 sync_file = self.ui.config(b'devel', b'lock-wait-sync-file')
3076 if not sync_file:
3077 sync_file = None
3075 3078
3076 3079 l = lockmod.trylock(
3077 3080 self.ui,
@@ -3083,6 +3086,7 b' class localrepository:'
3083 3086 acquirefn=acquirefn,
3084 3087 desc=desc,
3085 3088 signalsafe=signalsafe,
3089 devel_wait_sync_file=sync_file,
3086 3090 )
3087 3091 return l
3088 3092
@@ -115,6 +115,7 b' def trylock(ui, vfs, lockname, timeout, '
115 115
116 116 This function is responsible to issue warnings and or debug messages about
117 117 the held lock while trying to acquires it."""
118 devel_wait_file = kwargs.pop("devel_wait_sync_file", None)
118 119
119 120 def printwarning(printer, locker):
120 121 """issue the usual "waiting on lock" message through any channel"""
@@ -150,6 +151,11 b' def trylock(ui, vfs, lockname, timeout, '
150 151 l._trylock()
151 152 break
152 153 except error.LockHeld as inst:
154 if devel_wait_file is not None:
155 # create the file to signal we are waiting
156 with open(devel_wait_file, 'w'):
157 pass
158
153 159 if delay == debugidx:
154 160 printwarning(ui.debug, inst.locker)
155 161 if delay == warningidx:
@@ -49,15 +49,32 b' Test that raising an exception in the re'
49 49
50 50 One process waiting for another
51 51
52 $ cat > hooks.py << EOF
53 > import time
54 > def sleepone(**x): time.sleep(1)
55 > def sleephalf(**x): time.sleep(0.5)
52 $ SYNC_FILE_LOCKED="$TESTTMP/sync-file-locked"
53 $ export SYNC_FILE_LOCKED
54 $ SYNC_FILE_TRYING_LOCK="$TESTTMP/sync-file-trying-lock"
55 $ export SYNC_FILE_TRYING_LOCK
56 $ cat << EOF > locker.sh
57 > $RUNTESTDIR/testlib/wait-on-file 10 $SYNC_FILE_TRYING_LOCK $SYNC_FILE_LOCKED;
58 > EOF
59 $ cat << EOF > waiter.sh
60 > $RUNTESTDIR/testlib/wait-on-file 10 $SYNC_FILE_LOCKED;
56 61 > EOF
62 $ clean_sync() {
63 > rm -f "$SYNC_FILE_LOCKED"
64 > rm -f "$SYNC_FILE_TRYING_LOCK"
65 > }
66
67
68 $ clean_sync
57 69 $ echo b > b/b
58 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
59 $ hg -R b up -q --config ui.timeout.warn=0 --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
60 > > preup-stdout 2>preup-stderr
70 $ hg -R b ci -A -m b \
71 > --config hooks.precommit="sh $TESTTMP/locker.sh" \
72 > > stdout &
73 $ hg -R b up -q \
74 > --config ui.timeout.warn=0 \
75 > --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
76 > --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
77 > > preup-stdout 2> preup-stderr
61 78 $ wait
62 79 $ cat preup-stdout
63 80 $ cat preup-stderr
@@ -68,11 +85,16 b' One process waiting for another'
68 85
69 86 On processs waiting on another, warning after a long time.
70 87
88 $ clean_sync
71 89 $ echo b > b/c
72 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
73 $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
74 > --config ui.timeout.warn=250 \
75 > > preup-stdout 2>preup-stderr
90 $ hg -R b ci -A -m b \
91 > --config hooks.precommit="sh $TESTTMP/locker.sh" \
92 > > stdout &
93 $ hg -R b up -q \
94 > --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
95 > --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
96 > --config ui.timeout.warn=250 \
97 > > preup-stdout 2> preup-stderr
76 98 $ wait
77 99 $ cat preup-stdout
78 100 $ cat preup-stderr
@@ -81,11 +103,16 b' On processs waiting on another, warning '
81 103
82 104 On processs waiting on another, warning disabled.
83 105
106 $ clean_sync
84 107 $ echo b > b/d
85 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
86 $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
87 > --config ui.timeout.warn=-1 \
88 > > preup-stdout 2>preup-stderr
108 $ hg -R b ci -A -m b \
109 > --config hooks.precommit="sh $TESTTMP/locker.sh" \
110 > > stdout &
111 $ hg -R b up -q \
112 > --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
113 > --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
114 > --config ui.timeout.warn=-1 \
115 > > preup-stdout 2>preup-stderr
89 116 $ wait
90 117 $ cat preup-stdout
91 118 $ cat preup-stderr
@@ -96,14 +123,19 b' check we still print debug output'
96 123
97 124 On processs waiting on another, warning after a long time (debug output on)
98 125
126 $ clean_sync
99 127 $ echo b > b/e
100 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
101 $ hg -R b up --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
102 > --config ui.timeout.warn=250 --debug\
103 > > preup-stdout 2>preup-stderr
128 $ hg -R b ci -A -m b \
129 > --config hooks.precommit="sh $TESTTMP/locker.sh" \
130 > > stdout &
131 $ hg -R b up \
132 > --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
133 > --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
134 > --config ui.timeout.warn=250 --debug \
135 > > preup-stdout 2>preup-stderr
104 136 $ wait
105 137 $ cat preup-stdout
106 calling hook pre-update: hghook_pre-update.sleephalf
138 running hook pre-update: sh $TESTTMP/waiter.sh
107 139 waiting for lock on working directory of b held by process '*' on host '*' (glob)
108 140 got lock after * seconds (glob)
109 141 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -113,14 +145,19 b' On processs waiting on another, warning '
113 145
114 146 On processs waiting on another, warning disabled, (debug output on)
115 147
148 $ clean_sync
116 149 $ echo b > b/f
117 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
118 $ hg -R b up --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
119 > --config ui.timeout.warn=-1 --debug\
120 > > preup-stdout 2>preup-stderr
150 $ hg -R b ci -A -m b \
151 > --config hooks.precommit="sh $TESTTMP/locker.sh" \
152 > > stdout &
153 $ hg -R b up \
154 > --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
155 > --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
156 > --config ui.timeout.warn=-1 --debug\
157 > > preup-stdout 2>preup-stderr
121 158 $ wait
122 159 $ cat preup-stdout
123 calling hook pre-update: hghook_pre-update.sleephalf
160 running hook pre-update: sh $TESTTMP/waiter.sh
124 161 waiting for lock on working directory of b held by process '*' on host '*' (glob)
125 162 got lock after * seconds (glob)
126 163 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
General Comments 0
You need to be logged in to leave comments. Login now