test: use a more direct form of interruption in fncache "recover" testing
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 07 Feb 2023 15:27:37 +0100
changeset 49992 420fad6bdec5
parent 49991 3997c64eff8b
child 49993 2f348babe30d
test: use a more direct form of interruption in fncache "recover" testing The previous test was relying on implementation details and harder to maintain. The new version is closer to the initial intend : "What happens if the process die without cleanup". This change is motivated by further changes around the transaction and dirstate logic that would break the fragile equilibrium that existed before this patch. Making this change early make it easier to review on its own and remove noise in future larger changes.
tests/test-fncache.t
--- a/tests/test-fncache.t	Tue Feb 07 13:14:59 2023 +0100
+++ b/tests/test-fncache.t	Tue Feb 07 15:27:37 2023 +0100
@@ -304,6 +304,7 @@
 
   $ cat > ../exceptionext.py <<EOF
   > import os
+  > import signal
   > from mercurial import (
   >   commands,
   >   error,
@@ -315,19 +316,14 @@
   > def trwrapper(orig, self, *args, **kwargs):
   >     tr = orig(self, *args, **kwargs)
   >     def fail(tr):
-  >         raise error.Abort(b"forced transaction failure")
+  >         os.kill(os.getpid(), signal.SIGKILL)
   >     # zzz prefix to ensure it sorted after store.write
   >     tr.addfinalize(b'zzz-forcefails', fail)
   >     return tr
   > 
-  > def abortwrapper(orig, self, *args, **kwargs):
-  >     raise error.Abort(b"forced transaction failure")
-  > 
   > def uisetup(ui):
   >     extensions.wrapfunction(localrepo.localrepository, 'transaction',
   >                             trwrapper)
-  >     extensions.wrapfunction(transaction.transaction, '_abort',
-  >                             abortwrapper)
   > 
   > cmdtable = {}
   > 
@@ -339,8 +335,12 @@
 
   $ hg up -q 1
   $ touch z
-  $ hg ci -qAm z 2>/dev/null
-  [255]
+# Cannot rely on the return code value as chg use a different one.
+# So we use a `|| echo` trick
+# XXX-CHG fixing chg behavior would be nice here.
+  $ hg ci -qAm z || echo "He's Dead, Jim." 2>/dev/null
+  Killed (?)
+  He's Dead, Jim.
   $ cat .hg/store/fncache | sort
   data/y.i
   data/z.i