Mercurial > hg
annotate tests/test-oldcgi.t @ 13290:82133e91ce7d
record: turn consumefile() into a pure function
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sun, 23 Jan 2011 12:44:05 +0100 |
parents | aa3f726a2bdb |
children | 8b84d040d9f9 |
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 |
13269
aa3f726a2bdb
tests: remove duplication of the CGI environment variables
StevenGBrown
parents:
12472
diff
changeset
|
62 $ . "$TESTDIR/cgienv" |
12472 | 63 $ python hgweb.cgi > page1 |
64 $ python hgwebdir.cgi > page2 | |
65 | |
66 $ PATH_INFO="/test/" | |
67 $ PATH_TRANSLATED="/var/something/test.cgi" | |
68 $ REQUEST_URI="/test/test/" | |
69 $ SCRIPT_URI="http://hg.omnifarious.org/test/test/" | |
70 $ SCRIPT_URL="/test/test/" | |
71 $ python hgwebdir.cgi > page3 | |
72 | |
73 $ grep -i error page1 page2 page3 | |
74 [1] |