author | Yuya Nishihara <yuya@tcha.org> |
Sat, 15 Apr 2017 13:02:34 +0900 | |
changeset 32041 | 38963a53ab0d |
parent 31696 | 9d3d56aa1a9f |
child 32042 | 8f8ad0139b8b |
permissions | -rw-r--r-- |
31696
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
1 |
Test UI worker interaction |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
2 |
|
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
3 |
$ cat > t.py <<EOF |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
4 |
> from __future__ import absolute_import, print_function |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
5 |
> from mercurial import ( |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
6 |
> cmdutil, |
32041
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
7 |
> error, |
31696
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
8 |
> ui as uimod, |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
9 |
> worker, |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
10 |
> ) |
32041
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
11 |
> def abort(ui, args): |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
12 |
> if args[0] == 0: |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
13 |
> # by first worker for test stability |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
14 |
> raise error.Abort('known exception') |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
15 |
> return runme(ui, []) |
31696
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
16 |
> def runme(ui, args): |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
17 |
> for arg in args: |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
18 |
> ui.status('run\n') |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
19 |
> yield 1, arg |
32041
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
20 |
> functable = { |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
21 |
> 'abort': abort, |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
22 |
> 'runme': runme, |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
23 |
> } |
31696
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
24 |
> cmdtable = {} |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
25 |
> command = cmdutil.command(cmdtable) |
32041
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
26 |
> @command('test', [], 'hg test [COST] [FUNC]') |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
27 |
> def t(ui, repo, cost=1.0, func='runme'): |
31696
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
28 |
> cost = float(cost) |
32041
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
29 |
> func = functable[func] |
31696
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
30 |
> ui.status('start\n') |
32041
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
31 |
> runs = worker.worker(ui, cost, func, (ui,), range(8)) |
31696
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
32 |
> for n, i in runs: |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
33 |
> pass |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
34 |
> ui.status('done\n') |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
35 |
> EOF |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
36 |
$ abspath=`pwd`/t.py |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
37 |
$ hg init |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
38 |
|
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
39 |
Run tests with worker enable by forcing a heigh cost |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
40 |
|
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
41 |
$ hg --config "extensions.t=$abspath" test 100000.0 |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
42 |
start |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
43 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
44 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
45 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
46 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
47 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
48 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
49 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
50 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
51 |
done |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
52 |
|
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
53 |
Run tests without worker by forcing a low cost |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
54 |
|
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
55 |
$ hg --config "extensions.t=$abspath" test 0.0000001 |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
56 |
start |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
57 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
58 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
59 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
60 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
61 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
62 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
63 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
64 |
run |
9d3d56aa1a9f
worker: flush ui buffers before running the worker
David Soria Parra <davidsp@fb.com>
parents:
diff
changeset
|
65 |
done |
32041
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
66 |
|
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
67 |
Known exception should be caught, but printed if --traceback is enabled |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
68 |
|
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
69 |
$ hg --config "extensions.t=$abspath" --config 'worker.numcpus=2' \ |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
70 |
> test 100000.0 abort |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
71 |
start |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
72 |
abort: known exception |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
73 |
done |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
74 |
|
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
75 |
$ hg --config "extensions.t=$abspath" --config 'worker.numcpus=2' \ |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
76 |
> test 100000.0 abort --traceback 2>&1 | grep '^Traceback' |
38963a53ab0d
dispatch: print traceback in scmutil.callcatch() if --traceback specified
Yuya Nishihara <yuya@tcha.org>
parents:
31696
diff
changeset
|
77 |
Traceback (most recent call last): |