annotate tests/test-hgweb-non-interactive.t @ 26641:5c57d01fe64e

destupdate: also include bookmark related logic For the same reason, we move the bookmark related update logic into the 'destupdate' function. This requires to extend the returns of the function to include the bookmark that needs to move (more or less) and the bookmark to activate at the end of the function. See function documentation for details on this returns.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 29 Sep 2015 01:03:26 -0700
parents 7df5d4760873
children af2e00c85d0a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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('.')
26247
7df5d4760873 hgweb: consume generator inside context manager (issue4756)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26220
diff changeset
61 > for c in i(env, startrsp):
7df5d4760873 hgweb: consume generator inside context manager (issue4756)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26220
diff changeset
62 > pass
12440
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
63 > print '---- ERRORS'
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
64 > print errors.getvalue()
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
65 > print '---- OS.ENVIRON wsgi variables'
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
66 > 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
67 > print '---- request.ENVIRON wsgi variables'
26220
a43328baa2ac hgweb: use separate repo instances per thread
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26219
diff changeset
68 > with i._obtainrepo() as repo:
a43328baa2ac hgweb: use separate repo instances per thread
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26219
diff changeset
69 > print sorted([x for x in repo.ui.environ if x.startswith('wsgi')])
12440
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
70 > EOF
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
71 $ python request.py
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
72 ---- STATUS
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
73 200 Script output follows
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
74 ---- HEADERS
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
75 [('Content-Type', 'text/html; charset=ascii')]
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
76 ---- DATA
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
77 ---- ERRORS
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 ---- OS.ENVIRON wsgi variables
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
80 []
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
81 ---- request.ENVIRON wsgi variables
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
82 ['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
83
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 13956
diff changeset
84 $ cd ..