##// END OF EJS Templates
tests: mock getpid to reduce glob usage...
timeless -
r28028:ac49ecb2 default
parent child Browse files
Show More
@@ -1,11 +1,14
1 from mercurial import util
1 from mercurial import util
2
2
3 def makedate():
3 def makedate():
4 return 0, 0
4 return 0, 0
5 def getuser():
5 def getuser():
6 return 'bob'
6 return 'bob'
7 def getpid():
8 return 5000
7
9
8 # mock the date and user apis so the output is always the same
10 # mock the date and user apis so the output is always the same
9 def uisetup(ui):
11 def uisetup(ui):
10 util.makedate = makedate
12 util.makedate = makedate
11 util.getuser = getuser
13 util.getuser = getuser
14 util.getpid = getpid
@@ -1,185 +1,185
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
15 $ hg blackbox
16 1970/01/01 00:00:00 bob (*)> add a (glob)
16 1970/01/01 00:00:00 bob (*)> add a (glob)
17 1970/01/01 00:00:00 bob (*)> add a exited 0 after * seconds (glob)
17 1970/01/01 00:00:00 bob (*)> add a exited 0 after * seconds (glob)
18 1970/01/01 00:00:00 bob (*)> blackbox (glob)
18 1970/01/01 00:00:00 bob (*)> blackbox (glob)
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 (*)> pull (glob)
48 1970/01/01 00:00:00 bob (*)> pull (glob)
49 1970/01/01 00:00:00 bob (*)> updated served branch cache in * seconds (glob)
49 1970/01/01 00:00:00 bob (*)> updated served branch cache in * seconds (glob)
50 1970/01/01 00:00:00 bob (*)> wrote served branch cache with 1 labels and 2 nodes (glob)
50 1970/01/01 00:00:00 bob (*)> wrote served branch cache with 1 labels and 2 nodes (glob)
51 1970/01/01 00:00:00 bob (*)> 1 incoming changes - new heads: d02f48003e62 (glob)
51 1970/01/01 00:00:00 bob (*)> 1 incoming changes - new heads: d02f48003e62 (glob)
52 1970/01/01 00:00:00 bob (*)> pull exited 0 after * seconds (glob)
52 1970/01/01 00:00:00 bob (*)> pull exited 0 after * seconds (glob)
53 1970/01/01 00:00:00 bob (*)> blackbox -l 6 (glob)
53 1970/01/01 00:00:00 bob (*)> blackbox -l 6 (glob)
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 (*)> strip tip (glob)
110 1970/01/01 00:00:00 bob (*)> strip tip (glob)
111 1970/01/01 00:00:00 bob (*)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob)
111 1970/01/01 00:00:00 bob (*)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg (glob)
112 1970/01/01 00:00:00 bob (*)> updated base branch cache in * seconds (glob)
112 1970/01/01 00:00:00 bob (*)> updated base branch cache in * seconds (glob)
113 1970/01/01 00:00:00 bob (*)> wrote base branch cache with 1 labels and 2 nodes (glob)
113 1970/01/01 00:00:00 bob (*)> wrote base branch cache with 1 labels and 2 nodes (glob)
114 1970/01/01 00:00:00 bob (*)> strip tip exited 0 after * seconds (glob)
114 1970/01/01 00:00:00 bob (*)> strip tip exited 0 after * seconds (glob)
115 1970/01/01 00:00:00 bob (*)> blackbox -l 6 (glob)
115 1970/01/01 00:00:00 bob (*)> blackbox -l 6 (glob)
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 $ hg blackbox -l 6
126 $ hg blackbox -l 6
127 1970/01/01 00:00:00 bob (*)> update (glob)
127 1970/01/01 00:00:00 bob (*)> update (glob)
128 1970/01/01 00:00:00 bob (*)> writing .hg/cache/tags2-visible with 0 tags (glob)
128 1970/01/01 00:00:00 bob (*)> writing .hg/cache/tags2-visible with 0 tags (glob)
129 1970/01/01 00:00:00 bob (*)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob)
129 1970/01/01 00:00:00 bob (*)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob)
130 1970/01/01 00:00:00 bob (*)> exthook-update: echo hooked finished in * seconds (glob)
130 1970/01/01 00:00:00 bob (*)> exthook-update: echo hooked finished in * seconds (glob)
131 1970/01/01 00:00:00 bob (*)> update exited 0 after * seconds (glob)
131 1970/01/01 00:00:00 bob (*)> update exited 0 after * seconds (glob)
132 1970/01/01 00:00:00 bob (*)> blackbox -l 6 (glob)
132 1970/01/01 00:00:00 bob (*)> blackbox -l 6 (glob)
133
133
134 log rotation
134 log rotation
135
135
136 $ echo '[blackbox]' >> .hg/hgrc
136 $ echo '[blackbox]' >> .hg/hgrc
137 $ echo 'maxsize = 20 b' >> .hg/hgrc
137 $ echo 'maxsize = 20 b' >> .hg/hgrc
138 $ echo 'maxfiles = 3' >> .hg/hgrc
138 $ echo 'maxfiles = 3' >> .hg/hgrc
139 $ hg status
139 $ hg status
140 $ hg status
140 $ hg status
141 $ hg status
141 $ hg status
142 $ hg tip -q
142 $ hg tip -q
143 2:d02f48003e62
143 2:d02f48003e62
144 $ ls .hg/blackbox.log*
144 $ ls .hg/blackbox.log*
145 .hg/blackbox.log
145 .hg/blackbox.log
146 .hg/blackbox.log.1
146 .hg/blackbox.log.1
147 .hg/blackbox.log.2
147 .hg/blackbox.log.2
148 $ cd ..
148 $ cd ..
149
149
150 $ hg init blackboxtest3
150 $ hg init blackboxtest3
151 $ cd blackboxtest3
151 $ cd blackboxtest3
152 $ hg blackbox
152 $ hg blackbox
153 1970/01/01 00:00:00 bob (*)> blackbox (glob)
153 1970/01/01 00:00:00 bob (*)> blackbox (glob)
154 $ mv .hg/blackbox.log .hg/blackbox.log-
154 $ mv .hg/blackbox.log .hg/blackbox.log-
155 $ mkdir .hg/blackbox.log
155 $ mkdir .hg/blackbox.log
156 $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\nos.rename(".hg/blackbox.log-", ".hg/blackbox.log")\n\1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
156 $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\nos.rename(".hg/blackbox.log-", ".hg/blackbox.log")\n\1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
157 $ python ../test-dispatch.py
157 $ python ../test-dispatch.py
158 running: add foo
158 running: add foo
159 result: 0
159 result: 0
160 running: commit -m commit1 -d 2000-01-01 foo
160 running: commit -m commit1 -d 2000-01-01 foo
161 result: None
161 result: None
162 running: commit -m commit2 -d 2000-01-02 foo
162 running: commit -m commit2 -d 2000-01-02 foo
163 result: None
163 result: None
164 running: log -r 0
164 running: log -r 0
165 changeset: 0:0e4634943879
165 changeset: 0:0e4634943879
166 user: test
166 user: test
167 date: Sat Jan 01 00:00:00 2000 +0000
167 date: Sat Jan 01 00:00:00 2000 +0000
168 summary: commit1
168 summary: commit1
169
169
170 result: None
170 result: None
171 running: log -r tip
171 running: log -r tip
172 changeset: 1:45589e459b2e
172 changeset: 1:45589e459b2e
173 tag: tip
173 tag: tip
174 user: test
174 user: test
175 date: Sun Jan 02 00:00:00 2000 +0000
175 date: Sun Jan 02 00:00:00 2000 +0000
176 summary: commit2
176 summary: commit2
177
177
178 result: None
178 result: None
179 $ hg blackbox
179 $ hg blackbox
180 1970/01/01 00:00:00 bob (*)> blackbox (glob)
180 1970/01/01 00:00:00 bob (*)> blackbox (glob)
181 1970/01/01 00:00:00 bob (*)> blackbox exited 0 after * seconds (glob)
181 1970/01/01 00:00:00 bob (*)> blackbox exited 0 after * seconds (glob)
182 1970/01/01 00:00:00 bob (*)> blackbox (glob)
182 1970/01/01 00:00:00 bob (*)> blackbox (glob)
183
183
184 cleanup
184 cleanup
185 $ cd ..
185 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now