##// END OF EJS Templates
tests: unify test-hgweb
Matt Mackall -
r12432:7f3af5da default
parent child Browse files
Show More
@@ -1,49 +1,425 b''
1 #!/bin/sh
1 Some tests for hgweb. Tests static files, plain files and different 404's.
2 # Some tests for hgweb. Tests static files, plain files and different 404's.
2
3 $ hg init test
4 $ cd test
5 $ mkdir da
6 $ echo foo > da/foo
7 $ echo foo > foo
8 $ hg ci -Ambase
9 adding da/foo
10 adding foo
11 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
12 $ cat hg.pid >> $DAEMON_PIDS
13
14 manifest
3
15
4 hg init test
16 $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/?style=raw')
5 cd test
17 200 Script output follows
6 mkdir da
18
7 echo foo > da/foo
19
8 echo foo > foo
20 drwxr-xr-x da
9 hg ci -Ambase
21 -rw-r--r-- 4 foo
22
23
24 $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/da?style=raw')
25 200 Script output follows
26
27
28 -rw-r--r-- 4 foo
29
30
31
32 plain file
33
34 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/foo?style=raw'
35 200 Script output follows
36
37 foo
38
39 should give a 404 - static file that does not exist
10
40
11 hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
41 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/static/bogus'
12 cat hg.pid >> $DAEMON_PIDS
42 404 Not Found
43
44 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
45 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
46 <head>
47 <link rel="icon" href="/static/hgicon.png" type="image/png" />
48 <meta name="robots" content="index, nofollow" />
49 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
50
51 <title>test: error</title>
52 </head>
53 <body>
54
55 <div class="container">
56 <div class="menu">
57 <div class="logo">
58 <a href="http://mercurial.selenic.com/">
59 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
60 </div>
61 <ul>
62 <li><a href="/shortlog">log</a></li>
63 <li><a href="/graph">graph</a></li>
64 <li><a href="/tags">tags</a></li>
65 <li><a href="/branches">branches</a></li>
66 </ul>
67 </div>
68
69 <div class="main">
70
71 <h2><a href="/">test</a></h2>
72 <h3>error</h3>
73
74 <form class="search" action="/log">
75
76 <p><input name="rev" id="search1" type="text" size="30"></p>
77 <div id="hint">find changesets by author, revision,
78 files, or words in the commit message</div>
79 </form>
80
81 <div class="description">
82 <p>
83 An error occurred while processing your request:
84 </p>
85 <p>
86 Not Found
87 </p>
88 </div>
89 </div>
90 </div>
91
92
93
94 </body>
95 </html>
96
97 [1]
98
99 should give a 404 - bad revision
100
101 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/spam/foo?style=raw'
102 404 Not Found
103
104
105 error: revision not found: spam
106 [1]
107
108 should give a 400 - bad command
13
109
14 echo % manifest
110 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/foo?cmd=spam&style=raw'
15 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/?style=raw')
111 400* (glob)
16 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/da?style=raw')
112
113
114 error: no such method: spam
115 [1]
116
117 should give a 404 - file does not exist
17
118
18 echo % plain file
119 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork?style=raw'
19 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/foo?style=raw'
120 404 Not Found
121
122
123 error: bork@2ef0ac749a14: not found in manifest
124 [1]
125 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork'
126 404 Not Found
127
128 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
129 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
130 <head>
131 <link rel="icon" href="/static/hgicon.png" type="image/png" />
132 <meta name="robots" content="index, nofollow" />
133 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
134
135 <title>test: error</title>
136 </head>
137 <body>
138
139 <div class="container">
140 <div class="menu">
141 <div class="logo">
142 <a href="http://mercurial.selenic.com/">
143 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
144 </div>
145 <ul>
146 <li><a href="/shortlog">log</a></li>
147 <li><a href="/graph">graph</a></li>
148 <li><a href="/tags">tags</a></li>
149 <li><a href="/branches">branches</a></li>
150 </ul>
151 </div>
152
153 <div class="main">
154
155 <h2><a href="/">test</a></h2>
156 <h3>error</h3>
157
158 <form class="search" action="/log">
159
160 <p><input name="rev" id="search1" type="text" size="30"></p>
161 <div id="hint">find changesets by author, revision,
162 files, or words in the commit message</div>
163 </form>
164
165 <div class="description">
166 <p>
167 An error occurred while processing your request:
168 </p>
169 <p>
170 bork@2ef0ac749a14: not found in manifest
171 </p>
172 </div>
173 </div>
174 </div>
175
176
177
178 </body>
179 </html>
180
181 [1]
182 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/bork?style=raw'
183 404 Not Found
184
185
186 error: bork@2ef0ac749a14: not found in manifest
187 [1]
20
188
21 echo % should give a 404 - static file that does not exist
189 try bad style
22 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/static/bogus'
23
190
24 echo % should give a 404 - bad revision
191 $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/?style=foobar')
25 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/spam/foo?style=raw'
192 200 Script output follows
193
194 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
195 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
196 <head>
197 <link rel="icon" href="/static/hgicon.png" type="image/png" />
198 <meta name="robots" content="index, nofollow" />
199 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
200
201 <title>test: 2ef0ac749a14 /</title>
202 </head>
203 <body>
204
205 <div class="container">
206 <div class="menu">
207 <div class="logo">
208 <a href="http://mercurial.selenic.com/">
209 <img src="/static/hglogo.png" alt="mercurial" /></a>
210 </div>
211 <ul>
212 <li><a href="/shortlog/2ef0ac749a14">log</a></li>
213 <li><a href="/graph/2ef0ac749a14">graph</a></li>
214 <li><a href="/tags">tags</a></li>
215 <li><a href="/branches">branches</a></li>
216 </ul>
217 <ul>
218 <li><a href="/rev/2ef0ac749a14">changeset</a></li>
219 <li class="active">browse</li>
220 </ul>
221 <ul>
222
223 </ul>
224 </div>
225
226 <div class="main">
227 <h2><a href="/">test</a></h2>
228 <h3>directory / @ 0:2ef0ac749a14 <span class="tag">tip</span> </h3>
229
230 <form class="search" action="/log">
231
232 <p><input name="rev" id="search1" type="text" size="30" /></p>
233 <div id="hint">find changesets by author, revision,
234 files, or words in the commit message</div>
235 </form>
236
237 <table class="bigtable">
238 <tr>
239 <th class="name">name</th>
240 <th class="size">size</th>
241 <th class="permissions">permissions</th>
242 </tr>
243 <tr class="fileline parity0">
244 <td class="name"><a href="/file/2ef0ac749a14/">[up]</a></td>
245 <td class="size"></td>
246 <td class="permissions">drwxr-xr-x</td>
247 </tr>
248
249 <tr class="fileline parity1">
250 <td class="name">
251 <a href="/file/2ef0ac749a14/da">
252 <img src="/static/coal-folder.png" alt="dir."/> da/
253 </a>
254 <a href="/file/2ef0ac749a14/da/">
255
256 </a>
257 </td>
258 <td class="size"></td>
259 <td class="permissions">drwxr-xr-x</td>
260 </tr>
261
262 <tr class="fileline parity0">
263 <td class="filename">
264 <a href="/file/2ef0ac749a14/foo">
265 <img src="/static/coal-file.png" alt="file"/> foo
266 </a>
267 </td>
268 <td class="size">4</td>
269 <td class="permissions">-rw-r--r--</td>
270 </tr>
271 </table>
272 </div>
273 </div>
274
275
276 </body>
277 </html>
278
26
279
27 echo % should give a 400 - bad command
280 stop and restart
28 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/foo?cmd=spam&style=raw' | sed 's/400.*/400/'
281
282 $ "$TESTDIR/killdaemons.py"
283 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log
284 $ cat hg.pid >> $DAEMON_PIDS
29
285
30 echo % should give a 404 - file does not exist
286 Test the access/error files are opened in append mode
31 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork?style=raw'
287
32 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork'
288 $ python -c "print len(file('access.log').readlines()), 'log lines written'"
33 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/bork?style=raw'
289 10 log lines written
290
291 static file
34
292
35 echo % try bad style
293 $ "$TESTDIR/get-with-headers.py" --twice localhost:$HGPORT '/static/style-gitweb.css'
36 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/?style=foobar')
294 200 Script output follows
295
296 body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid #d9d8d1; border-width:1px; margin:10px; }
297 a { color:#0000cc; }
298 a:hover, a:visited, a:active { color:#880000; }
299 div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; }
300 div.page_header a:visited { color:#0000cc; }
301 div.page_header a:hover { color:#880000; }
302 div.page_nav { padding:8px; }
303 div.page_nav a:visited { color:#0000cc; }
304 div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px}
305 div.page_footer { padding:4px 8px; background-color: #d9d8d1; }
306 div.page_footer_text { float:left; color:#555555; font-style:italic; }
307 div.page_body { padding:8px; }
308 div.title, a.title {
309 display:block; padding:6px 8px;
310 font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000;
311 }
312 a.title:hover { background-color: #d9d8d1; }
313 div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; }
314 div.log_body { padding:8px 8px 8px 150px; }
315 .age { white-space:nowrap; }
316 span.age { position:relative; float:left; width:142px; font-style:italic; }
317 div.log_link {
318 padding:0px 8px;
319 font-size:10px; font-family:sans-serif; font-style:normal;
320 position:relative; float:left; width:136px;
321 }
322 div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; }
323 a.list { text-decoration:none; color:#000000; }
324 a.list:hover { text-decoration:underline; color:#880000; }
325 table { padding:8px 4px; }
326 th { padding:2px 5px; font-size:12px; text-align:left; }
327 tr.light:hover, .parity0:hover { background-color:#edece6; }
328 tr.dark, .parity1 { background-color:#f6f6f0; }
329 tr.dark:hover, .parity1:hover { background-color:#edece6; }
330 td { padding:2px 5px; font-size:12px; vertical-align:top; }
331 td.closed { background-color: #99f; }
332 td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; }
333 td.indexlinks { white-space: nowrap; }
334 td.indexlinks a {
335 padding: 2px 5px; line-height: 10px;
336 border: 1px solid;
337 color: #ffffff; background-color: #7777bb;
338 border-color: #aaaadd #333366 #333366 #aaaadd;
339 font-weight: bold; text-align: center; text-decoration: none;
340 font-size: 10px;
341 }
342 td.indexlinks a:hover { background-color: #6666aa; }
343 div.pre { font-family:monospace; font-size:12px; white-space:pre; }
344 div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; }
345 div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
346 div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
347 .linenr { color:#999999; text-decoration:none }
348 div.rss_logo { float: right; white-space: nowrap; }
349 div.rss_logo a {
350 padding:3px 6px; line-height:10px;
351 border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
352 color:#ffffff; background-color:#ff6600;
353 font-weight:bold; font-family:sans-serif; font-size:10px;
354 text-align:center; text-decoration:none;
355 }
356 div.rss_logo a:hover { background-color:#ee5500; }
357 pre { margin: 0; }
358 span.logtags span {
359 padding: 0px 4px;
360 font-size: 10px;
361 font-weight: normal;
362 border: 1px solid;
363 background-color: #ffaaff;
364 border-color: #ffccff #ff00ee #ff00ee #ffccff;
365 }
366 span.logtags span.tagtag {
367 background-color: #ffffaa;
368 border-color: #ffffcc #ffee00 #ffee00 #ffffcc;
369 }
370 span.logtags span.branchtag {
371 background-color: #aaffaa;
372 border-color: #ccffcc #00cc33 #00cc33 #ccffcc;
373 }
374 span.logtags span.inbranchtag {
375 background-color: #d5dde6;
376 border-color: #e3ecf4 #9398f4 #9398f4 #e3ecf4;
377 }
378
379 /* Graph */
380 div#wrapper {
381 position: relative;
382 margin: 0;
383 padding: 0;
384 margin-top: 3px;
385 }
386
387 canvas {
388 position: absolute;
389 z-index: 5;
390 top: -0.9em;
391 margin: 0;
392 }
393
394 ul#nodebgs {
395 list-style: none inside none;
396 padding: 0;
397 margin: 0;
398 top: -0.7em;
399 }
400
401 ul#graphnodes li, ul#nodebgs li {
402 height: 39px;
403 }
404
405 ul#graphnodes {
406 position: absolute;
407 z-index: 10;
408 top: -0.8em;
409 list-style: none inside none;
410 padding: 0;
411 }
412
413 ul#graphnodes li .info {
414 display: block;
415 font-size: 100%;
416 position: relative;
417 top: -3px;
418 font-style: italic;
419 }
420 304 Not Modified
421
37
422
38 echo % stop and restart
423 errors
39 "$TESTDIR/killdaemons.py"
40 hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log
41 cat hg.pid >> $DAEMON_PIDS
42 # Test the access/error files are opened in append mode
43 python -c "print len(file('access.log').readlines()), 'log lines written'"
44
424
45 echo % static file
425 $ cat errors.log
46 "$TESTDIR/get-with-headers.py" --twice localhost:$HGPORT '/static/style-gitweb.css'
47
48 echo % errors
49 cat errors.log
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now