comparison tests/test-worker.t @ 32041:38963a53ab0d

dispatch: print traceback in scmutil.callcatch() if --traceback specified Otherwise, traceback wouldn't be printed for a known exception occurred in worker processes.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 15 Apr 2017 13:02:34 +0900
parents 9d3d56aa1a9f
children 8f8ad0139b8b
comparison
equal deleted inserted replaced
32040:0fb78cb90ca7 32041:38963a53ab0d
2 2
3 $ cat > t.py <<EOF 3 $ cat > t.py <<EOF
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, runme, (ui,), range(8)) 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')
24 > EOF 35 > EOF
25 $ abspath=`pwd`/t.py 36 $ abspath=`pwd`/t.py
50 run 61 run
51 run 62 run
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):