tests/test-newcgi.t
author Adrian Buehlmann <adrian@cadifra.com>
Sun, 17 Apr 2011 11:37:11 +0200
changeset 13950 14d0553bd48b
parent 13269 aa3f726a2bdb
child 15567 8b84d040d9f9
permissions -rw-r--r--
help: do not show full help text for command on option errors Example $ hg clone --jump foo bar hg clone: option --jump not recognized hg clone [OPTION]... SOURCE [DEST] make a copy of an existing repository options: -U --noupdate the clone will include an empty working copy (only a repository) -u --updaterev REV revision, tag or branch to check out -r --rev REV [+] include the specified changeset -b --branch BRANCH [+] clone only the specified branch --pull use pull protocol to copy metadata --uncompressed use uncompressed transfer (fast over LAN) -e --ssh CMD specify ssh command to use --remotecmd CMD specify hg command to run on the remote side --insecure do not verify server certificate (ignoring web.cacerts config) [+] marked option can be specified multiple times use "hg help clone" to show the full help text Motivation for this change If the user already has specified the command, he probably already knows the command to some extent. Apparently, he has a problem with the options, so we show him just the synopsis with the short help and the details about the options, with a hint on the last line how to get the full help text. Why is Mercurial better with this change? Experts who just forgot about the details of an option don't get that much text thrown at them, while the newbies still get a hint on the last line how to get the full help text.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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():
12743
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12470
diff changeset
    19
  >     return hgweb("test", "Empty test repository")
12470
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():
12743
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12470
diff changeset
    45
  >     return hgwebdir("hgweb.config")
12470
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
13269
aa3f726a2bdb tests: remove duplication of the CGI environment variables
StevenGBrown
parents: 12743
diff changeset
    52
  $ . "$TESTDIR/cgienv"
12470
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
    53
  $ python hgweb.cgi > page1
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
    54
  $ python hgwebdir.cgi > page2
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
    55
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
    56
  $ PATH_INFO="/test/"
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
    57
  $ PATH_TRANSLATED="/var/something/test.cgi"
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
    58
  $ REQUEST_URI="/test/test/"
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
    59
  $ SCRIPT_URI="http://hg.omnifarious.org/test/test/"
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
    60
  $ SCRIPT_URL="/test/test/"
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
    61
  $ python hgwebdir.cgi > page3
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
    62
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
    63
  $ grep -i error page1 page2 page3
70a6734cf761 tests: unify test-newcgi
Matt Mackall <mpm@selenic.com>
parents: 5580
diff changeset
    64
  [1]