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