##// END OF EJS Templates
configitems: register the test 'logtoprocess.foo' config
Boris Feld -
r34765:af43cb56 default
parent child Browse files
Show More
@@ -1,80 +1,85 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 = {}
16 > configitem = registrar.configitem(configtable)
17 > configitem('logtoprocess', 'foo',
18 > default=None,
19 > )
15 > @command(b'foo', [])
20 > @command(b'foo', [])
16 > def foo(ui, repo):
21 > def foo(ui, repo):
17 > ui.log('foo', 'a message: %(bar)s\n', bar='spam')
22 > ui.log('foo', 'a message: %(bar)s\n', bar='spam')
18 > EOF
23 > EOF
19 $ cp $HGRCPATH $HGRCPATH.bak
24 $ cp $HGRCPATH $HGRCPATH.bak
20 $ cat >> $HGRCPATH << EOF
25 $ cat >> $HGRCPATH << EOF
21 > [extensions]
26 > [extensions]
22 > logtoprocess=
27 > logtoprocess=
23 > foocommand=$TESTTMP/foocommand.py
28 > foocommand=$TESTTMP/foocommand.py
24 > [logtoprocess]
29 > [logtoprocess]
25 > command=echo 'logtoprocess command output:';
30 > command=echo 'logtoprocess command output:';
26 > echo "\$EVENT";
31 > echo "\$EVENT";
27 > echo "\$MSG1";
32 > echo "\$MSG1";
28 > echo "\$MSG2"
33 > echo "\$MSG2"
29 > commandfinish=echo 'logtoprocess commandfinish output:';
34 > commandfinish=echo 'logtoprocess commandfinish output:';
30 > echo "\$EVENT";
35 > echo "\$EVENT";
31 > echo "\$MSG1";
36 > echo "\$MSG1";
32 > echo "\$MSG2";
37 > echo "\$MSG2";
33 > echo "\$MSG3"
38 > echo "\$MSG3"
34 > foo=echo 'logtoprocess foo output:';
39 > foo=echo 'logtoprocess foo output:';
35 > echo "\$EVENT";
40 > echo "\$EVENT";
36 > echo "\$MSG1";
41 > echo "\$MSG1";
37 > echo "\$OPT_BAR"
42 > echo "\$OPT_BAR"
38 > EOF
43 > EOF
39
44
40 Running a command triggers both a ui.log('command') and a
45 Running a command triggers both a ui.log('command') and a
41 ui.log('commandfinish') call. The foo command also uses ui.log.
46 ui.log('commandfinish') call. The foo command also uses ui.log.
42
47
43 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:
44 $ hg foo | cat | sort
49 $ hg foo | cat | sort
45
50
46
51
47
52
48 (chg !)
53 (chg !)
49 0
54 0
50 a message: spam
55 a message: spam
51 command
56 command
52 command (chg !)
57 command (chg !)
53 commandfinish
58 commandfinish
54 foo
59 foo
55 foo
60 foo
56 foo
61 foo
57 foo
62 foo
58 foo exited 0 after * seconds (glob)
63 foo exited 0 after * seconds (glob)
59 logtoprocess command output:
64 logtoprocess command output:
60 logtoprocess command output: (chg !)
65 logtoprocess command output: (chg !)
61 logtoprocess commandfinish output:
66 logtoprocess commandfinish output:
62 logtoprocess foo output:
67 logtoprocess foo output:
63 serve --cmdserver chgunix * (glob) (chg !)
68 serve --cmdserver chgunix * (glob) (chg !)
64 serve --cmdserver chgunix * (glob) (chg !)
69 serve --cmdserver chgunix * (glob) (chg !)
65 spam
70 spam
66
71
67 Confirm that logging blocked time catches stdio properly:
72 Confirm that logging blocked time catches stdio properly:
68 $ cp $HGRCPATH.bak $HGRCPATH
73 $ cp $HGRCPATH.bak $HGRCPATH
69 $ cat >> $HGRCPATH << EOF
74 $ cat >> $HGRCPATH << EOF
70 > [extensions]
75 > [extensions]
71 > logtoprocess=
76 > logtoprocess=
72 > pager=
77 > pager=
73 > [logtoprocess]
78 > [logtoprocess]
74 > uiblocked=echo "\$EVENT stdio \$OPT_STDIO_BLOCKED ms command \$OPT_COMMAND_DURATION ms"
79 > uiblocked=echo "\$EVENT stdio \$OPT_STDIO_BLOCKED ms command \$OPT_COMMAND_DURATION ms"
75 > [ui]
80 > [ui]
76 > logblockedtimes=True
81 > logblockedtimes=True
77 > EOF
82 > EOF
78
83
79 $ hg log | cat
84 $ hg log | cat
80 uiblocked stdio [0-9]+.[0-9]* ms command [0-9]+.[0-9]* ms (re)
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