annotate tests/test-newcgi.t @ 12582:18c79cef795c

serve: let --web-conf help reference hgweb
author Mads Kiilerich <mads@kiilerich.com>
date Wed, 29 Sep 2010 01:32:50 +0200
parents 70a6734cf761
children 4c4aeaab2339
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12470
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
1 This tests if CGI files from after d0db3462d568 but
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
2 before d74fc8dec2b4 still work.
5577
e0173902c813 CGI compatibility fix for d74fc8dec2b4.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
3
12470
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
4 $ hg init test
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
5 $ cat >hgweb.cgi <<HGWEB
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
6 > #!/usr/bin/env python
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
7 > #
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
8 > # An example CGI script to use hgweb, edit as necessary
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
9 >
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
10 > import cgitb
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
11 > cgitb.enable()
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
12 >
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
13 > from mercurial import demandimport; demandimport.enable()
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
14 > from mercurial.hgweb import hgweb
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
15 > from mercurial.hgweb import wsgicgi
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
16 > from mercurial.hgweb.request import wsgiapplication
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
17 >
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
18 > def make_web_app():
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
19 > return hgweb("test", "Empty test repository")
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
20 >
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
21 > wsgicgi.launch(wsgiapplication(make_web_app))
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
22 > HGWEB
5577
e0173902c813 CGI compatibility fix for d74fc8dec2b4.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
23
12470
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
24 $ chmod 755 hgweb.cgi
5577
e0173902c813 CGI compatibility fix for d74fc8dec2b4.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
25
12470
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
26 $ cat >hgweb.config <<HGWEBDIRCONF
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
27 > [paths]
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
28 > test = test
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
29 > HGWEBDIRCONF
5577
e0173902c813 CGI compatibility fix for d74fc8dec2b4.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
30
12470
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
31 $ cat >hgwebdir.cgi <<HGWEBDIR
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
32 > #!/usr/bin/env python
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
33 > #
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
34 > # An example CGI script to export multiple hgweb repos, edit as necessary
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
35 >
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
36 > import cgitb
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
37 > cgitb.enable()
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
38 >
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
39 > from mercurial import demandimport; demandimport.enable()
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
40 > from mercurial.hgweb import hgwebdir
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
41 > from mercurial.hgweb import wsgicgi
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
42 > from mercurial.hgweb.request import wsgiapplication
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
43 >
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
44 > def make_web_app():
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
45 > return hgwebdir("hgweb.config")
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
46 >
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
47 > wsgicgi.launch(wsgiapplication(make_web_app))
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
48 > HGWEBDIR
5577
e0173902c813 CGI compatibility fix for d74fc8dec2b4.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
49
12470
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
50 $ chmod 755 hgwebdir.cgi
5577
e0173902c813 CGI compatibility fix for d74fc8dec2b4.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
51
12470
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
52 $ DOCUMENT_ROOT="/var/www/hg"; export DOCUMENT_ROOT
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
53 $ GATEWAY_INTERFACE="CGI/1.1"; export GATEWAY_INTERFACE
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
54 $ HTTP_ACCEPT="text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; export HTTP_ACCEPT
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
55 $ HTTP_ACCEPT_CHARSET="ISO-8859-1,utf-8;q=0.7,*;q=0.7"; export HTTP_ACCEPT_CHARSET
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
56 $ HTTP_ACCEPT_ENCODING="gzip,deflate"; export HTTP_ACCEPT_ENCODING
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
57 $ HTTP_ACCEPT_LANGUAGE="en-us,en;q=0.5"; export HTTP_ACCEPT_LANGUAGE
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
58 $ HTTP_CACHE_CONTROL="max-age=0"; export HTTP_CACHE_CONTROL
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
59 $ HTTP_CONNECTION="keep-alive"; export HTTP_CONNECTION
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
60 $ HTTP_HOST="hg.omnifarious.org"; export HTTP_HOST
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
61 $ HTTP_KEEP_ALIVE="300"; export HTTP_KEEP_ALIVE
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
62 $ HTTP_USER_AGENT="Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.4) Gecko/20060608 Ubuntu/dapper-security Firefox/1.5.0.4"; export HTTP_USER_AGENT
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
63 $ PATH_INFO="/"; export PATH_INFO
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
64 $ PATH_TRANSLATED="/var/www/hg/index.html"; export PATH_TRANSLATED
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
65 $ QUERY_STRING=""; export QUERY_STRING
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
66 $ REMOTE_ADDR="127.0.0.2"; export REMOTE_ADDR
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
67 $ REMOTE_PORT="44703"; export REMOTE_PORT
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
68 $ REQUEST_METHOD="GET"; export REQUEST_METHOD
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
69 $ REQUEST_URI="/test/"; export REQUEST_URI
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
70 $ SCRIPT_FILENAME="/home/hopper/hg_public/test.cgi"; export SCRIPT_FILENAME
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
71 $ SCRIPT_NAME="/test"; export SCRIPT_NAME
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
72 $ SCRIPT_URI="http://hg.omnifarious.org/test/"; export SCRIPT_URI
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
73 $ SCRIPT_URL="/test/"; export SCRIPT_URL
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
74 $ SERVER_ADDR="127.0.0.1"; export SERVER_ADDR
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
75 $ SERVER_ADMIN="eric@localhost"; export SERVER_ADMIN
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
76 $ SERVER_NAME="hg.omnifarious.org"; export SERVER_NAME
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
77 $ SERVER_PORT="80"; export SERVER_PORT
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
78 $ SERVER_PROTOCOL="HTTP/1.1"; export SERVER_PROTOCOL
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
79 $ SERVER_SIGNATURE="<address>Apache/2.0.53 (Fedora) Server at hg.omnifarious.org Port 80</address>"; export SERVER_SIGNATURE
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
80 $ SERVER_SOFTWARE="Apache/2.0.53 (Fedora)"; export SERVER_SOFTWARE
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
81
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
82 $ python hgweb.cgi > page1
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
83 $ python hgwebdir.cgi > page2
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
84
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
85 $ PATH_INFO="/test/"
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
86 $ PATH_TRANSLATED="/var/something/test.cgi"
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
87 $ REQUEST_URI="/test/test/"
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
88 $ SCRIPT_URI="http://hg.omnifarious.org/test/test/"
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
89 $ SCRIPT_URL="/test/test/"
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
90 $ python hgwebdir.cgi > page3
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
91
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
92 $ grep -i error page1 page2 page3
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
93 [1]