tests/test-dirstate-status-write-race.t
branchstable
changeset 50224 e30b9e43be7e
parent 50223 3f34d800cc69
child 50225 53ca3e3bc013
--- a/tests/test-dirstate-status-write-race.t	Fri Feb 24 01:19:37 2023 +0100
+++ b/tests/test-dirstate-status-write-race.t	Sat Feb 25 06:11:14 2023 +0100
@@ -438,3 +438,50 @@
 
   $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting
   $ cd ..
+
+Race with the removal of an ambiguous file
+----------------------รจ-------------------
+
+  $ cp -a reference-repo race-with-remove
+  $ cd race-with-remove
+
+spin a `hg status` with some caches to update
+
+  $ touch -t 200001010035 dir2/l
+  $ 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
+
+remove that same file
+
+  $ hg $d2args remove dir2/l
+  $ touch $TESTTMP/status-race-lock
+  $ wait
+
+file should be marked as removed
+
+  $ hg status
+  A dir/o
+  R dir/nested/m
+  R dir2/l
+  ? dir/n
+  ? 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
+  abort: when reading $TESTTMP/race-with-remove/dir2/l: $ENOENT$ (known-bad-output rhg !)
+
+final cleanup
+
+  $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting
+  $ cd ..