# HG changeset patch # User Pierre-Yves David # Date 2023-02-07 14:27:37 # Node ID 420fad6bdec5ba5e638b86246c30a7509283f257 # Parent 3997c64eff8bc022452f4169e3fd14e63efd0ad1 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. diff --git a/tests/test-fncache.t b/tests/test-fncache.t --- a/tests/test-fncache.t +++ b/tests/test-fncache.t @@ -304,6 +304,7 @@ Aborted transactions can be recovered la $ cat > ../exceptionext.py < import os + > import signal > from mercurial import ( > commands, > error, @@ -315,19 +316,14 @@ Aborted transactions can be recovered la > 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 @@ Clean cached versions $ 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