Mercurial > hg
annotate tests/test-hgweb-non-interactive @ 12181:045c9e8db0d8
tests: fix test output for test-hgweb-no* tests
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Wed, 08 Sep 2010 15:19:35 +0200 |
parents | 45e654e10e1b |
children | f64b416b0ac8 |
rev | line source |
---|---|
5337
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
1 #!/bin/sh |
5580
f429e0e067a8
Fix style nit and add some comments to tests.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5566
diff
changeset
|
2 # Tests if hgweb can run without touching sys.stdin, as is required |
f429e0e067a8
Fix style nit and add some comments to tests.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5566
diff
changeset
|
3 # 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
|
4 |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
5 mkdir repo |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
6 cd repo |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
7 hg init |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
8 echo foo > bar |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
9 hg add bar |
8167
6c82beaaa11a
tests: removed redundant "-d '0 0'" from test scripts
Martin Geisler <mg@lazybytes.net>
parents:
8136
diff
changeset
|
10 hg commit -m "test" |
5337
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
11 hg tip |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
12 |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
13 cat > request.py <<EOF |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
14 from mercurial import dispatch |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
15 from mercurial.hgweb.hgweb_mod import hgweb |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
16 from mercurial.ui import ui |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
17 from mercurial import hg |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
18 from StringIO import StringIO |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5337
diff
changeset
|
19 import os, sys |
5337
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
20 |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
21 class FileLike(object): |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
22 def __init__(self, real): |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
23 self.real = real |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
24 def fileno(self): |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
25 print >> sys.__stdout__, 'FILENO' |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
26 return self.real.fileno() |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
27 def read(self): |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
28 print >> sys.__stdout__, 'READ' |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
29 return self.real.read() |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
30 def readline(self): |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
31 print >> sys.__stdout__, 'READLINE' |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
32 return self.real.readline() |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
33 |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
34 sys.stdin = FileLike(sys.stdin) |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
35 errors = StringIO() |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
36 input = StringIO() |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
37 output = StringIO() |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
38 |
12181
045c9e8db0d8
tests: fix test output for test-hgweb-no* tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12180
diff
changeset
|
39 def startrsp(status, headers): |
045c9e8db0d8
tests: fix test output for test-hgweb-no* tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12180
diff
changeset
|
40 print '---- STATUS' |
045c9e8db0d8
tests: fix test output for test-hgweb-no* tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12180
diff
changeset
|
41 print status |
5337
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
42 print '---- HEADERS' |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
43 print headers |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
44 print '---- DATA' |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
45 return output.write |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
46 |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
47 env = { |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
48 'wsgi.version': (1, 0), |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
49 'wsgi.url_scheme': 'http', |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
50 'wsgi.errors': errors, |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
51 'wsgi.input': input, |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
52 'wsgi.multithread': False, |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
53 'wsgi.multiprocess': False, |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
54 'wsgi.run_once': False, |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
55 'REQUEST_METHOD': 'GET', |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
56 'SCRIPT_NAME': '', |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
57 'PATH_INFO': '', |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
58 'QUERY_STRING': '', |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
59 'SERVER_NAME': '127.0.0.1', |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5337
diff
changeset
|
60 'SERVER_PORT': os.environ['HGPORT'], |
5337
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
61 'SERVER_PROTOCOL': 'HTTP/1.0' |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
62 } |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
63 |
9888
510122bb3c7f
hgweb: fix error in 38170eeed18c and introduce test for change
Henrik Stuart <hg@hstuart.dk>
parents:
8167
diff
changeset
|
64 i = hgweb('.') |
510122bb3c7f
hgweb: fix error in 38170eeed18c and introduce test for change
Henrik Stuart <hg@hstuart.dk>
parents:
8167
diff
changeset
|
65 i(env, startrsp) |
5337
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
66 print '---- ERRORS' |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
67 print errors.getvalue() |
9888
510122bb3c7f
hgweb: fix error in 38170eeed18c and introduce test for change
Henrik Stuart <hg@hstuart.dk>
parents:
8167
diff
changeset
|
68 print '---- OS.ENVIRON wsgi variables' |
9889
38864218c4cc
test-non-interactive-wsgi: make output deterministic
Martin Geisler <mg@lazybytes.net>
parents:
9888
diff
changeset
|
69 print sorted([x for x in os.environ if x.startswith('wsgi')]) |
9888
510122bb3c7f
hgweb: fix error in 38170eeed18c and introduce test for change
Henrik Stuart <hg@hstuart.dk>
parents:
8167
diff
changeset
|
70 print '---- request.ENVIRON wsgi variables' |
9889
38864218c4cc
test-non-interactive-wsgi: make output deterministic
Martin Geisler <mg@lazybytes.net>
parents:
9888
diff
changeset
|
71 print sorted([x for x in i.repo.ui.environ if x.startswith('wsgi')]) |
5337
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
72 EOF |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
73 |
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
74 python request.py |