##// END OF EJS Templates
tests: divorce blackbox test from test-dispatch.py...
timeless -
r28406:0767c2f6 default
parent child Browse files
Show More
@@ -1,35 +1,36 b''
1 from __future__ import absolute_import, print_function
1 from __future__ import absolute_import, print_function
2 import os
2 import os
3 from mercurial import (
3 from mercurial import (
4 dispatch,
4 dispatch,
5 )
5 )
6
6
7 def testdispatch(cmd):
7 def testdispatch(cmd):
8 """Simple wrapper around dispatch.dispatch()
8 """Simple wrapper around dispatch.dispatch()
9
9
10 Prints command and result value, but does not handle quoting.
10 Prints command and result value, but does not handle quoting.
11 """
11 """
12 print("running: %s" % (cmd,))
12 print("running: %s" % (cmd,))
13 req = dispatch.request(cmd.split())
13 req = dispatch.request(cmd.split())
14 result = dispatch.dispatch(req)
14 result = dispatch.dispatch(req)
15 print("result: %r" % (result,))
15 print("result: %r" % (result,))
16
16
17 testdispatch("init test1")
18 os.chdir('test1')
19
20 # create file 'foo', add and commit
17 # create file 'foo', add and commit
21 f = open('foo', 'wb')
18 f = open('foo', 'wb')
22 f.write('foo\n')
19 f.write('foo\n')
23 f.close()
20 f.close()
24 testdispatch("add foo")
21 testdispatch("add foo")
25 testdispatch("commit -m commit1 -d 2000-01-01 foo")
22 testdispatch("commit -m commit1 -d 2000-01-01 foo")
26
23
27 # append to file 'foo' and commit
24 # append to file 'foo' and commit
28 f = open('foo', 'ab')
25 f = open('foo', 'ab')
29 f.write('bar\n')
26 f.write('bar\n')
30 f.close()
27 f.close()
28 # remove blackbox.log directory (proxy for readonly log file)
29 os.rmdir(".hg/blackbox.log")
30 # replace it with the real blackbox.log file
31 os.rename(".hg/blackbox.log-", ".hg/blackbox.log")
31 testdispatch("commit -m commit2 -d 2000-01-02 foo")
32 testdispatch("commit -m commit2 -d 2000-01-02 foo")
32
33
33 # check 88803a69b24 (fancyopts modified command table)
34 # check 88803a69b24 (fancyopts modified command table)
34 testdispatch("log -r 0")
35 testdispatch("log -r 0")
35 testdispatch("log -r tip")
36 testdispatch("log -r tip")
@@ -1,195 +1,195 b''
1 setup
1 setup
2 $ cat >> $HGRCPATH <<EOF
2 $ cat >> $HGRCPATH <<EOF
3 > [extensions]
3 > [extensions]
4 > blackbox=
4 > blackbox=
5 > mock=$TESTDIR/mockblackbox.py
5 > mock=$TESTDIR/mockblackbox.py
6 > mq=
6 > mq=
7 > EOF
7 > EOF
8 $ hg init blackboxtest
8 $ hg init blackboxtest
9 $ cd blackboxtest
9 $ cd blackboxtest
10
10
11 command, exit codes, and duration
11 command, exit codes, and duration
12
12
13 $ echo a > a
13 $ echo a > a
14 $ hg add a
14 $ hg add a
15 $ hg blackbox --config blackbox.dirty=True
15 $ hg blackbox --config blackbox.dirty=True
16 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a
16 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a
17 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob)
17 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob)
18 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox
18 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox
19
19
20 incoming change tracking
20 incoming change tracking
21
21
22 create two heads to verify that we only see one change in the log later
22 create two heads to verify that we only see one change in the log later
23 $ hg commit -ma
23 $ hg commit -ma
24 $ hg up null
24 $ hg up null
25 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
25 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
26 $ echo b > b
26 $ echo b > b
27 $ hg commit -Amb
27 $ hg commit -Amb
28 adding b
28 adding b
29 created new head
29 created new head
30
30
31 clone, commit, pull
31 clone, commit, pull
32 $ hg clone . ../blackboxtest2
32 $ hg clone . ../blackboxtest2
33 updating to branch default
33 updating to branch default
34 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
34 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
35 $ echo c > c
35 $ echo c > c
36 $ hg commit -Amc
36 $ hg commit -Amc
37 adding c
37 adding c
38 $ cd ../blackboxtest2
38 $ cd ../blackboxtest2
39 $ hg pull
39 $ hg pull
40 pulling from $TESTTMP/blackboxtest (glob)
40 pulling from $TESTTMP/blackboxtest (glob)
41 searching for changes
41 searching for changes
42 adding changesets
42 adding changesets
43 adding manifests
43 adding manifests
44 adding file changes
44 adding file changes
45 added 1 changesets with 1 changes to 1 files
45 added 1 changesets with 1 changes to 1 files
46 (run 'hg update' to get a working copy)
46 (run 'hg update' to get a working copy)
47 $ hg blackbox -l 6
47 $ hg blackbox -l 6
48 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull
48 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull
49 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated served branch cache in * seconds (glob)
49 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated served branch cache in * seconds (glob)
50 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote served branch cache with 1 labels and 2 nodes
50 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote served branch cache with 1 labels and 2 nodes
51 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> 1 incoming changes - new heads: d02f48003e62
51 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> 1 incoming changes - new heads: d02f48003e62
52 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull exited 0 after * seconds (glob)
52 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull exited 0 after * seconds (glob)
53 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
53 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
54
54
55 we must not cause a failure if we cannot write to the log
55 we must not cause a failure if we cannot write to the log
56
56
57 $ hg rollback
57 $ hg rollback
58 repository tip rolled back to revision 1 (undo pull)
58 repository tip rolled back to revision 1 (undo pull)
59
59
60 $ mv .hg/blackbox.log .hg/blackbox.log-
60 $ mv .hg/blackbox.log .hg/blackbox.log-
61 $ mkdir .hg/blackbox.log
61 $ mkdir .hg/blackbox.log
62 $ hg --debug incoming
62 $ hg --debug incoming
63 warning: cannot write to blackbox.log: * (glob)
63 warning: cannot write to blackbox.log: * (glob)
64 comparing with $TESTTMP/blackboxtest (glob)
64 comparing with $TESTTMP/blackboxtest (glob)
65 query 1; heads
65 query 1; heads
66 searching for changes
66 searching for changes
67 all local heads known remotely
67 all local heads known remotely
68 changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51
68 changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51
69 tag: tip
69 tag: tip
70 phase: draft
70 phase: draft
71 parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06
71 parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06
72 parent: -1:0000000000000000000000000000000000000000
72 parent: -1:0000000000000000000000000000000000000000
73 manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892
73 manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892
74 user: test
74 user: test
75 date: Thu Jan 01 00:00:00 1970 +0000
75 date: Thu Jan 01 00:00:00 1970 +0000
76 files+: c
76 files+: c
77 extra: branch=default
77 extra: branch=default
78 description:
78 description:
79 c
79 c
80
80
81
81
82 $ hg pull
82 $ hg pull
83 pulling from $TESTTMP/blackboxtest (glob)
83 pulling from $TESTTMP/blackboxtest (glob)
84 searching for changes
84 searching for changes
85 adding changesets
85 adding changesets
86 adding manifests
86 adding manifests
87 adding file changes
87 adding file changes
88 added 1 changesets with 1 changes to 1 files
88 added 1 changesets with 1 changes to 1 files
89 (run 'hg update' to get a working copy)
89 (run 'hg update' to get a working copy)
90
90
91 a failure reading from the log is fatal
91 a failure reading from the log is fatal
92
92
93 $ hg blackbox -l 3
93 $ hg blackbox -l 3
94 abort: *$TESTTMP/blackboxtest2/.hg/blackbox.log* (glob)
94 abort: *$TESTTMP/blackboxtest2/.hg/blackbox.log* (glob)
95 [255]
95 [255]
96
96
97 $ rmdir .hg/blackbox.log
97 $ rmdir .hg/blackbox.log
98 $ mv .hg/blackbox.log- .hg/blackbox.log
98 $ mv .hg/blackbox.log- .hg/blackbox.log
99
99
100 backup bundles get logged
100 backup bundles get logged
101
101
102 $ touch d
102 $ touch d
103 $ hg commit -Amd
103 $ hg commit -Amd
104 adding d
104 adding d
105 created new head
105 created new head
106 $ hg strip tip
106 $ hg strip tip
107 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
107 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
108 saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob)
108 saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob)
109 $ hg blackbox -l 6
109 $ hg blackbox -l 6
110 1970/01/01 00:00:00 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip
110 1970/01/01 00:00:00 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip
111 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg
111 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg
112 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated base branch cache in * seconds (glob)
112 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated base branch cache in * seconds (glob)
113 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote base branch cache with 1 labels and 2 nodes
113 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote base branch cache with 1 labels and 2 nodes
114 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> strip tip exited 0 after * seconds (glob)
114 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> strip tip exited 0 after * seconds (glob)
115 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
115 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
116
116
117 extension and python hooks - use the eol extension for a pythonhook
117 extension and python hooks - use the eol extension for a pythonhook
118
118
119 $ echo '[extensions]' >> .hg/hgrc
119 $ echo '[extensions]' >> .hg/hgrc
120 $ echo 'eol=' >> .hg/hgrc
120 $ echo 'eol=' >> .hg/hgrc
121 $ echo '[hooks]' >> .hg/hgrc
121 $ echo '[hooks]' >> .hg/hgrc
122 $ echo 'update = echo hooked' >> .hg/hgrc
122 $ echo 'update = echo hooked' >> .hg/hgrc
123 $ hg update
123 $ hg update
124 hooked
124 hooked
125 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
125 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
126 1 other heads for branch "default"
126 1 other heads for branch "default"
127 $ hg blackbox -l 6
127 $ hg blackbox -l 6
128 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> update
128 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> update
129 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> writing .hg/cache/tags2-visible with 0 tags
129 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> writing .hg/cache/tags2-visible with 0 tags
130 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob)
130 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob)
131 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> exthook-update: echo hooked finished in * seconds (glob)
131 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> exthook-update: echo hooked finished in * seconds (glob)
132 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> update exited 0 after * seconds (glob)
132 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> update exited 0 after * seconds (glob)
133 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> blackbox -l 6
133 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> blackbox -l 6
134
134
135 log rotation
135 log rotation
136
136
137 $ echo '[blackbox]' >> .hg/hgrc
137 $ echo '[blackbox]' >> .hg/hgrc
138 $ echo 'maxsize = 20 b' >> .hg/hgrc
138 $ echo 'maxsize = 20 b' >> .hg/hgrc
139 $ echo 'maxfiles = 3' >> .hg/hgrc
139 $ echo 'maxfiles = 3' >> .hg/hgrc
140 $ hg status
140 $ hg status
141 $ hg status
141 $ hg status
142 $ hg status
142 $ hg status
143 $ hg tip -q
143 $ hg tip -q
144 2:d02f48003e62
144 2:d02f48003e62
145 $ ls .hg/blackbox.log*
145 $ ls .hg/blackbox.log*
146 .hg/blackbox.log
146 .hg/blackbox.log
147 .hg/blackbox.log.1
147 .hg/blackbox.log.1
148 .hg/blackbox.log.2
148 .hg/blackbox.log.2
149 $ cd ..
149 $ cd ..
150
150
151 $ hg init blackboxtest3
151 $ hg init blackboxtest3
152 $ cd blackboxtest3
152 $ cd blackboxtest3
153 $ hg blackbox
153 $ hg blackbox
154 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
154 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
155 $ mv .hg/blackbox.log .hg/blackbox.log-
155 $ mv .hg/blackbox.log .hg/blackbox.log-
156 $ mkdir .hg/blackbox.log
156 $ mkdir .hg/blackbox.log
157 $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\
157 $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\
158 > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\
158 > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\
159 > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
159 > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
160 $ python ../test-dispatch.py
160 $ python $TESTDIR/blackbox-readonly-dispatch.py
161 running: add foo
161 running: add foo
162 result: 0
162 result: 0
163 running: commit -m commit1 -d 2000-01-01 foo
163 running: commit -m commit1 -d 2000-01-01 foo
164 result: None
164 result: None
165 running: commit -m commit2 -d 2000-01-02 foo
165 running: commit -m commit2 -d 2000-01-02 foo
166 result: None
166 result: None
167 running: log -r 0
167 running: log -r 0
168 changeset: 0:0e4634943879
168 changeset: 0:0e4634943879
169 user: test
169 user: test
170 date: Sat Jan 01 00:00:00 2000 +0000
170 date: Sat Jan 01 00:00:00 2000 +0000
171 summary: commit1
171 summary: commit1
172
172
173 result: None
173 result: None
174 running: log -r tip
174 running: log -r tip
175 changeset: 1:45589e459b2e
175 changeset: 1:45589e459b2e
176 tag: tip
176 tag: tip
177 user: test
177 user: test
178 date: Sun Jan 02 00:00:00 2000 +0000
178 date: Sun Jan 02 00:00:00 2000 +0000
179 summary: commit2
179 summary: commit2
180
180
181 result: None
181 result: None
182 $ hg blackbox
182 $ hg blackbox
183 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> commit -m commit2 -d 2000-01-02 foo
183 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> commit -m commit2 -d 2000-01-02 foo
184 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> updated served branch cache in * seconds (glob)
184 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> updated served branch cache in * seconds (glob)
185 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> wrote served branch cache with 1 labels and 1 nodes
185 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> wrote served branch cache with 1 labels and 1 nodes
186 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> commit -m commit2 -d 2000-01-02 foo exited 0 after * seconds (glob)
186 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> commit -m commit2 -d 2000-01-02 foo exited 0 after * seconds (glob)
187 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0
187 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0
188 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> writing .hg/cache/tags2-visible with 0 tags
188 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> writing .hg/cache/tags2-visible with 0 tags
189 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0 exited 0 after * seconds (glob)
189 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0 exited 0 after * seconds (glob)
190 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip
190 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip
191 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip exited 0 after * seconds (glob)
191 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip exited 0 after * seconds (glob)
192 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox
192 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox
193
193
194 cleanup
194 cleanup
195 $ cd ..
195 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now