annotate tests/test-logtoprocess.t @ 45244:d4a28b76fa54

cleanup: fix bad formatting of state.py from D8811 `test-check-format.t` was failing for me. Do I just have the wrong version? Differential Revision: https://phab.mercurial-scm.org/D8841
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 28 Jul 2020 11:11:14 -0700
parents 44378796c5e5
children 42d2b31cee0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32915
0afc4206d02b test-logtoprocess: don't run on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 32337
diff changeset
1 #require no-windows
0afc4206d02b test-logtoprocess: don't run on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 32337
diff changeset
2
30991
3844b3299a53 test-logtoprocess: use cat to wait for outputs
Jun Wu <quark@fb.com>
parents: 30978
diff changeset
3 ATTENTION: logtoprocess runs commands asynchronously. Be sure to append "| cat"
3844b3299a53 test-logtoprocess: use cat to wait for outputs
Jun Wu <quark@fb.com>
parents: 30978
diff changeset
4 to hg commands, to wait for the output, if you want to test its output.
3844b3299a53 test-logtoprocess: use cat to wait for outputs
Jun Wu <quark@fb.com>
parents: 30978
diff changeset
5 Otherwise the test will be flaky.
3844b3299a53 test-logtoprocess: use cat to wait for outputs
Jun Wu <quark@fb.com>
parents: 30978
diff changeset
6
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
7 Test if logtoprocess correctly captures command-related log calls.
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
8
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
9 $ hg init
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
10 $ cat > $TESTTMP/foocommand.py << EOF
33966
e98dab3fafbc tests: update test-logtoprocess to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 33097
diff changeset
11 > from __future__ import absolute_import
32337
46ba2cdda476 registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 30991
diff changeset
12 > from mercurial import registrar
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
13 > cmdtable = {}
32337
46ba2cdda476 registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 30991
diff changeset
14 > command = registrar.command(cmdtable)
34764
af43cb56af4e configitems: register the test 'logtoprocess.foo' config
Boris Feld <boris.feld@octobus.net>
parents: 34444
diff changeset
15 > configtable = {}
af43cb56af4e configitems: register the test 'logtoprocess.foo' config
Boris Feld <boris.feld@octobus.net>
parents: 34444
diff changeset
16 > configitem = registrar.configitem(configtable)
40621
175b590b1f51 py3: byte-stringify inline extension in test-logtoprocess.t
Yuya Nishihara <yuya@tcha.org>
parents: 40402
diff changeset
17 > configitem(b'logtoprocess', b'foo',
34764
af43cb56af4e configitems: register the test 'logtoprocess.foo' config
Boris Feld <boris.feld@octobus.net>
parents: 34444
diff changeset
18 > default=None,
af43cb56af4e configitems: register the test 'logtoprocess.foo' config
Boris Feld <boris.feld@octobus.net>
parents: 34444
diff changeset
19 > )
40402
106adc261492 logtoprocess: sends the canonical command name to the subprocess
Boris Feld <boris.feld@octobus.net>
parents: 40401
diff changeset
20 > @command(b'foobar', [])
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
21 > def foo(ui, repo):
40621
175b590b1f51 py3: byte-stringify inline extension in test-logtoprocess.t
Yuya Nishihara <yuya@tcha.org>
parents: 40402
diff changeset
22 > ui.log(b'foo', b'a message: %s\n', b'spam')
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
23 > EOF
30976
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
24 $ cp $HGRCPATH $HGRCPATH.bak
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
25 $ cat >> $HGRCPATH << EOF
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
26 > [extensions]
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
27 > logtoprocess=
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
28 > foocommand=$TESTTMP/foocommand.py
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
29 > [logtoprocess]
39925
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
30 > command=(echo 'logtoprocess command output:';
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
31 > echo "\$EVENT";
40622
d2c997b8001f logtoprocess: drop support for ui.log() call with invalid msg arguments (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 40621
diff changeset
32 > echo "\$MSG1") > $TESTTMP/command.log
39925
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
33 > commandfinish=(echo 'logtoprocess commandfinish output:';
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
34 > echo "\$EVENT";
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
35 > echo "\$MSG1";
40402
106adc261492 logtoprocess: sends the canonical command name to the subprocess
Boris Feld <boris.feld@octobus.net>
parents: 40401
diff changeset
36 > echo "canonical: \$OPT_CANONICAL_COMMAND") > $TESTTMP/commandfinish.log
39925
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
37 > foo=(echo 'logtoprocess foo output:';
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
38 > echo "\$EVENT";
40622
d2c997b8001f logtoprocess: drop support for ui.log() call with invalid msg arguments (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 40621
diff changeset
39 > echo "\$MSG1") > $TESTTMP/foo.log
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
40 > EOF
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
41
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
42 Running a command triggers both a ui.log('command') and a
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
43 ui.log('commandfinish') call. The foo command also uses ui.log.
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
44
30991
3844b3299a53 test-logtoprocess: use cat to wait for outputs
Jun Wu <quark@fb.com>
parents: 30978
diff changeset
45 Use sort to avoid ordering issues between the various processes we spawn:
40402
106adc261492 logtoprocess: sends the canonical command name to the subprocess
Boris Feld <boris.feld@octobus.net>
parents: 40401
diff changeset
46 $ hg fooba
40377
18da306e92b5 tests: sleep longer in test-logtoprocess.t
Augie Fackler <augie@google.com>
parents: 39926
diff changeset
47 $ sleep 1
39925
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
48 $ cat $TESTTMP/command.log | sort
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
49
39925
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
50 command
40402
106adc261492 logtoprocess: sends the canonical command name to the subprocess
Boris Feld <boris.feld@octobus.net>
parents: 40401
diff changeset
51 fooba
39925
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
52 logtoprocess command output:
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
53
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
54 #if no-chg
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
55 $ cat $TESTTMP/commandfinish.log | sort
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
56
40402
106adc261492 logtoprocess: sends the canonical command name to the subprocess
Boris Feld <boris.feld@octobus.net>
parents: 40401
diff changeset
57 canonical: foobar
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
58 commandfinish
40402
106adc261492 logtoprocess: sends the canonical command name to the subprocess
Boris Feld <boris.feld@octobus.net>
parents: 40401
diff changeset
59 fooba exited 0 after * seconds (glob)
39925
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
60 logtoprocess commandfinish output:
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
61 $ cat $TESTTMP/foo.log | sort
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
62
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
63 a message: spam
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
64 foo
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
65 logtoprocess foo output:
39925
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
66 #endif
30976
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
67
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
68 Confirm that logging blocked time catches stdio properly:
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
69 $ cp $HGRCPATH.bak $HGRCPATH
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
70 $ cat >> $HGRCPATH << EOF
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
71 > [extensions]
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
72 > logtoprocess=
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
73 > pager=
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
74 > [logtoprocess]
39925
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
75 > uiblocked=echo "\$EVENT stdio \$OPT_STDIO_BLOCKED ms command \$OPT_COMMAND_DURATION ms" > $TESTTMP/uiblocked.log
30976
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
76 > [ui]
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
77 > logblockedtimes=True
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
78 > EOF
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
79
39925
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
80 $ hg log
40377
18da306e92b5 tests: sleep longer in test-logtoprocess.t
Augie Fackler <augie@google.com>
parents: 39926
diff changeset
81 $ sleep 1
39925
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
82 $ cat $TESTTMP/uiblocked.log
30978
fdecd24ca4dc ui: log time spent blocked on stdio
Simon Farnsworth <simonfar@fb.com>
parents: 30976
diff changeset
83 uiblocked stdio [0-9]+.[0-9]* ms command [0-9]+.[0-9]* ms (re)
39925
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
84
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
85 Try to confirm that pager wait on logtoprocess:
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
86
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
87 Add a script that wait on a file to appears for 5 seconds, if it sees it touch
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
88 another file or die after 5 seconds. If the scripts is awaited by hg, the
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
89 script will die after the timeout before we could touch the file and the
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
90 resulting file will not exists. If not, we will touch the file and see it.
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
91
40873
44378796c5e5 test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents: 40622
diff changeset
92 $ cat >> fakepager.py <<EOF
44378796c5e5 test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents: 40622
diff changeset
93 > import sys
44378796c5e5 test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents: 40622
diff changeset
94 > printed = False
44378796c5e5 test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents: 40622
diff changeset
95 > for line in sys.stdin:
44378796c5e5 test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents: 40622
diff changeset
96 > sys.stdout.write(line)
44378796c5e5 test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents: 40622
diff changeset
97 > printed = True
44378796c5e5 test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents: 40622
diff changeset
98 > if not printed:
44378796c5e5 test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents: 40622
diff changeset
99 > sys.stdout.write('paged empty output!\n')
44378796c5e5 test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents: 40622
diff changeset
100 > EOF
44378796c5e5 test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents: 40622
diff changeset
101
39925
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
102 $ cat > $TESTTMP/wait-output.sh << EOF
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
103 > #!/bin/sh
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
104 > for i in \`$TESTDIR/seq.py 50\`; do
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
105 > if [ -f "$TESTTMP/wait-for-touched" ];
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
106 > then
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
107 > touch "$TESTTMP/touched";
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
108 > break;
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
109 > else
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
110 > sleep 0.1;
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
111 > fi
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
112 > done
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
113 > EOF
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
114 $ chmod +x $TESTTMP/wait-output.sh
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
115
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
116 $ cat >> $HGRCPATH << EOF
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
117 > [extensions]
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
118 > logtoprocess=
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
119 > pager=
40873
44378796c5e5 test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents: 40622
diff changeset
120 > [pager]
44378796c5e5 test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents: 40622
diff changeset
121 > pager = "$PYTHON" $TESTTMP/fakepager.py
39925
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
122 > [logtoprocess]
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
123 > commandfinish=$TESTTMP/wait-output.sh
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
124 > EOF
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
125 $ hg version -q --pager=always
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
126 Mercurial Distributed SCM (version *) (glob)
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
127 $ touch $TESTTMP/wait-for-touched
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
128 $ sleep 0.2
dfca83594145 logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents: 34764
diff changeset
129 $ test -f $TESTTMP/touched && echo "SUCCESS Pager is not waiting on ltp" || echo "FAIL Pager is waiting on ltp"
39926
c4a3d3c67c4f logtoprocess: connect all fds to /dev/null to avoid bad interaction with pager
Boris Feld <boris.feld@octobus.net>
parents: 39925
diff changeset
130 SUCCESS Pager is not waiting on ltp