Show More
@@ -255,7 +255,6 b' def _runcatch(req):' | |||||
255 | if '--debugger' in req.args: |
|
255 | if '--debugger' in req.args: | |
256 | traceback.print_exc() |
|
256 | traceback.print_exc() | |
257 | debugmortem[debugger](sys.exc_info()[2]) |
|
257 | debugmortem[debugger](sys.exc_info()[2]) | |
258 | ui.traceback() |
|
|||
259 | raise |
|
258 | raise | |
260 |
|
259 | |||
261 | return _callcatch(ui, _runcatchfunc) |
|
260 | return _callcatch(ui, _runcatchfunc) |
@@ -142,7 +142,11 b' def callcatch(ui, func):' | |||||
142 | and return an exit code accordingly. does not handle all exceptions. |
|
142 | and return an exit code accordingly. does not handle all exceptions. | |
143 | """ |
|
143 | """ | |
144 | try: |
|
144 | try: | |
|
145 | try: | |||
145 | return func() |
|
146 | return func() | |
|
147 | except: # re-raises | |||
|
148 | ui.traceback() | |||
|
149 | raise | |||
146 | # Global exception handling, alphabetically |
|
150 | # Global exception handling, alphabetically | |
147 | # Mercurial-specific first, followed by built-in and library exceptions |
|
151 | # Mercurial-specific first, followed by built-in and library exceptions | |
148 | except error.LockHeld as inst: |
|
152 | except error.LockHeld as inst: |
@@ -4,20 +4,31 b' Test UI worker interaction' | |||||
4 | > from __future__ import absolute_import, print_function |
|
4 | > from __future__ import absolute_import, print_function | |
5 | > from mercurial import ( |
|
5 | > from mercurial import ( | |
6 | > cmdutil, |
|
6 | > cmdutil, | |
|
7 | > error, | |||
7 | > ui as uimod, |
|
8 | > ui as uimod, | |
8 | > worker, |
|
9 | > worker, | |
9 | > ) |
|
10 | > ) | |
|
11 | > def abort(ui, args): | |||
|
12 | > if args[0] == 0: | |||
|
13 | > # by first worker for test stability | |||
|
14 | > raise error.Abort('known exception') | |||
|
15 | > return runme(ui, []) | |||
10 | > def runme(ui, args): |
|
16 | > def runme(ui, args): | |
11 | > for arg in args: |
|
17 | > for arg in args: | |
12 | > ui.status('run\n') |
|
18 | > ui.status('run\n') | |
13 | > yield 1, arg |
|
19 | > yield 1, arg | |
|
20 | > functable = { | |||
|
21 | > 'abort': abort, | |||
|
22 | > 'runme': runme, | |||
|
23 | > } | |||
14 | > cmdtable = {} |
|
24 | > cmdtable = {} | |
15 | > command = cmdutil.command(cmdtable) |
|
25 | > command = cmdutil.command(cmdtable) | |
16 | > @command('test', [], 'hg test [COST]') |
|
26 | > @command('test', [], 'hg test [COST] [FUNC]') | |
17 | > def t(ui, repo, cost=1.0): |
|
27 | > def t(ui, repo, cost=1.0, func='runme'): | |
18 | > cost = float(cost) |
|
28 | > cost = float(cost) | |
|
29 | > func = functable[func] | |||
19 | > ui.status('start\n') |
|
30 | > ui.status('start\n') | |
20 |
> runs = worker.worker(ui, cost, |
|
31 | > runs = worker.worker(ui, cost, func, (ui,), range(8)) | |
21 | > for n, i in runs: |
|
32 | > for n, i in runs: | |
22 | > pass |
|
33 | > pass | |
23 | > ui.status('done\n') |
|
34 | > ui.status('done\n') | |
@@ -52,3 +63,15 b' Run tests without worker by forcing a lo' | |||||
52 | run |
|
63 | run | |
53 | run |
|
64 | run | |
54 | done |
|
65 | done | |
|
66 | ||||
|
67 | Known exception should be caught, but printed if --traceback is enabled | |||
|
68 | ||||
|
69 | $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=2' \ | |||
|
70 | > test 100000.0 abort | |||
|
71 | start | |||
|
72 | abort: known exception | |||
|
73 | done | |||
|
74 | ||||
|
75 | $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=2' \ | |||
|
76 | > test 100000.0 abort --traceback 2>&1 | grep '^Traceback' | |||
|
77 | Traceback (most recent call last): |
General Comments 0
You need to be logged in to leave comments.
Login now