annotate tests/test-logtoprocess.t @ 34107:4f60720cf0df

blackbox: fix rotation with chg The added test will show: $ $PYTHON showsize.py .hg/blackbox* .hg/blackbox.log: < 500 .hg/blackbox.log.1: < 500 .hg/blackbox.log.2: < 500 .hg/blackbox.log.3: < 500 .hg/blackbox.log.4: < 500 .hg/blackbox.log.5: >= 500 with previous code. The issue is caused by blackbox caching file objects *by path*, and the rotation size check could run on a wrong file object (i.e. it should check "blackbox.log", but `filehandles["blackbox.log"]` contains a file object that has been renamed to "blackbox.log.5"). This patch removes the "filehandlers" global cache added by 45313f5a3a8c to solve the issue. I think the original patch was trying to make different ui objects use a same file object if their blackbox.log path is the same. In theory it could also be problematic in the rotation case. Anyway, that should become unnecessary after D650. Differential Revision: https://phab.mercurial-scm.org/D648
author Jun Wu <quark@fb.com>
date Wed, 06 Sep 2017 19:27:30 -0700
parents e98dab3fafbc
children df78b1a24094
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)
33097
fce4ed2912bb py3: make sure commands name are bytes in tests
Pulkit Goyal <7895pulkit@gmail.com>
parents: 32915
diff changeset
15 > @command(b'foo', [])
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
16 > def foo(ui, repo):
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
17 > ui.log('foo', 'a message: %(bar)s\n', bar='spam')
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
18 > EOF
30976
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
19 $ cp $HGRCPATH $HGRCPATH.bak
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
20 $ cat >> $HGRCPATH << EOF
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
21 > [extensions]
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
22 > logtoprocess=
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
23 > foocommand=$TESTTMP/foocommand.py
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
24 > [logtoprocess]
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
25 > command=echo 'logtoprocess command output:';
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
26 > echo "\$EVENT";
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
27 > echo "\$MSG1";
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
28 > echo "\$MSG2"
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
29 > commandfinish=echo 'logtoprocess commandfinish output:';
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
30 > echo "\$EVENT";
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
31 > echo "\$MSG1";
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
32 > echo "\$MSG2";
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
33 > echo "\$MSG3"
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
34 > foo=echo 'logtoprocess foo output:';
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
35 > echo "\$EVENT";
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
36 > echo "\$MSG1";
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
37 > echo "\$OPT_BAR"
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
38 > EOF
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
39
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
40 Running a command triggers both a ui.log('command') and a
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
41 ui.log('commandfinish') call. The foo command also uses ui.log.
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
42
30991
3844b3299a53 test-logtoprocess: use cat to wait for outputs
Jun Wu <quark@fb.com>
parents: 30978
diff changeset
43 Use sort to avoid ordering issues between the various processes we spawn:
3844b3299a53 test-logtoprocess: use cat to wait for outputs
Jun Wu <quark@fb.com>
parents: 30978
diff changeset
44 $ hg foo | cat | sort
28901
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
45
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
46
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
47
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
48 0
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
49 a message: spam
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
50 command
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
51 commandfinish
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
52 foo
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
53 foo
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
54 foo
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
55 foo
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
56 foo exited 0 after * seconds (glob)
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
57 logtoprocess command output:
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
58 logtoprocess commandfinish output:
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
59 logtoprocess foo output:
a368da441b32 logtoprocess: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
60 spam
30976
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
61
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
62 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
63 $ cp $HGRCPATH.bak $HGRCPATH
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
64 $ cat >> $HGRCPATH << EOF
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
65 > [extensions]
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
66 > logtoprocess=
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
67 > pager=
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
68 > [logtoprocess]
30978
fdecd24ca4dc ui: log time spent blocked on stdio
Simon Farnsworth <simonfar@fb.com>
parents: 30976
diff changeset
69 > uiblocked=echo "\$EVENT stdio \$OPT_STDIO_BLOCKED ms command \$OPT_COMMAND_DURATION ms"
30976
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
70 > [ui]
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
71 > logblockedtimes=True
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
72 > EOF
e92daf156d5c ui: provide a mechanism to track and log blocked time
Simon Farnsworth <simonfar@fb.com>
parents: 28901
diff changeset
73
30991
3844b3299a53 test-logtoprocess: use cat to wait for outputs
Jun Wu <quark@fb.com>
parents: 30978
diff changeset
74 $ hg log | cat
30978
fdecd24ca4dc ui: log time spent blocked on stdio
Simon Farnsworth <simonfar@fb.com>
parents: 30976
diff changeset
75 uiblocked stdio [0-9]+.[0-9]* ms command [0-9]+.[0-9]* ms (re)