Mercurial > hg
annotate tests/test-logtoprocess.t @ 49762:c4d587fa161c
peer: pass the `path` to the statichttp peer
We now have all peer able to receive and store a `path` object. Hooray.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 02 Dec 2022 19:34:01 +0100 |
parents | b3e77d536b53 |
children |
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 |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30991
diff
changeset
|
11 > from mercurial import registrar |
28901
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
12 > cmdtable = {} |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30991
diff
changeset
|
13 > command = registrar.command(cmdtable) |
34764
af43cb56af4e
configitems: register the test 'logtoprocess.foo' config
Boris Feld <boris.feld@octobus.net>
parents:
34444
diff
changeset
|
14 > configtable = {} |
af43cb56af4e
configitems: register the test 'logtoprocess.foo' config
Boris Feld <boris.feld@octobus.net>
parents:
34444
diff
changeset
|
15 > configitem = registrar.configitem(configtable) |
40621
175b590b1f51
py3: byte-stringify inline extension in test-logtoprocess.t
Yuya Nishihara <yuya@tcha.org>
parents:
40402
diff
changeset
|
16 > configitem(b'logtoprocess', b'foo', |
34764
af43cb56af4e
configitems: register the test 'logtoprocess.foo' config
Boris Feld <boris.feld@octobus.net>
parents:
34444
diff
changeset
|
17 > default=None, |
af43cb56af4e
configitems: register the test 'logtoprocess.foo' config
Boris Feld <boris.feld@octobus.net>
parents:
34444
diff
changeset
|
18 > ) |
40402
106adc261492
logtoprocess: sends the canonical command name to the subprocess
Boris Feld <boris.feld@octobus.net>
parents:
40401
diff
changeset
|
19 > @command(b'foobar', []) |
28901
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
20 > def foo(ui, repo): |
40621
175b590b1f51
py3: byte-stringify inline extension in test-logtoprocess.t
Yuya Nishihara <yuya@tcha.org>
parents:
40402
diff
changeset
|
21 > 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
|
22 > EOF |
30976
e92daf156d5c
ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents:
28901
diff
changeset
|
23 $ cp $HGRCPATH $HGRCPATH.bak |
28901
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
24 $ cat >> $HGRCPATH << EOF |
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
25 > [extensions] |
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
26 > logtoprocess= |
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
27 > foocommand=$TESTTMP/foocommand.py |
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
28 > [logtoprocess] |
39925
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
29 > command=(echo 'logtoprocess command output:'; |
28901
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
30 > 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
|
31 > 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
|
32 > commandfinish=(echo 'logtoprocess commandfinish output:'; |
28901
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
33 > echo "\$EVENT"; |
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
34 > echo "\$MSG1"; |
40402
106adc261492
logtoprocess: sends the canonical command name to the subprocess
Boris Feld <boris.feld@octobus.net>
parents:
40401
diff
changeset
|
35 > 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
|
36 > foo=(echo 'logtoprocess foo output:'; |
28901
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
37 > 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
|
38 > echo "\$MSG1") > $TESTTMP/foo.log |
28901
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
39 > EOF |
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
40 |
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
41 Running a command triggers both a ui.log('command') and a |
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
42 ui.log('commandfinish') call. The foo command also uses ui.log. |
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
43 |
30991
3844b3299a53
test-logtoprocess: use cat to wait for outputs
Jun Wu <quark@fb.com>
parents:
30978
diff
changeset
|
44 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
|
45 $ hg fooba |
40377
18da306e92b5
tests: sleep longer in test-logtoprocess.t
Augie Fackler <augie@google.com>
parents:
39926
diff
changeset
|
46 $ 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
|
47 $ cat $TESTTMP/command.log | sort |
28901
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
48 |
39925
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
49 command |
40402
106adc261492
logtoprocess: sends the canonical command name to the subprocess
Boris Feld <boris.feld@octobus.net>
parents:
40401
diff
changeset
|
50 fooba |
39925
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
51 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
|
52 |
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
53 #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
|
54 $ 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
|
55 |
40402
106adc261492
logtoprocess: sends the canonical command name to the subprocess
Boris Feld <boris.feld@octobus.net>
parents:
40401
diff
changeset
|
56 canonical: foobar |
28901
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
57 commandfinish |
40402
106adc261492
logtoprocess: sends the canonical command name to the subprocess
Boris Feld <boris.feld@octobus.net>
parents:
40401
diff
changeset
|
58 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
|
59 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
|
60 $ 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
|
61 |
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
62 a message: spam |
28901
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
63 foo |
a368da441b32
logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
64 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
|
65 #endif |
30976
e92daf156d5c
ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents:
28901
diff
changeset
|
66 |
e92daf156d5c
ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents:
28901
diff
changeset
|
67 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
|
68 $ cp $HGRCPATH.bak $HGRCPATH |
e92daf156d5c
ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents:
28901
diff
changeset
|
69 $ cat >> $HGRCPATH << EOF |
e92daf156d5c
ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents:
28901
diff
changeset
|
70 > [extensions] |
e92daf156d5c
ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents:
28901
diff
changeset
|
71 > logtoprocess= |
e92daf156d5c
ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents:
28901
diff
changeset
|
72 > pager= |
e92daf156d5c
ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents:
28901
diff
changeset
|
73 > [logtoprocess] |
39925
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
74 > 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
|
75 > [ui] |
e92daf156d5c
ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents:
28901
diff
changeset
|
76 > logblockedtimes=True |
e92daf156d5c
ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents:
28901
diff
changeset
|
77 > EOF |
e92daf156d5c
ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents:
28901
diff
changeset
|
78 |
39925
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
79 $ hg log |
40377
18da306e92b5
tests: sleep longer in test-logtoprocess.t
Augie Fackler <augie@google.com>
parents:
39926
diff
changeset
|
80 $ 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
|
81 $ cat $TESTTMP/uiblocked.log |
30978
fdecd24ca4dc
ui: log time spent blocked on stdio
Simon Farnsworth <simonfar@fb.com>
parents:
30976
diff
changeset
|
82 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
|
83 |
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
84 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
|
85 |
49492
b3e77d536b53
tests: fix the flaky test test-logtoprocess.t
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48876
diff
changeset
|
86 Add a script that waits on a file to appear. If the script is awaited by hg, |
b3e77d536b53
tests: fix the flaky test test-logtoprocess.t
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48876
diff
changeset
|
87 the script will die after the timeout before we could touch the file and the |
b3e77d536b53
tests: fix the flaky test test-logtoprocess.t
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48876
diff
changeset
|
88 resulting file will not exist. If not, we will touch the file and see it. |
39925
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
89 |
40873
44378796c5e5
test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents:
40622
diff
changeset
|
90 $ cat >> fakepager.py <<EOF |
44378796c5e5
test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents:
40622
diff
changeset
|
91 > import sys |
44378796c5e5
test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents:
40622
diff
changeset
|
92 > printed = False |
44378796c5e5
test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents:
40622
diff
changeset
|
93 > 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
|
94 > sys.stdout.write(line) |
44378796c5e5
test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents:
40622
diff
changeset
|
95 > printed = True |
44378796c5e5
test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents:
40622
diff
changeset
|
96 > if not printed: |
44378796c5e5
test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents:
40622
diff
changeset
|
97 > 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
|
98 > EOF |
44378796c5e5
test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents:
40622
diff
changeset
|
99 |
39925
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
100 $ 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
|
101 > #!/bin/sh |
49492
b3e77d536b53
tests: fix the flaky test test-logtoprocess.t
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48876
diff
changeset
|
102 > set -eu |
b3e77d536b53
tests: fix the flaky test test-logtoprocess.t
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48876
diff
changeset
|
103 > "$RUNTESTDIR/testlib/wait-on-file" 10 "$TESTTMP/wait-for-touched" |
b3e77d536b53
tests: fix the flaky test test-logtoprocess.t
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48876
diff
changeset
|
104 > touch "$TESTTMP/touched" |
39925
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
105 > EOF |
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
106 $ 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
|
107 |
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
108 $ 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
|
109 > [extensions] |
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
110 > logtoprocess= |
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
111 > pager= |
40873
44378796c5e5
test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents:
40622
diff
changeset
|
112 > [pager] |
44378796c5e5
test: update test-logtoprocess.t to not requires less
Boris Feld <boris.feld@octobus.net>
parents:
40622
diff
changeset
|
113 > 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
|
114 > [logtoprocess] |
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
115 > 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
|
116 > EOF |
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
117 $ 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
|
118 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
|
119 $ touch $TESTTMP/wait-for-touched |
49492
b3e77d536b53
tests: fix the flaky test test-logtoprocess.t
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48876
diff
changeset
|
120 $ "$RUNTESTDIR/testlib/wait-on-file" 5 "$TESTTMP/touched" |
39925
dfca83594145
logtoprocess: add a test to show pager and ltp bad interaction
Boris Feld <boris.feld@octobus.net>
parents:
34764
diff
changeset
|
121 $ 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
|
122 SUCCESS Pager is not waiting on ltp |