From patchwork Sat Apr 15 10:18:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4, of, 4] worker: print traceback for uncaught exception unconditionally From: Yuya Nishihara X-Patchwork-Id: 20215 Message-Id: <7c455aa99683ec6f7f24.1492251518@mimosa> To: mercurial-devel@mercurial-scm.org Date: Sat, 15 Apr 2017 19:18:38 +0900 # HG changeset patch # User Yuya Nishihara # Date 1492229095 -32400 # Sat Apr 15 13:04:55 2017 +0900 # Node ID 7c455aa99683ec6f7f24c24e11aaadfb3fe32fe3 # Parent 535303fbc0cbdaa0c02a5aec441625c6e9b7b07d worker: print traceback for uncaught exception unconditionally This is what a Python interpreter would do if there were no os._exit(). diff --git a/mercurial/worker.py b/mercurial/worker.py --- a/mercurial/worker.py +++ b/mercurial/worker.py @@ -159,7 +159,7 @@ def _posixworker(ui, func, staticargs, a os._exit(255) except: # never return, therefore no re-raises try: - ui.traceback() + ui.traceback(force=True) ui.flush() finally: os._exit(255) diff --git a/tests/test-worker.t b/tests/test-worker.t --- a/tests/test-worker.t +++ b/tests/test-worker.t @@ -13,12 +13,18 @@ Test UI worker interaction > # by first worker for test stability > raise error.Abort('known exception') > return runme(ui, []) + > def exc(ui, args): + > if args[0] == 0: + > # by first worker for test stability + > raise Exception('unknown exception') + > return runme(ui, []) > def runme(ui, args): > for arg in args: > ui.status('run\n') > yield 1, arg > functable = { > 'abort': abort, + > 'exc': exc, > 'runme': runme, > } > cmdtable = {} @@ -76,3 +82,9 @@ Known exception should be caught, but pr > test 100000.0 abort --traceback 2>&1 | grep '^Traceback' Traceback (most recent call last): Traceback (most recent call last): + +Traceback must be printed for unknown exceptions + + $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=2' \ + > test 100000.0 exc 2>&1 | grep '^Traceback' + Traceback (most recent call last):