changeset 50216:02bf2f94a04c stable

dirstate: test a `hg status` raced by a `hg add` This shows that `rhg` is misbehaving here.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 24 Feb 2023 16:12:01 +0100
parents ae61851e6fe2
children 718fcccae326
files tests/test-dirstate-status-write-race.t
diffstat 1 files changed, 50 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-dirstate-status-write-race.t	Tue Feb 28 15:25:47 2023 +0100
+++ b/tests/test-dirstate-status-write-race.t	Fri Feb 24 16:12:01 2023 +0100
@@ -188,3 +188,53 @@
 
   $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting
   $ cd ..
+
+Actual Testing
+==============
+
+Race with a `hg add`
+-------------------
+
+  $ cp -a reference-repo race-with-add
+  $ cd race-with-add
+
+spin a `hg status` with some caches to update
+
+  $ touch -t 200001020001 f
+  $ hg st >$TESTTMP/status-race-lock.out 2>$TESTTMP/status-race-lock.log \
+  > --config rhg.on-unsupported=abort \
+  > --config devel.sync.status.pre-dirstate-write-file=$TESTTMP/status-race-lock \
+  > &
+  $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting
+
+Add a file
+
+  $ hg add dir/n
+  $ touch $TESTTMP/status-race-lock
+  $ wait
+
+The file should in a "added" state
+
+  $ hg status
+  A dir/n (no-rhg !)
+  A dir/n (missing-correct-output rhg !)
+  A dir/o
+  R dir/nested/m
+  ? dir/n (known-bad-output rhg !)
+  ? p
+  ? q
+
+The status process should return a consistent result and not crash.
+
+  $ cat $TESTTMP/status-race-lock.out
+  A dir/o
+  R dir/nested/m
+  ? dir/n
+  ? p
+  ? q
+  $ cat $TESTTMP/status-race-lock.log
+
+final cleanup
+
+  $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting
+  $ cd ..