Mercurial > hg
annotate tests/test-hgweb-non-interactive.t @ 31971:73e9328e5307
obsolescence: add test case D-3 for obsolescence markers exchange
About 3 years ago, in August 2014, the logic to select what markers to select on
push was ported from the evolve extension to Mercurial core. However, for some
unclear reasons, the tests for that logic were not ported alongside.
I realised it a couple of weeks ago while working on another push related issue.
I've made a clean up pass on the tests and they are now ready to integrate the
core test suite. This series of changesets do not change any logic. I just adds
test for logic that has been around for about 10 versions of Mercurial.
They are a patch for each test case. It makes it easier to review and postpone
one with documentation issues without rejecting the wholes series.
This patch introduce case D3: missing prune target (prune not in "pushed set")
Each test case comes it in own test file. It help parallelism and does not
introduce a significant overhead from having a single unified giant test file.
Here are timing to support this claim.
# Multiple test files version:
# run-tests.py --local -j 1 test-exchange-*.t
53.40s user 6.82s system 85% cpu 1:10.76 total
52.79s user 6.97s system 85% cpu 1:09.97 total
52.94s user 6.82s system 85% cpu 1:09.69 total
# Single test file version:
# run-tests.py --local -j 1 test-exchange-obsmarkers.t
52.97s user 6.85s system 85% cpu 1:10.10 total
52.64s user 6.79s system 85% cpu 1:09.63 total
53.70s user 7.00s system 85% cpu 1:11.17 total
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Mon, 10 Apr 2017 16:54:43 +0200 |
parents | 636cf3f7620d |
children | 75be14993fda |
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, |
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
15 > hg, |
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
16 > ui as uimod, |
28861
86db5cb55d46
pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents:
28859
diff
changeset
|
17 > util, |
28859
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
18 > ) |
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
19 > ui = uimod.ui |
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
20 > from mercurial.hgweb.hgweb_mod import ( |
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
21 > hgweb, |
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
22 > ) |
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): |
12743
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
44 > print '---- STATUS' |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
45 > print status |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
46 > print '---- HEADERS' |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
47 > 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
|
48 > print '---- DATA' |
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 | 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 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
68 > i = hgweb('.') |
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 |
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
71 > print '---- ERRORS' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
72 > print errors.getvalue() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
73 > print '---- OS.ENVIRON wsgi variables' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
74 > 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
|
75 > print '---- request.ENVIRON wsgi variables' |
26220
a43328baa2ac
hgweb: use separate repo instances per thread
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26219
diff
changeset
|
76 > with i._obtainrepo() as repo: |
a43328baa2ac
hgweb: use separate repo instances per thread
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26219
diff
changeset
|
77 > 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
|
78 > EOF |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
79 $ python request.py |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
80 ---- STATUS |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
81 200 Script output follows |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
82 ---- HEADERS |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
83 [('Content-Type', 'text/html; charset=ascii')] |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
84 ---- DATA |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
85 ---- ERRORS |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
86 |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
87 ---- OS.ENVIRON wsgi variables |
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 ---- request.ENVIRON wsgi variables |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
90 ['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
|
91 |
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
13956
diff
changeset
|
92 $ cd .. |