Show More
@@ -1,80 +1,85 b'' | |||
|
1 | 1 | #require no-windows |
|
2 | 2 | |
|
3 | 3 | ATTENTION: logtoprocess runs commands asynchronously. Be sure to append "| cat" |
|
4 | 4 | to hg commands, to wait for the output, if you want to test its output. |
|
5 | 5 | Otherwise the test will be flaky. |
|
6 | 6 | |
|
7 | 7 | Test if logtoprocess correctly captures command-related log calls. |
|
8 | 8 | |
|
9 | 9 | $ hg init |
|
10 | 10 | $ cat > $TESTTMP/foocommand.py << EOF |
|
11 | 11 | > from __future__ import absolute_import |
|
12 | 12 | > from mercurial import registrar |
|
13 | 13 | > cmdtable = {} |
|
14 | 14 | > command = registrar.command(cmdtable) |
|
15 | > configtable = {} | |
|
16 | > configitem = registrar.configitem(configtable) | |
|
17 | > configitem('logtoprocess', 'foo', | |
|
18 | > default=None, | |
|
19 | > ) | |
|
15 | 20 | > @command(b'foo', []) |
|
16 | 21 | > def foo(ui, repo): |
|
17 | 22 | > ui.log('foo', 'a message: %(bar)s\n', bar='spam') |
|
18 | 23 | > EOF |
|
19 | 24 | $ cp $HGRCPATH $HGRCPATH.bak |
|
20 | 25 | $ cat >> $HGRCPATH << EOF |
|
21 | 26 | > [extensions] |
|
22 | 27 | > logtoprocess= |
|
23 | 28 | > foocommand=$TESTTMP/foocommand.py |
|
24 | 29 | > [logtoprocess] |
|
25 | 30 | > command=echo 'logtoprocess command output:'; |
|
26 | 31 | > echo "\$EVENT"; |
|
27 | 32 | > echo "\$MSG1"; |
|
28 | 33 | > echo "\$MSG2" |
|
29 | 34 | > commandfinish=echo 'logtoprocess commandfinish output:'; |
|
30 | 35 | > echo "\$EVENT"; |
|
31 | 36 | > echo "\$MSG1"; |
|
32 | 37 | > echo "\$MSG2"; |
|
33 | 38 | > echo "\$MSG3" |
|
34 | 39 | > foo=echo 'logtoprocess foo output:'; |
|
35 | 40 | > echo "\$EVENT"; |
|
36 | 41 | > echo "\$MSG1"; |
|
37 | 42 | > echo "\$OPT_BAR" |
|
38 | 43 | > EOF |
|
39 | 44 | |
|
40 | 45 | Running a command triggers both a ui.log('command') and a |
|
41 | 46 | ui.log('commandfinish') call. The foo command also uses ui.log. |
|
42 | 47 | |
|
43 | 48 | Use sort to avoid ordering issues between the various processes we spawn: |
|
44 | 49 | $ hg foo | cat | sort |
|
45 | 50 | |
|
46 | 51 | |
|
47 | 52 | |
|
48 | 53 | (chg !) |
|
49 | 54 | 0 |
|
50 | 55 | a message: spam |
|
51 | 56 | command |
|
52 | 57 | command (chg !) |
|
53 | 58 | commandfinish |
|
54 | 59 | foo |
|
55 | 60 | foo |
|
56 | 61 | foo |
|
57 | 62 | foo |
|
58 | 63 | foo exited 0 after * seconds (glob) |
|
59 | 64 | logtoprocess command output: |
|
60 | 65 | logtoprocess command output: (chg !) |
|
61 | 66 | logtoprocess commandfinish output: |
|
62 | 67 | logtoprocess foo output: |
|
63 | 68 | serve --cmdserver chgunix * (glob) (chg !) |
|
64 | 69 | serve --cmdserver chgunix * (glob) (chg !) |
|
65 | 70 | spam |
|
66 | 71 | |
|
67 | 72 | Confirm that logging blocked time catches stdio properly: |
|
68 | 73 | $ cp $HGRCPATH.bak $HGRCPATH |
|
69 | 74 | $ cat >> $HGRCPATH << EOF |
|
70 | 75 | > [extensions] |
|
71 | 76 | > logtoprocess= |
|
72 | 77 | > pager= |
|
73 | 78 | > [logtoprocess] |
|
74 | 79 | > uiblocked=echo "\$EVENT stdio \$OPT_STDIO_BLOCKED ms command \$OPT_COMMAND_DURATION ms" |
|
75 | 80 | > [ui] |
|
76 | 81 | > logblockedtimes=True |
|
77 | 82 | > EOF |
|
78 | 83 | |
|
79 | 84 | $ hg log | cat |
|
80 | 85 | uiblocked stdio [0-9]+.[0-9]* ms command [0-9]+.[0-9]* ms (re) |
General Comments 0
You need to be logged in to leave comments.
Login now