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