Debian Codegraph @

tests/test-oldcgi.t

raw
1 #require no-msys # MSYS will translate web paths as if they were file paths
2
3 This tests if CGI files from before d0db3462d568 still work.
4
5 $ hg init test
6 $ cat >hgweb.cgi <<HGWEB
7 > #!"$PYTHON"
8 > #
9 > # An example CGI script to use hgweb, edit as necessary
10 >
11 > import os, sys
12 >
13 > # sys.path.insert(0, "/path/to/python/lib") # if not a system-wide install
14 > from mercurial import hgweb
15 >
16 > h = hgweb.hgweb(b"test", b"Empty test repository")
17 > h.run()
18 > HGWEB
19
20 $ chmod 755 hgweb.cgi
21
22 $ cat >hgweb.config <<HGWEBDIRCONF
23 > [paths]
24 > test = test
25 > HGWEBDIRCONF
26
27 $ cat >hgwebdir.cgi <<HGWEBDIR
28 > #!"$PYTHON"
29 > #
30 > # An example CGI script to export multiple hgweb repos, edit as necessary
31 >
32 > import sys
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(b"hgweb.config")
57 > h.run()
58 > HGWEBDIR
59
60 $ chmod 755 hgwebdir.cgi
61
62 $ . "$TESTDIR/cgienv"
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]