Show More
@@ -1,124 +1,124 b'' | |||||
1 | #require no-windows |
|
1 | #require no-windows | |
2 |
|
2 | |||
3 | ATTENTION: logtoprocess runs commands asynchronously. Be sure to append "| cat" |
|
3 | ATTENTION: logtoprocess runs commands asynchronously. Be sure to append "| cat" | |
4 | to hg commands, to wait for the output, if you want to test its output. |
|
4 | to hg commands, to wait for the output, if you want to test its output. | |
5 | Otherwise the test will be flaky. |
|
5 | Otherwise the test will be flaky. | |
6 |
|
6 | |||
7 | Test if logtoprocess correctly captures command-related log calls. |
|
7 | Test if logtoprocess correctly captures command-related log calls. | |
8 |
|
8 | |||
9 | $ hg init |
|
9 | $ hg init | |
10 | $ cat > $TESTTMP/foocommand.py << EOF |
|
10 | $ cat > $TESTTMP/foocommand.py << EOF | |
11 | > from __future__ import absolute_import |
|
11 | > from __future__ import absolute_import | |
12 | > from mercurial import registrar |
|
12 | > from mercurial import registrar | |
13 | > cmdtable = {} |
|
13 | > cmdtable = {} | |
14 | > command = registrar.command(cmdtable) |
|
14 | > command = registrar.command(cmdtable) | |
15 | > configtable = {} |
|
15 | > configtable = {} | |
16 | > configitem = registrar.configitem(configtable) |
|
16 | > configitem = registrar.configitem(configtable) | |
17 | > configitem('logtoprocess', 'foo', |
|
17 | > configitem('logtoprocess', 'foo', | |
18 | > default=None, |
|
18 | > default=None, | |
19 | > ) |
|
19 | > ) | |
20 | > @command(b'foo', []) |
|
20 | > @command(b'foo', []) | |
21 | > def foo(ui, repo): |
|
21 | > def foo(ui, repo): | |
22 | > ui.log('foo', 'a message: %(bar)s\n', bar='spam') |
|
22 | > ui.log('foo', 'a message: %(bar)s\n', bar='spam') | |
23 | > EOF |
|
23 | > EOF | |
24 | $ cp $HGRCPATH $HGRCPATH.bak |
|
24 | $ cp $HGRCPATH $HGRCPATH.bak | |
25 | $ cat >> $HGRCPATH << EOF |
|
25 | $ cat >> $HGRCPATH << EOF | |
26 | > [extensions] |
|
26 | > [extensions] | |
27 | > logtoprocess= |
|
27 | > logtoprocess= | |
28 | > foocommand=$TESTTMP/foocommand.py |
|
28 | > foocommand=$TESTTMP/foocommand.py | |
29 | > [logtoprocess] |
|
29 | > [logtoprocess] | |
30 | > command=(echo 'logtoprocess command output:'; |
|
30 | > command=(echo 'logtoprocess command output:'; | |
31 | > echo "\$EVENT"; |
|
31 | > echo "\$EVENT"; | |
32 | > echo "\$MSG1"; |
|
32 | > echo "\$MSG1"; | |
33 | > echo "\$MSG2") > $TESTTMP/command.log |
|
33 | > echo "\$MSG2") > $TESTTMP/command.log | |
34 | > commandfinish=(echo 'logtoprocess commandfinish output:'; |
|
34 | > commandfinish=(echo 'logtoprocess commandfinish output:'; | |
35 | > echo "\$EVENT"; |
|
35 | > echo "\$EVENT"; | |
36 | > echo "\$MSG1"; |
|
36 | > echo "\$MSG1"; | |
37 | > echo "\$MSG2"; |
|
37 | > echo "\$MSG2"; | |
38 | > echo "\$MSG3") > $TESTTMP/commandfinish.log |
|
38 | > echo "\$MSG3") > $TESTTMP/commandfinish.log | |
39 | > foo=(echo 'logtoprocess foo output:'; |
|
39 | > foo=(echo 'logtoprocess foo output:'; | |
40 | > echo "\$EVENT"; |
|
40 | > echo "\$EVENT"; | |
41 | > echo "\$MSG1"; |
|
41 | > echo "\$MSG1"; | |
42 | > echo "\$OPT_BAR") > $TESTTMP/foo.log |
|
42 | > echo "\$OPT_BAR") > $TESTTMP/foo.log | |
43 | > EOF |
|
43 | > EOF | |
44 |
|
44 | |||
45 | Running a command triggers both a ui.log('command') and a |
|
45 | Running a command triggers both a ui.log('command') and a | |
46 | ui.log('commandfinish') call. The foo command also uses ui.log. |
|
46 | ui.log('commandfinish') call. The foo command also uses ui.log. | |
47 |
|
47 | |||
48 | Use sort to avoid ordering issues between the various processes we spawn: |
|
48 | Use sort to avoid ordering issues between the various processes we spawn: | |
49 | $ hg foo |
|
49 | $ hg foo | |
50 |
$ sleep |
|
50 | $ sleep 1 | |
51 | $ cat $TESTTMP/command.log | sort |
|
51 | $ cat $TESTTMP/command.log | sort | |
52 |
|
52 | |||
53 | command |
|
53 | command | |
54 | foo |
|
54 | foo | |
55 | foo |
|
55 | foo | |
56 | logtoprocess command output: |
|
56 | logtoprocess command output: | |
57 |
|
57 | |||
58 | #if no-chg |
|
58 | #if no-chg | |
59 | $ cat $TESTTMP/commandfinish.log | sort |
|
59 | $ cat $TESTTMP/commandfinish.log | sort | |
60 |
|
60 | |||
61 | 0 |
|
61 | 0 | |
62 | commandfinish |
|
62 | commandfinish | |
63 | foo |
|
63 | foo | |
64 | foo exited 0 after * seconds (glob) |
|
64 | foo exited 0 after * seconds (glob) | |
65 | logtoprocess commandfinish output: |
|
65 | logtoprocess commandfinish output: | |
66 | $ cat $TESTTMP/foo.log | sort |
|
66 | $ cat $TESTTMP/foo.log | sort | |
67 |
|
67 | |||
68 | a message: spam |
|
68 | a message: spam | |
69 | foo |
|
69 | foo | |
70 | logtoprocess foo output: |
|
70 | logtoprocess foo output: | |
71 | spam |
|
71 | spam | |
72 | #endif |
|
72 | #endif | |
73 |
|
73 | |||
74 | Confirm that logging blocked time catches stdio properly: |
|
74 | Confirm that logging blocked time catches stdio properly: | |
75 | $ cp $HGRCPATH.bak $HGRCPATH |
|
75 | $ cp $HGRCPATH.bak $HGRCPATH | |
76 | $ cat >> $HGRCPATH << EOF |
|
76 | $ cat >> $HGRCPATH << EOF | |
77 | > [extensions] |
|
77 | > [extensions] | |
78 | > logtoprocess= |
|
78 | > logtoprocess= | |
79 | > pager= |
|
79 | > pager= | |
80 | > [logtoprocess] |
|
80 | > [logtoprocess] | |
81 | > uiblocked=echo "\$EVENT stdio \$OPT_STDIO_BLOCKED ms command \$OPT_COMMAND_DURATION ms" > $TESTTMP/uiblocked.log |
|
81 | > uiblocked=echo "\$EVENT stdio \$OPT_STDIO_BLOCKED ms command \$OPT_COMMAND_DURATION ms" > $TESTTMP/uiblocked.log | |
82 | > [ui] |
|
82 | > [ui] | |
83 | > logblockedtimes=True |
|
83 | > logblockedtimes=True | |
84 | > EOF |
|
84 | > EOF | |
85 |
|
85 | |||
86 | $ hg log |
|
86 | $ hg log | |
87 |
$ sleep |
|
87 | $ sleep 1 | |
88 | $ cat $TESTTMP/uiblocked.log |
|
88 | $ cat $TESTTMP/uiblocked.log | |
89 | uiblocked stdio [0-9]+.[0-9]* ms command [0-9]+.[0-9]* ms (re) |
|
89 | uiblocked stdio [0-9]+.[0-9]* ms command [0-9]+.[0-9]* ms (re) | |
90 |
|
90 | |||
91 | Try to confirm that pager wait on logtoprocess: |
|
91 | Try to confirm that pager wait on logtoprocess: | |
92 |
|
92 | |||
93 | Add a script that wait on a file to appears for 5 seconds, if it sees it touch |
|
93 | Add a script that wait on a file to appears for 5 seconds, if it sees it touch | |
94 | another file or die after 5 seconds. If the scripts is awaited by hg, the |
|
94 | another file or die after 5 seconds. If the scripts is awaited by hg, the | |
95 | script will die after the timeout before we could touch the file and the |
|
95 | script will die after the timeout before we could touch the file and the | |
96 | resulting file will not exists. If not, we will touch the file and see it. |
|
96 | resulting file will not exists. If not, we will touch the file and see it. | |
97 |
|
97 | |||
98 | $ cat > $TESTTMP/wait-output.sh << EOF |
|
98 | $ cat > $TESTTMP/wait-output.sh << EOF | |
99 | > #!/bin/sh |
|
99 | > #!/bin/sh | |
100 | > for i in \`$TESTDIR/seq.py 50\`; do |
|
100 | > for i in \`$TESTDIR/seq.py 50\`; do | |
101 | > if [ -f "$TESTTMP/wait-for-touched" ]; |
|
101 | > if [ -f "$TESTTMP/wait-for-touched" ]; | |
102 | > then |
|
102 | > then | |
103 | > touch "$TESTTMP/touched"; |
|
103 | > touch "$TESTTMP/touched"; | |
104 | > break; |
|
104 | > break; | |
105 | > else |
|
105 | > else | |
106 | > sleep 0.1; |
|
106 | > sleep 0.1; | |
107 | > fi |
|
107 | > fi | |
108 | > done |
|
108 | > done | |
109 | > EOF |
|
109 | > EOF | |
110 | $ chmod +x $TESTTMP/wait-output.sh |
|
110 | $ chmod +x $TESTTMP/wait-output.sh | |
111 |
|
111 | |||
112 | $ cat >> $HGRCPATH << EOF |
|
112 | $ cat >> $HGRCPATH << EOF | |
113 | > [extensions] |
|
113 | > [extensions] | |
114 | > logtoprocess= |
|
114 | > logtoprocess= | |
115 | > pager= |
|
115 | > pager= | |
116 | > [logtoprocess] |
|
116 | > [logtoprocess] | |
117 | > commandfinish=$TESTTMP/wait-output.sh |
|
117 | > commandfinish=$TESTTMP/wait-output.sh | |
118 | > EOF |
|
118 | > EOF | |
119 | $ hg version -q --pager=always |
|
119 | $ hg version -q --pager=always | |
120 | Mercurial Distributed SCM (version *) (glob) |
|
120 | Mercurial Distributed SCM (version *) (glob) | |
121 | $ touch $TESTTMP/wait-for-touched |
|
121 | $ touch $TESTTMP/wait-for-touched | |
122 | $ sleep 0.2 |
|
122 | $ sleep 0.2 | |
123 | $ test -f $TESTTMP/touched && echo "SUCCESS Pager is not waiting on ltp" || echo "FAIL Pager is waiting on ltp" |
|
123 | $ test -f $TESTTMP/touched && echo "SUCCESS Pager is not waiting on ltp" || echo "FAIL Pager is waiting on ltp" | |
124 | SUCCESS Pager is not waiting on ltp |
|
124 | SUCCESS Pager is not waiting on ltp |
General Comments 0
You need to be logged in to leave comments.
Login now