Mercurial > hg
annotate tests/test-oldcgi.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 | 17c62039cadd |
children | aa3f726a2bdb |
rev | line source |
---|---|
12472 | 1 This tests if CGI files from before d0db3462d568 still work. |
2533
589474a1dc36
Create a test to make sure old CGI scripts will still work.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
2 |
12472 | 3 $ hg init test |
4 $ cat >hgweb.cgi <<HGWEB | |
5 > #!/usr/bin/env python | |
6 > # | |
7 > # An example CGI script to use hgweb, edit as necessary | |
8 > | |
9 > import cgitb, os, sys | |
10 > cgitb.enable() | |
11 > | |
12 > # sys.path.insert(0, "/path/to/python/lib") # if not a system-wide install | |
13 > from mercurial import hgweb | |
14 > | |
15 > h = hgweb.hgweb("test", "Empty test repository") | |
16 > h.run() | |
17 > HGWEB | |
2533
589474a1dc36
Create a test to make sure old CGI scripts will still work.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
18 |
12472 | 19 $ chmod 755 hgweb.cgi |
2533
589474a1dc36
Create a test to make sure old CGI scripts will still work.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
20 |
12472 | 21 $ cat >hgweb.config <<HGWEBDIRCONF |
22 > [paths] | |
23 > test = test | |
24 > HGWEBDIRCONF | |
2533
589474a1dc36
Create a test to make sure old CGI scripts will still work.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
25 |
12472 | 26 $ cat >hgwebdir.cgi <<HGWEBDIR |
27 > #!/usr/bin/env python | |
28 > # | |
29 > # An example CGI script to export multiple hgweb repos, edit as necessary | |
30 > | |
31 > import cgitb, sys | |
32 > cgitb.enable() | |
33 > | |
34 > # sys.path.insert(0, "/path/to/python/lib") # if not a system-wide install | |
35 > from mercurial import hgweb | |
36 > | |
37 > # The config file looks like this. You can have paths to individual | |
38 > # repos, collections of repos in a directory tree, or both. | |
39 > # | |
40 > # [paths] | |
41 > # virtual/path = /real/path | |
42 > # virtual/path = /real/path | |
43 > # | |
44 > # [collections] | |
45 > # /prefix/to/strip/off = /root/of/tree/full/of/repos | |
46 > # | |
47 > # collections example: say directory tree /foo contains repos /foo/bar, | |
48 > # /foo/quux/baz. Give this config section: | |
49 > # [collections] | |
50 > # /foo = /foo | |
51 > # Then repos will list as bar and quux/baz. | |
52 > | |
53 > # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples | |
54 > # or use a dictionary with entries like 'virtual/path': '/real/path' | |
55 > | |
56 > h = hgweb.hgwebdir("hgweb.config") | |
57 > h.run() | |
58 > HGWEBDIR | |
2533
589474a1dc36
Create a test to make sure old CGI scripts will still work.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
59 |
12472 | 60 $ chmod 755 hgwebdir.cgi |
2533
589474a1dc36
Create a test to make sure old CGI scripts will still work.
Eric Hopper <hopper@omnifarious.org>
parents:
diff
changeset
|
61 |
12472 | 62 $ DOCUMENT_ROOT="/var/www/hg"; export DOCUMENT_ROOT |
63 $ GATEWAY_INTERFACE="CGI/1.1"; export GATEWAY_INTERFACE | |
64 $ 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 | |
65 $ HTTP_ACCEPT_CHARSET="ISO-8859-1,utf-8;q=0.7,*;q=0.7"; export HTTP_ACCEPT_CHARSET | |
66 $ HTTP_ACCEPT_ENCODING="gzip,deflate"; export HTTP_ACCEPT_ENCODING | |
67 $ HTTP_ACCEPT_LANGUAGE="en-us,en;q=0.5"; export HTTP_ACCEPT_LANGUAGE | |
68 $ HTTP_CACHE_CONTROL="max-age=0"; export HTTP_CACHE_CONTROL | |
69 $ HTTP_CONNECTION="keep-alive"; export HTTP_CONNECTION | |
70 $ HTTP_HOST="hg.omnifarious.org"; export HTTP_HOST | |
71 $ HTTP_KEEP_ALIVE="300"; export HTTP_KEEP_ALIVE | |
72 $ 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 | |
73 $ PATH_INFO="/"; export PATH_INFO | |
74 $ PATH_TRANSLATED="/var/www/hg/index.html"; export PATH_TRANSLATED | |
75 $ QUERY_STRING=""; export QUERY_STRING | |
76 $ REMOTE_ADDR="127.0.0.2"; export REMOTE_ADDR | |
77 $ REMOTE_PORT="44703"; export REMOTE_PORT | |
78 $ REQUEST_METHOD="GET"; export REQUEST_METHOD | |
79 $ REQUEST_URI="/test/"; export REQUEST_URI | |
80 $ SCRIPT_FILENAME="/home/hopper/hg_public/test.cgi"; export SCRIPT_FILENAME | |
81 $ SCRIPT_NAME="/test"; export SCRIPT_NAME | |
82 $ SCRIPT_URI="http://hg.omnifarious.org/test/"; export SCRIPT_URI | |
83 $ SCRIPT_URL="/test/"; export SCRIPT_URL | |
84 $ SERVER_ADDR="127.0.0.1"; export SERVER_ADDR | |
85 $ SERVER_ADMIN="eric@localhost"; export SERVER_ADMIN | |
86 $ SERVER_NAME="hg.omnifarious.org"; export SERVER_NAME | |
87 $ SERVER_PORT="80"; export SERVER_PORT | |
88 $ SERVER_PROTOCOL="HTTP/1.1"; export SERVER_PROTOCOL | |
89 $ SERVER_SIGNATURE="<address>Apache/2.0.53 (Fedora) Server at hg.omnifarious.org Port 80</address>"; export SERVER_SIGNATURE | |
90 $ SERVER_SOFTWARE="Apache/2.0.53 (Fedora)"; export SERVER_SOFTWARE | |
91 | |
92 $ python hgweb.cgi > page1 | |
93 $ python hgwebdir.cgi > page2 | |
94 | |
95 $ PATH_INFO="/test/" | |
96 $ PATH_TRANSLATED="/var/something/test.cgi" | |
97 $ REQUEST_URI="/test/test/" | |
98 $ SCRIPT_URI="http://hg.omnifarious.org/test/test/" | |
99 $ SCRIPT_URL="/test/test/" | |
100 $ python hgwebdir.cgi > page3 | |
101 | |
102 $ grep -i error page1 page2 page3 | |
103 [1] |