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