annotate tests/test-hgweb-non-interactive.t @ 40793:64cdfcc73706

cache: create `cache` directory at init time The cache directory will be needed very quickly, so it seems simpler to create it early to make sure it has the same owner and permission than the other directory in the repository.
author Boris Feld <boris.feld@octobus.net>
date Thu, 15 Nov 2018 02:38:55 +0100
parents f80f7a67e176
children 4c1b4805db57
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
28859
af2e00c85d0a py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents: 26247
diff changeset
10 > from __future__ import absolute_import
af2e00c85d0a py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents: 26247
diff changeset
11 > import os
af2e00c85d0a py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents: 26247
diff changeset
12 > import sys
af2e00c85d0a py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents: 26247
diff changeset
13 > from mercurial import (
af2e00c85d0a py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents: 26247
diff changeset
14 > dispatch,
39913
8bd589aecf65 py3: avoid b'' output in test-hgweb-non-interactive.t
Matt Harbison <matt_harbison@yahoo.com>
parents: 39707
diff changeset
15 > encoding,
28859
af2e00c85d0a py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents: 26247
diff changeset
16 > hg,
39913
8bd589aecf65 py3: avoid b'' output in test-hgweb-non-interactive.t
Matt Harbison <matt_harbison@yahoo.com>
parents: 39707
diff changeset
17 > pycompat,
28859
af2e00c85d0a py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents: 26247
diff changeset
18 > ui as uimod,
28861
86db5cb55d46 pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents: 28859
diff changeset
19 > util,
28859
af2e00c85d0a py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents: 26247
diff changeset
20 > )
af2e00c85d0a py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents: 26247
diff changeset
21 > ui = uimod.ui
40203
f80f7a67e176 tests: fix style issue of importing hgweb in embedded code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 39913
diff changeset
22 > from mercurial.hgweb import hgweb_mod
28861
86db5cb55d46 pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents: 28859
diff changeset
23 > stringio = util.stringio
12440
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
24 >
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
25 > class FileLike(object):
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
26 > def __init__(self, real):
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
27 > self.real = real
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
28 > def fileno(self):
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
29 > print >> sys.__stdout__, 'FILENO'
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
30 > return self.real.fileno()
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
31 > def read(self):
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
32 > print >> sys.__stdout__, 'READ'
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
33 > return self.real.read()
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
34 > def readline(self):
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
35 > print >> sys.__stdout__, 'READLINE'
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
36 > return self.real.readline()
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
37 >
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
38 > sys.stdin = FileLike(sys.stdin)
28861
86db5cb55d46 pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents: 28859
diff changeset
39 > errors = stringio()
86db5cb55d46 pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents: 28859
diff changeset
40 > input = stringio()
86db5cb55d46 pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents: 28859
diff changeset
41 > output = stringio()
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 > def startrsp(status, headers):
33720
27fb986e54d0 tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents: 32940
diff changeset
44 > print('---- STATUS')
27fb986e54d0 tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents: 32940
diff changeset
45 > print(status)
27fb986e54d0 tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents: 32940
diff changeset
46 > print('---- HEADERS')
27fb986e54d0 tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents: 32940
diff changeset
47 > print([i for i in headers if i[0] != 'ETag'])
27fb986e54d0 tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents: 32940
diff changeset
48 > print('---- DATA')
12743
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12440
diff changeset
49 > return output.write
12440
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
50 >
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
51 > env = {
12743
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12440
diff changeset
52 > 'wsgi.version': (1, 0),
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12440
diff changeset
53 > 'wsgi.url_scheme': 'http',
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12440
diff changeset
54 > 'wsgi.errors': errors,
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12440
diff changeset
55 > 'wsgi.input': input,
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12440
diff changeset
56 > 'wsgi.multithread': False,
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12440
diff changeset
57 > 'wsgi.multiprocess': False,
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12440
diff changeset
58 > 'wsgi.run_once': False,
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12440
diff changeset
59 > 'REQUEST_METHOD': 'GET',
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12440
diff changeset
60 > 'SCRIPT_NAME': '',
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12440
diff changeset
61 > 'PATH_INFO': '',
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12440
diff changeset
62 > 'QUERY_STRING': '',
31008
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 28861
diff changeset
63 > 'SERVER_NAME': '$LOCALIP',
12743
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12440
diff changeset
64 > '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
65 > 'SERVER_PROTOCOL': 'HTTP/1.0'
12440
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
66 > }
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
67 >
40203
f80f7a67e176 tests: fix style issue of importing hgweb in embedded code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 39913
diff changeset
68 > i = hgweb_mod.hgweb(b'.')
26247
7df5d4760873 hgweb: consume generator inside context manager (issue4756)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26220
diff changeset
69 > for c in i(env, startrsp):
7df5d4760873 hgweb: consume generator inside context manager (issue4756)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26220
diff changeset
70 > pass
39913
8bd589aecf65 py3: avoid b'' output in test-hgweb-non-interactive.t
Matt Harbison <matt_harbison@yahoo.com>
parents: 39707
diff changeset
71 > sys.stdout.flush()
8bd589aecf65 py3: avoid b'' output in test-hgweb-non-interactive.t
Matt Harbison <matt_harbison@yahoo.com>
parents: 39707
diff changeset
72 > pycompat.stdout.write(b'---- ERRORS\n')
8bd589aecf65 py3: avoid b'' output in test-hgweb-non-interactive.t
Matt Harbison <matt_harbison@yahoo.com>
parents: 39707
diff changeset
73 > pycompat.stdout.write(b'%s\n' % errors.getvalue())
33720
27fb986e54d0 tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents: 32940
diff changeset
74 > print('---- OS.ENVIRON wsgi variables')
27fb986e54d0 tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents: 32940
diff changeset
75 > print(sorted([x for x in os.environ if x.startswith('wsgi')]))
27fb986e54d0 tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents: 32940
diff changeset
76 > print('---- request.ENVIRON wsgi variables')
26220
a43328baa2ac hgweb: use separate repo instances per thread
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26219
diff changeset
77 > with i._obtainrepo() as repo:
39913
8bd589aecf65 py3: avoid b'' output in test-hgweb-non-interactive.t
Matt Harbison <matt_harbison@yahoo.com>
parents: 39707
diff changeset
78 > print(sorted([encoding.strfromlocal(x) for x in repo.ui.environ
8bd589aecf65 py3: avoid b'' output in test-hgweb-non-interactive.t
Matt Harbison <matt_harbison@yahoo.com>
parents: 39707
diff changeset
79 > if x.startswith(b'wsgi')]))
12440
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
80 > EOF
39707
5abc47d4ca6b tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents: 39658
diff changeset
81 $ "$PYTHON" request.py
12440
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
82 ---- STATUS
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
83 200 Script output follows
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
84 ---- HEADERS
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
85 [('Content-Type', 'text/html; charset=ascii')]
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
86 ---- DATA
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
87 ---- ERRORS
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
88
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
89 ---- OS.ENVIRON wsgi variables
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
90 []
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
91 ---- request.ENVIRON wsgi variables
d9f7753a94d5 tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents: 12183
diff changeset
92 ['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
93
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 13956
diff changeset
94 $ cd ..