Show More
@@ -1,129 +1,122 b'' | |||||
1 | #require no-windows |
|
1 | #require no-windows | |
2 |
|
2 | |||
3 | ATTENTION: logtoprocess runs commands asynchronously. Be sure to append "| cat" |
|
3 | ATTENTION: logtoprocess runs commands asynchronously. Be sure to append "| cat" | |
4 | 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. | |
5 | Otherwise the test will be flaky. |
|
5 | Otherwise the test will be flaky. | |
6 |
|
6 | |||
7 | Test if logtoprocess correctly captures command-related log calls. |
|
7 | Test if logtoprocess correctly captures command-related log calls. | |
8 |
|
8 | |||
9 | $ hg init |
|
9 | $ hg init | |
10 | $ cat > $TESTTMP/foocommand.py << EOF |
|
10 | $ cat > $TESTTMP/foocommand.py << EOF | |
11 | > from mercurial import registrar |
|
11 | > from mercurial import registrar | |
12 | > cmdtable = {} |
|
12 | > cmdtable = {} | |
13 | > command = registrar.command(cmdtable) |
|
13 | > command = registrar.command(cmdtable) | |
14 | > configtable = {} |
|
14 | > configtable = {} | |
15 | > configitem = registrar.configitem(configtable) |
|
15 | > configitem = registrar.configitem(configtable) | |
16 | > configitem(b'logtoprocess', b'foo', |
|
16 | > configitem(b'logtoprocess', b'foo', | |
17 | > default=None, |
|
17 | > default=None, | |
18 | > ) |
|
18 | > ) | |
19 | > @command(b'foobar', []) |
|
19 | > @command(b'foobar', []) | |
20 | > def foo(ui, repo): |
|
20 | > def foo(ui, repo): | |
21 | > ui.log(b'foo', b'a message: %s\n', b'spam') |
|
21 | > ui.log(b'foo', b'a message: %s\n', b'spam') | |
22 | > EOF |
|
22 | > EOF | |
23 | $ cp $HGRCPATH $HGRCPATH.bak |
|
23 | $ cp $HGRCPATH $HGRCPATH.bak | |
24 | $ cat >> $HGRCPATH << EOF |
|
24 | $ cat >> $HGRCPATH << EOF | |
25 | > [extensions] |
|
25 | > [extensions] | |
26 | > logtoprocess= |
|
26 | > logtoprocess= | |
27 | > foocommand=$TESTTMP/foocommand.py |
|
27 | > foocommand=$TESTTMP/foocommand.py | |
28 | > [logtoprocess] |
|
28 | > [logtoprocess] | |
29 | > command=(echo 'logtoprocess command output:'; |
|
29 | > command=(echo 'logtoprocess command output:'; | |
30 | > echo "\$EVENT"; |
|
30 | > echo "\$EVENT"; | |
31 | > echo "\$MSG1") > $TESTTMP/command.log |
|
31 | > echo "\$MSG1") > $TESTTMP/command.log | |
32 | > commandfinish=(echo 'logtoprocess commandfinish output:'; |
|
32 | > commandfinish=(echo 'logtoprocess commandfinish output:'; | |
33 | > echo "\$EVENT"; |
|
33 | > echo "\$EVENT"; | |
34 | > echo "\$MSG1"; |
|
34 | > echo "\$MSG1"; | |
35 | > echo "canonical: \$OPT_CANONICAL_COMMAND") > $TESTTMP/commandfinish.log |
|
35 | > echo "canonical: \$OPT_CANONICAL_COMMAND") > $TESTTMP/commandfinish.log | |
36 | > foo=(echo 'logtoprocess foo output:'; |
|
36 | > foo=(echo 'logtoprocess foo output:'; | |
37 | > echo "\$EVENT"; |
|
37 | > echo "\$EVENT"; | |
38 | > echo "\$MSG1") > $TESTTMP/foo.log |
|
38 | > echo "\$MSG1") > $TESTTMP/foo.log | |
39 | > EOF |
|
39 | > EOF | |
40 |
|
40 | |||
41 | Running a command triggers both a ui.log('command') and a |
|
41 | Running a command triggers both a ui.log('command') and a | |
42 | ui.log('commandfinish') call. The foo command also uses ui.log. |
|
42 | ui.log('commandfinish') call. The foo command also uses ui.log. | |
43 |
|
43 | |||
44 | Use sort to avoid ordering issues between the various processes we spawn: |
|
44 | Use sort to avoid ordering issues between the various processes we spawn: | |
45 | $ hg fooba |
|
45 | $ hg fooba | |
46 | $ sleep 1 |
|
46 | $ sleep 1 | |
47 | $ cat $TESTTMP/command.log | sort |
|
47 | $ cat $TESTTMP/command.log | sort | |
48 |
|
48 | |||
49 | command |
|
49 | command | |
50 | fooba |
|
50 | fooba | |
51 | logtoprocess command output: |
|
51 | logtoprocess command output: | |
52 |
|
52 | |||
53 | #if no-chg |
|
53 | #if no-chg | |
54 | $ cat $TESTTMP/commandfinish.log | sort |
|
54 | $ cat $TESTTMP/commandfinish.log | sort | |
55 |
|
55 | |||
56 | canonical: foobar |
|
56 | canonical: foobar | |
57 | commandfinish |
|
57 | commandfinish | |
58 | fooba exited 0 after * seconds (glob) |
|
58 | fooba exited 0 after * seconds (glob) | |
59 | logtoprocess commandfinish output: |
|
59 | logtoprocess commandfinish output: | |
60 | $ cat $TESTTMP/foo.log | sort |
|
60 | $ cat $TESTTMP/foo.log | sort | |
61 |
|
61 | |||
62 | a message: spam |
|
62 | a message: spam | |
63 | foo |
|
63 | foo | |
64 | logtoprocess foo output: |
|
64 | logtoprocess foo output: | |
65 | #endif |
|
65 | #endif | |
66 |
|
66 | |||
67 | Confirm that logging blocked time catches stdio properly: |
|
67 | Confirm that logging blocked time catches stdio properly: | |
68 | $ cp $HGRCPATH.bak $HGRCPATH |
|
68 | $ cp $HGRCPATH.bak $HGRCPATH | |
69 | $ cat >> $HGRCPATH << EOF |
|
69 | $ cat >> $HGRCPATH << EOF | |
70 | > [extensions] |
|
70 | > [extensions] | |
71 | > logtoprocess= |
|
71 | > logtoprocess= | |
72 | > pager= |
|
72 | > pager= | |
73 | > [logtoprocess] |
|
73 | > [logtoprocess] | |
74 | > uiblocked=echo "\$EVENT stdio \$OPT_STDIO_BLOCKED ms command \$OPT_COMMAND_DURATION ms" > $TESTTMP/uiblocked.log |
|
74 | > uiblocked=echo "\$EVENT stdio \$OPT_STDIO_BLOCKED ms command \$OPT_COMMAND_DURATION ms" > $TESTTMP/uiblocked.log | |
75 | > [ui] |
|
75 | > [ui] | |
76 | > logblockedtimes=True |
|
76 | > logblockedtimes=True | |
77 | > EOF |
|
77 | > EOF | |
78 |
|
78 | |||
79 | $ hg log |
|
79 | $ hg log | |
80 | $ sleep 1 |
|
80 | $ sleep 1 | |
81 | $ cat $TESTTMP/uiblocked.log |
|
81 | $ cat $TESTTMP/uiblocked.log | |
82 | uiblocked stdio [0-9]+.[0-9]* ms command [0-9]+.[0-9]* ms (re) |
|
82 | uiblocked stdio [0-9]+.[0-9]* ms command [0-9]+.[0-9]* ms (re) | |
83 |
|
83 | |||
84 | Try to confirm that pager wait on logtoprocess: |
|
84 | Try to confirm that pager wait on logtoprocess: | |
85 |
|
85 | |||
86 |
Add a script that wait on a file to appear |
|
86 | Add a script that waits on a file to appear. If the script is awaited by hg, | |
87 | another file or die after 5 seconds. If the scripts is awaited by hg, the |
|
87 | the script will die after the timeout before we could touch the file and the | |
88 | script will die after the timeout before we could touch the file and the |
|
88 | resulting file will not exist. If not, we will touch the file and see it. | |
89 | resulting file will not exists. If not, we will touch the file and see it. |
|
|||
90 |
|
89 | |||
91 | $ cat >> fakepager.py <<EOF |
|
90 | $ cat >> fakepager.py <<EOF | |
92 | > import sys |
|
91 | > import sys | |
93 | > printed = False |
|
92 | > printed = False | |
94 | > for line in sys.stdin: |
|
93 | > for line in sys.stdin: | |
95 | > sys.stdout.write(line) |
|
94 | > sys.stdout.write(line) | |
96 | > printed = True |
|
95 | > printed = True | |
97 | > if not printed: |
|
96 | > if not printed: | |
98 | > sys.stdout.write('paged empty output!\n') |
|
97 | > sys.stdout.write('paged empty output!\n') | |
99 | > EOF |
|
98 | > EOF | |
100 |
|
99 | |||
101 | $ cat > $TESTTMP/wait-output.sh << EOF |
|
100 | $ cat > $TESTTMP/wait-output.sh << EOF | |
102 | > #!/bin/sh |
|
101 | > #!/bin/sh | |
103 | > for i in \`$TESTDIR/seq.py 50\`; do |
|
102 | > set -eu | |
104 |
> |
|
103 | > "$RUNTESTDIR/testlib/wait-on-file" 10 "$TESTTMP/wait-for-touched" | |
105 | > then |
|
104 | > touch "$TESTTMP/touched" | |
106 | > touch "$TESTTMP/touched"; |
|
|||
107 | > break; |
|
|||
108 | > else |
|
|||
109 | > sleep 0.1; |
|
|||
110 | > fi |
|
|||
111 | > done |
|
|||
112 | > EOF |
|
105 | > EOF | |
113 | $ chmod +x $TESTTMP/wait-output.sh |
|
106 | $ chmod +x $TESTTMP/wait-output.sh | |
114 |
|
107 | |||
115 | $ cat >> $HGRCPATH << EOF |
|
108 | $ cat >> $HGRCPATH << EOF | |
116 | > [extensions] |
|
109 | > [extensions] | |
117 | > logtoprocess= |
|
110 | > logtoprocess= | |
118 | > pager= |
|
111 | > pager= | |
119 | > [pager] |
|
112 | > [pager] | |
120 | > pager = "$PYTHON" $TESTTMP/fakepager.py |
|
113 | > pager = "$PYTHON" $TESTTMP/fakepager.py | |
121 | > [logtoprocess] |
|
114 | > [logtoprocess] | |
122 | > commandfinish=$TESTTMP/wait-output.sh |
|
115 | > commandfinish=$TESTTMP/wait-output.sh | |
123 | > EOF |
|
116 | > EOF | |
124 |
$ hg |
|
117 | $ hg version -q --pager=always | |
125 |
|
|
118 | Mercurial Distributed SCM (version *) (glob) | |
126 | $ touch $TESTTMP/wait-for-touched |
|
119 | $ touch $TESTTMP/wait-for-touched | |
127 | $ sleep 0.2 |
|
120 | $ "$RUNTESTDIR/testlib/wait-on-file" 5 "$TESTTMP/touched" | |
128 |
$ test -f $TESTTMP/touched && echo |
|
121 | $ test -f $TESTTMP/touched && echo "SUCCESS Pager is not waiting on ltp" || echo "FAIL Pager is waiting on ltp" | |
129 |
|
|
122 | SUCCESS Pager is not waiting on ltp |
General Comments 0
You need to be logged in to leave comments.
Login now