tests/test-lock-badness.t
branchstable
changeset 51497 9da3fcc5f70f
parent 50320 adecb1ab4a0d
--- a/tests/test-lock-badness.t	Mon Mar 11 13:36:25 2024 +0100
+++ b/tests/test-lock-badness.t	Mon Mar 11 16:05:28 2024 +0100
@@ -49,15 +49,32 @@
 
 One process waiting for another
 
-  $ cat > hooks.py << EOF
-  > import time
-  > def sleepone(**x): time.sleep(1)
-  > def sleephalf(**x): time.sleep(0.5)
+  $ SYNC_FILE_LOCKED="$TESTTMP/sync-file-locked"
+  $ export SYNC_FILE_LOCKED
+  $ SYNC_FILE_TRYING_LOCK="$TESTTMP/sync-file-trying-lock"
+  $ export SYNC_FILE_TRYING_LOCK
+  $ cat << EOF > locker.sh
+  > $RUNTESTDIR/testlib/wait-on-file 10 $SYNC_FILE_TRYING_LOCK $SYNC_FILE_LOCKED;
+  > EOF
+  $ cat << EOF > waiter.sh
+  > $RUNTESTDIR/testlib/wait-on-file 10 $SYNC_FILE_LOCKED;
   > EOF
+  $ clean_sync() {
+  >   rm -f "$SYNC_FILE_LOCKED"
+  >   rm -f "$SYNC_FILE_TRYING_LOCK"
+  > }
+
+
+  $ clean_sync
   $ echo b > b/b
-  $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
-  $ hg -R b up -q --config ui.timeout.warn=0 --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
-  > > preup-stdout 2>preup-stderr
+  $ hg -R b ci -A -m b \
+  >   --config hooks.precommit="sh $TESTTMP/locker.sh" \
+  >   > stdout &
+  $ hg -R b up -q \
+  >   --config ui.timeout.warn=0 \
+  >   --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
+  >   --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
+  >   > preup-stdout 2> preup-stderr
   $ wait
   $ cat preup-stdout
   $ cat preup-stderr
@@ -68,11 +85,16 @@
 
 On processs waiting on another, warning after a long time.
 
+  $ clean_sync
   $ echo b > b/c
-  $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
-  $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
-  > --config ui.timeout.warn=250 \
-  > > preup-stdout 2>preup-stderr
+  $ hg -R b ci -A -m b \
+  >   --config hooks.precommit="sh $TESTTMP/locker.sh" \
+  >   > stdout &
+  $ hg -R b up -q \
+  >   --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
+  >   --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
+  >   --config ui.timeout.warn=250 \
+  >   > preup-stdout 2> preup-stderr
   $ wait
   $ cat preup-stdout
   $ cat preup-stderr
@@ -81,11 +103,16 @@
 
 On processs waiting on another, warning disabled.
 
+  $ clean_sync
   $ echo b > b/d
-  $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
-  $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
-  > --config ui.timeout.warn=-1 \
-  > > preup-stdout 2>preup-stderr
+  $ hg -R b ci -A -m b \
+  >   --config hooks.precommit="sh $TESTTMP/locker.sh" \
+  >   > stdout &
+  $ hg -R b up -q \
+  >   --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
+  >   --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
+  >   --config ui.timeout.warn=-1 \
+  >   > preup-stdout 2>preup-stderr
   $ wait
   $ cat preup-stdout
   $ cat preup-stderr
@@ -96,14 +123,19 @@
 
 On processs waiting on another, warning after a long time (debug output on)
 
+  $ clean_sync
   $ echo b > b/e
-  $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
-  $ hg -R b up --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
-  > --config ui.timeout.warn=250 --debug\
-  > > preup-stdout 2>preup-stderr
+  $ hg -R b ci -A -m b \
+  >   --config hooks.precommit="sh $TESTTMP/locker.sh" \
+  >   > stdout &
+  $ hg -R b up \
+  >   --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
+  >   --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
+  >   --config ui.timeout.warn=250 --debug \
+  >   > preup-stdout 2>preup-stderr
   $ wait
   $ cat preup-stdout
-  calling hook pre-update: hghook_pre-update.sleephalf
+  running hook pre-update: sh $TESTTMP/waiter.sh
   waiting for lock on working directory of b held by process '*' on host '*' (glob)
   got lock after * seconds (glob)
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -113,14 +145,19 @@
 
 On processs waiting on another, warning disabled, (debug output on)
 
+  $ clean_sync
   $ echo b > b/f
-  $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
-  $ hg -R b up --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
-  > --config ui.timeout.warn=-1 --debug\
-  > > preup-stdout 2>preup-stderr
+  $ hg -R b ci -A -m b \
+  >   --config hooks.precommit="sh $TESTTMP/locker.sh" \
+  >   > stdout &
+  $ hg -R b up \
+  >   --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
+  >   --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
+  >   --config ui.timeout.warn=-1 --debug\
+  >   > preup-stdout 2>preup-stderr
   $ wait
   $ cat preup-stdout
-  calling hook pre-update: hghook_pre-update.sleephalf
+  running hook pre-update: sh $TESTTMP/waiter.sh
   waiting for lock on working directory of b held by process '*' on host '*' (glob)
   got lock after * seconds (glob)
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved