test-logtoprocess.t
80 lines
| 2.1 KiB
| text/troff
|
Tads3Lexer
/ tests / test-logtoprocess.t
Matt Harbison
|
r32915 | #require no-windows | ||
Jun Wu
|
r30991 | ATTENTION: logtoprocess runs commands asynchronously. Be sure to append "| cat" | ||
to hg commands, to wait for the output, if you want to test its output. | ||||
Otherwise the test will be flaky. | ||||
Martijn Pieters
|
r28901 | Test if logtoprocess correctly captures command-related log calls. | ||
$ hg init | ||||
$ cat > $TESTTMP/foocommand.py << EOF | ||||
Augie Fackler
|
r33968 | > from __future__ import absolute_import | ||
Yuya Nishihara
|
r32337 | > from mercurial import registrar | ||
Martijn Pieters
|
r28901 | > cmdtable = {} | ||
Yuya Nishihara
|
r32337 | > command = registrar.command(cmdtable) | ||
Pulkit Goyal
|
r33097 | > @command(b'foo', []) | ||
Martijn Pieters
|
r28901 | > def foo(ui, repo): | ||
> ui.log('foo', 'a message: %(bar)s\n', bar='spam') | ||||
> EOF | ||||
Simon Farnsworth
|
r30976 | $ cp $HGRCPATH $HGRCPATH.bak | ||
Martijn Pieters
|
r28901 | $ cat >> $HGRCPATH << EOF | ||
> [extensions] | ||||
> logtoprocess= | ||||
> foocommand=$TESTTMP/foocommand.py | ||||
> [logtoprocess] | ||||
> command=echo 'logtoprocess command output:'; | ||||
> echo "\$EVENT"; | ||||
> echo "\$MSG1"; | ||||
> echo "\$MSG2" | ||||
> commandfinish=echo 'logtoprocess commandfinish output:'; | ||||
> echo "\$EVENT"; | ||||
> echo "\$MSG1"; | ||||
> echo "\$MSG2"; | ||||
> echo "\$MSG3" | ||||
> foo=echo 'logtoprocess foo output:'; | ||||
> echo "\$EVENT"; | ||||
> echo "\$MSG1"; | ||||
> echo "\$OPT_BAR" | ||||
> EOF | ||||
Running a command triggers both a ui.log('command') and a | ||||
ui.log('commandfinish') call. The foo command also uses ui.log. | ||||
Jun Wu
|
r30991 | Use sort to avoid ordering issues between the various processes we spawn: | ||
$ hg foo | cat | sort | ||||
Martijn Pieters
|
r28901 | |||
Jun Wu
|
r34445 | (chg !) | ||
Martijn Pieters
|
r28901 | 0 | ||
a message: spam | ||||
command | ||||
Jun Wu
|
r34445 | command (chg !) | ||
Martijn Pieters
|
r28901 | commandfinish | ||
foo | ||||
foo | ||||
foo | ||||
foo | ||||
foo exited 0 after * seconds (glob) | ||||
logtoprocess command output: | ||||
Jun Wu
|
r34445 | logtoprocess command output: (chg !) | ||
Martijn Pieters
|
r28901 | logtoprocess commandfinish output: | ||
logtoprocess foo output: | ||||
Jun Wu
|
r34445 | serve --cmdserver chgunix * (glob) (chg !) | ||
serve --cmdserver chgunix * (glob) (chg !) | ||||
Martijn Pieters
|
r28901 | spam | ||
Simon Farnsworth
|
r30976 | |||
Confirm that logging blocked time catches stdio properly: | ||||
$ cp $HGRCPATH.bak $HGRCPATH | ||||
$ cat >> $HGRCPATH << EOF | ||||
> [extensions] | ||||
> logtoprocess= | ||||
> pager= | ||||
> [logtoprocess] | ||||
Simon Farnsworth
|
r30978 | > uiblocked=echo "\$EVENT stdio \$OPT_STDIO_BLOCKED ms command \$OPT_COMMAND_DURATION ms" | ||
Simon Farnsworth
|
r30976 | > [ui] | ||
> logblockedtimes=True | ||||
> EOF | ||||
Jun Wu
|
r30991 | $ hg log | cat | ||
Simon Farnsworth
|
r30978 | uiblocked stdio [0-9]+.[0-9]* ms command [0-9]+.[0-9]* ms (re) | ||