dirstate: test a `hg status` raced by a `hg add` stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 24 Feb 2023 16:12:01 +0100
branchstable
changeset 50216 02bf2f94a04c
parent 50215 ae61851e6fe2
child 50217 718fcccae326
dirstate: test a `hg status` raced by a `hg add` This shows that `rhg` is misbehaving here.
tests/test-dirstate-status-write-race.t
--- 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 ..