##// END OF EJS Templates
tests: unify test-hgweb-no-request-uri
Matt Mackall -
r12439:31ea3ce8 default
parent child Browse files
Show More
@@ -1,74 +1,143 b''
1 #!/bin/sh
1 This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is
2 # This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is
2 no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO
3 # no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO
3 should be used from d74fc8dec2b4 onward to route the request.
4 # should be used from d74fc8dec2b4 onward to route the request.
5
6 mkdir repo
7 cd repo
8 hg init
9 echo foo > bar
10 hg add bar
11 hg commit -m "test"
12 hg tip
13
14 cat > request.py <<EOF
15 from mercurial.hgweb import hgweb, hgwebdir
16 from StringIO import StringIO
17 import os, sys
18
19 errors = StringIO()
20 input = StringIO()
21
22 def startrsp(status, headers):
23 print '---- STATUS'
24 print status
25 print '---- HEADERS'
26 print [i for i in headers if i[0] != 'ETag']
27 print '---- DATA'
28 return output.write
29
4
30 env = {
5 $ mkdir repo
31 'wsgi.version': (1, 0),
6 $ cd repo
32 'wsgi.url_scheme': 'http',
7 $ hg init
33 'wsgi.errors': errors,
8 $ echo foo > bar
34 'wsgi.input': input,
9 $ hg add bar
35 'wsgi.multithread': False,
10 $ hg commit -m "test"
36 'wsgi.multiprocess': False,
11 $ hg tip
37 'wsgi.run_once': False,
12 changeset: 0:61c9426e69fe
38 'REQUEST_METHOD': 'GET',
13 tag: tip
39 'SCRIPT_NAME': '',
14 user: test
40 'SERVER_NAME': '127.0.0.1',
15 date: Thu Jan 01 00:00:00 1970 +0000
41 'SERVER_PORT': os.environ['HGPORT'],
16 summary: test
42 'SERVER_PROTOCOL': 'HTTP/1.0'
17
43 }
18 $ cat > request.py <<EOF
44
19 > from mercurial.hgweb import hgweb, hgwebdir
45 def process(app):
20 > from StringIO import StringIO
46 content = app(env, startrsp)
21 > import os, sys
47 sys.stdout.write(output.getvalue())
22 >
48 sys.stdout.write(''.join(content))
23 > errors = StringIO()
49 print '---- ERRORS'
24 > input = StringIO()
50 print errors.getvalue()
25 >
51
26 > def startrsp(status, headers):
52
27 > print '---- STATUS'
53 output = StringIO()
28 > print status
54 env['PATH_INFO'] = '/'
29 > print '---- HEADERS'
55 env['QUERY_STRING'] = 'style=atom'
30 > print [i for i in headers if i[0] != 'ETag']
56 process(hgweb('.', name = 'repo'))
31 > print '---- DATA'
57
32 > return output.write
58 output = StringIO()
33 >
59 env['PATH_INFO'] = '/file/tip/'
34 > env = {
60 env['QUERY_STRING'] = 'style=raw'
35 > 'wsgi.version': (1, 0),
61 process(hgweb('.', name = 'repo'))
36 > 'wsgi.url_scheme': 'http',
62
37 > 'wsgi.errors': errors,
63 output = StringIO()
38 > 'wsgi.input': input,
64 env['PATH_INFO'] = '/'
39 > 'wsgi.multithread': False,
65 env['QUERY_STRING'] = 'style=raw'
40 > 'wsgi.multiprocess': False,
66 process(hgwebdir({'repo': '.'}))
41 > 'wsgi.run_once': False,
67
42 > 'REQUEST_METHOD': 'GET',
68 output = StringIO()
43 > 'SCRIPT_NAME': '',
69 env['PATH_INFO'] = '/repo/file/tip/'
44 > 'SERVER_NAME': '127.0.0.1',
70 env['QUERY_STRING'] = 'style=raw'
45 > 'SERVER_PORT': os.environ['HGPORT'],
71 process(hgwebdir({'repo': '.'}))
46 > 'SERVER_PROTOCOL': 'HTTP/1.0'
72 EOF
47 > }
73
48 >
74 python request.py | sed "s/http:\/\/127\.0\.0\.1:[0-9]*\//http:\/\/127.0.0.1\//"
49 > def process(app):
50 > content = app(env, startrsp)
51 > sys.stdout.write(output.getvalue())
52 > sys.stdout.write(''.join(content))
53 > print '---- ERRORS'
54 > print errors.getvalue()
55 >
56 >
57 > output = StringIO()
58 > env['PATH_INFO'] = '/'
59 > env['QUERY_STRING'] = 'style=atom'
60 > process(hgweb('.', name = 'repo'))
61 >
62 > output = StringIO()
63 > env['PATH_INFO'] = '/file/tip/'
64 > env['QUERY_STRING'] = 'style=raw'
65 > process(hgweb('.', name = 'repo'))
66 >
67 > output = StringIO()
68 > env['PATH_INFO'] = '/'
69 > env['QUERY_STRING'] = 'style=raw'
70 > process(hgwebdir({'repo': '.'}))
71 >
72 > output = StringIO()
73 > env['PATH_INFO'] = '/repo/file/tip/'
74 > env['QUERY_STRING'] = 'style=raw'
75 > process(hgwebdir({'repo': '.'}))
76 > EOF
77 $ python request.py
78 ---- STATUS
79 200 Script output follows
80 ---- HEADERS
81 [('Content-Type', 'application/atom+xml; charset=ascii')]
82 ---- DATA
83 <?xml version="1.0" encoding="ascii"?>
84 <feed xmlns="http://www.w3.org/2005/Atom">
85 <!-- Changelog -->
86 <id>http://127.0.0.1:*/</id> (glob)
87 <link rel="self" href="http://127.0.0.1:*/atom-log"/> (glob)
88 <link rel="alternate" href="http://127.0.0.1:*/"/> (glob)
89 <title>repo Changelog</title>
90 <updated>1970-01-01T00:00:00+00:00</updated>
91
92 <entry>
93 <title>test</title>
94 <id>http://127.0.0.1:*/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob)
95 <link href="http://127.0.0.1:*/rev/61c9426e69fe"/> (glob)
96 <author>
97 <name>test</name>
98 <email>&#116;&#101;&#115;&#116;</email>
99 </author>
100 <updated>1970-01-01T00:00:00+00:00</updated>
101 <published>1970-01-01T00:00:00+00:00</published>
102 <content type="xhtml">
103 <div xmlns="http://www.w3.org/1999/xhtml">
104 <pre xml:space="preserve">test</pre>
105 </div>
106 </content>
107 </entry>
108
109 </feed>
110 ---- ERRORS
111
112 ---- STATUS
113 200 Script output follows
114 ---- HEADERS
115 [('Content-Type', 'text/plain; charset=ascii')]
116 ---- DATA
117
118 -rw-r--r-- 4 bar
119
120
121 ---- ERRORS
122
123 ---- STATUS
124 200 Script output follows
125 ---- HEADERS
126 [('Content-Type', 'text/plain; charset=ascii')]
127 ---- DATA
128
129 /repo/
130
131 ---- ERRORS
132
133 ---- STATUS
134 200 Script output follows
135 ---- HEADERS
136 [('Content-Type', 'text/plain; charset=ascii')]
137 ---- DATA
138
139 -rw-r--r-- 4 bar
140
141
142 ---- ERRORS
143
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