Mercurial > hg
annotate tests/test-hgweb-non-interactive.t @ 24885:eea3977e6fca stable
windows: make shellquote() quote any path containing '\' (issue4629)
The '~' in the bug report is being expanded to a path with Windows style slashes
before being passed to shellquote() via util.shellquote(). But shlex.split()
strips '\' out of the string, leaving an invalid path in dispatch.aliasargs().
This regressed in 1642eb429536.
For now, the tests need to be conditionalized for Windows (because those paths
are quoted). In the future, a more complex regex could probably skip the quotes
if all component separators are double '\'. I opted to glob away the quotes in
test-rename-merge2.t and test-up-local-change.t (which only exist on Windows),
because they are in very large blocks of output and there are way too many diffs
to conditionalize with #if directives. Maybe the entire path should be globbed
away like the following paths in each changed line. Or, letting #if directives
sit in the middle of the output as was mentioned a few months back would work
too.
Unfortunately, I couldn't figure out how to test the specific bug. All of the
'hg serve' tests have a #require serve declaration, causing them to be skipped
on Windows. Adding an alias for 'expandtest = outgoing ~/bogusrepo' prints the
repo as '$TESTTMP/bogusrepo', so the test runner must be changing the
environment somehow.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 29 Apr 2015 21:14:59 -0400 |
parents | f2719b387380 |
children | ae33fff17c1e |
rev | line source |
---|---|
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
1 Tests if hgweb can run without touching sys.stdin, as is required |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
2 by the WSGI standard and strictly implemented by mod_wsgi. |
5337
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
3 |
13956
ffb5c09ba822
tests: remove redundant mkdir
Martin Geisler <mg@lazybytes.net>
parents:
12743
diff
changeset
|
4 $ hg init repo |
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
5 $ cd repo |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
6 $ echo foo > bar |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
7 $ hg add bar |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
8 $ hg commit -m "test" |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
9 $ cat > request.py <<EOF |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
10 > from mercurial import dispatch |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
11 > from mercurial.hgweb.hgweb_mod import hgweb |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
12 > from mercurial.ui import ui |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
13 > from mercurial import hg |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
14 > from StringIO import StringIO |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
15 > import os, sys |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
16 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
17 > class FileLike(object): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
18 > def __init__(self, real): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
19 > self.real = real |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
20 > def fileno(self): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
21 > print >> sys.__stdout__, 'FILENO' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
22 > return self.real.fileno() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
23 > def read(self): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
24 > print >> sys.__stdout__, 'READ' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
25 > return self.real.read() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
26 > def readline(self): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
27 > print >> sys.__stdout__, 'READLINE' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
28 > return self.real.readline() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
29 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
30 > sys.stdin = FileLike(sys.stdin) |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
31 > errors = StringIO() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
32 > input = StringIO() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
33 > output = StringIO() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
34 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
35 > def startrsp(status, headers): |
12743
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
36 > print '---- STATUS' |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
37 > print status |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
38 > print '---- HEADERS' |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
39 > print [i for i in headers if i[0] != 'ETag'] |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
40 > print '---- DATA' |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
41 > return output.write |
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
42 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
43 > env = { |
12743
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
44 > 'wsgi.version': (1, 0), |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
45 > 'wsgi.url_scheme': 'http', |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
46 > 'wsgi.errors': errors, |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
47 > 'wsgi.input': input, |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
48 > 'wsgi.multithread': False, |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
49 > 'wsgi.multiprocess': False, |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
50 > 'wsgi.run_once': False, |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
51 > 'REQUEST_METHOD': 'GET', |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
52 > 'SCRIPT_NAME': '', |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
53 > 'PATH_INFO': '', |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
54 > 'QUERY_STRING': '', |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
55 > 'SERVER_NAME': '127.0.0.1', |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
56 > 'SERVER_PORT': os.environ['HGPORT'], |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
57 > 'SERVER_PROTOCOL': 'HTTP/1.0' |
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
58 > } |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
59 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
60 > i = hgweb('.') |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
61 > i(env, startrsp) |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
62 > print '---- ERRORS' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
63 > print errors.getvalue() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
64 > print '---- OS.ENVIRON wsgi variables' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
65 > print sorted([x for x in os.environ if x.startswith('wsgi')]) |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
66 > print '---- request.ENVIRON wsgi variables' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
67 > print sorted([x for x in i.repo.ui.environ if x.startswith('wsgi')]) |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
68 > EOF |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
69 $ python request.py |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
70 ---- STATUS |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
71 200 Script output follows |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
72 ---- HEADERS |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
73 [('Content-Type', 'text/html; charset=ascii')] |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
74 ---- DATA |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
75 ---- ERRORS |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
76 |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
77 ---- OS.ENVIRON wsgi variables |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
78 [] |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
79 ---- request.ENVIRON wsgi variables |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
80 ['wsgi.errors', 'wsgi.input', 'wsgi.multiprocess', 'wsgi.multithread', 'wsgi.run_once', 'wsgi.url_scheme', 'wsgi.version'] |
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
13956
diff
changeset
|
81 |
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
13956
diff
changeset
|
82 $ cd .. |