Mercurial > hg
annotate tests/test-hgweb-non-interactive.t @ 12664:545ec1775021
merge: handle no file parent in backwards merge (issue2364)
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 09 Oct 2010 14:50:20 -0500 |
parents | d9f7753a94d5 |
children | 4c4aeaab2339 |
rev | line source |
---|---|
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
1 Tests if hgweb can run without touching sys.stdin, as is required |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
2 by the WSGI standard and strictly implemented by mod_wsgi. |
5337
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
3 |
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
4 $ mkdir repo |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
5 $ cd repo |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
6 $ hg init |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
7 $ echo foo > bar |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
8 $ hg add bar |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
9 $ hg commit -m "test" |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
10 $ cat > request.py <<EOF |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
11 > from mercurial import dispatch |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
12 > from mercurial.hgweb.hgweb_mod import hgweb |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
13 > from mercurial.ui import ui |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
14 > from mercurial import hg |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
15 > from StringIO import StringIO |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
16 > import os, sys |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
17 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
18 > class FileLike(object): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
19 > def __init__(self, real): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
20 > self.real = real |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
21 > def fileno(self): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
22 > print >> sys.__stdout__, 'FILENO' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
23 > return self.real.fileno() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
24 > def read(self): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
25 > print >> sys.__stdout__, 'READ' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
26 > return self.real.read() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
27 > def readline(self): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
28 > print >> sys.__stdout__, 'READLINE' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
29 > return self.real.readline() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
30 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
31 > sys.stdin = FileLike(sys.stdin) |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
32 > errors = StringIO() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
33 > input = StringIO() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
34 > output = StringIO() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
35 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
36 > def startrsp(status, headers): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
37 > print '---- STATUS' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
38 > print status |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
39 > print '---- HEADERS' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
40 > print [i for i in headers if i[0] != 'ETag'] |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
41 > print '---- DATA' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
42 > return output.write |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
43 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
44 > env = { |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
45 > 'wsgi.version': (1, 0), |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
46 > 'wsgi.url_scheme': 'http', |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
47 > 'wsgi.errors': errors, |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
48 > 'wsgi.input': input, |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
49 > 'wsgi.multithread': False, |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
50 > 'wsgi.multiprocess': False, |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
51 > 'wsgi.run_once': False, |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
52 > 'REQUEST_METHOD': 'GET', |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
53 > 'SCRIPT_NAME': '', |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
54 > 'PATH_INFO': '', |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
55 > 'QUERY_STRING': '', |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
56 > 'SERVER_NAME': '127.0.0.1', |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
57 > 'SERVER_PORT': os.environ['HGPORT'], |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
58 > 'SERVER_PROTOCOL': 'HTTP/1.0' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
59 > } |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
60 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
61 > i = hgweb('.') |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
62 > i(env, startrsp) |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
63 > print '---- ERRORS' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
64 > print errors.getvalue() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
65 > print '---- OS.ENVIRON wsgi variables' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
66 > print sorted([x for x in os.environ if x.startswith('wsgi')]) |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
67 > print '---- request.ENVIRON wsgi variables' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
68 > print sorted([x for x in i.repo.ui.environ if x.startswith('wsgi')]) |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
69 > EOF |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
70 $ python request.py |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
71 ---- STATUS |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
72 200 Script output follows |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
73 ---- HEADERS |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
74 [('Content-Type', 'text/html; charset=ascii')] |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
75 ---- DATA |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
76 ---- ERRORS |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
77 |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
78 ---- OS.ENVIRON wsgi variables |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
79 [] |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
80 ---- request.ENVIRON wsgi variables |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
81 ['wsgi.errors', 'wsgi.input', 'wsgi.multiprocess', 'wsgi.multithread', 'wsgi.run_once', 'wsgi.url_scheme', 'wsgi.version'] |