Mercurial > hg
annotate tests/heredoctest.py @ 23542:8b5adc6b72ae
tests: allow more flexibility in git diffstat output
The output of 'git diff --stat' changed in git 1.7.10 and 1.7.11.
To ensure the tests work with earlier versions of git as well,
the output is now wrapped with a whitespace regex.
author | Mathias De Maré <mathias.demare@gmail.com> |
---|---|
date | Sat, 13 Dec 2014 09:45:00 +0100 |
parents | 8d45a42b0c0f |
children | 1db2127d2373 |
rev | line source |
---|---|
15434
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
1 import sys |
15247
3cd1605e9d8e
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
15235
diff
changeset
|
2 |
15434
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
3 globalvars = {} |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
4 lines = sys.stdin.readlines() |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
5 while lines: |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
6 l = lines.pop(0) |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
7 if l.startswith('SALT'): |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
8 print l[:-1] |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
9 elif l.startswith('>>> '): |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
10 snippet = l[4:] |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
11 while lines and lines[0].startswith('... '): |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
12 l = lines.pop(0) |
22565
8d45a42b0c0f
heredoctest: do not append extra newline character to continuation line
Yuya Nishihara <yuya@tcha.org>
parents:
22564
diff
changeset
|
13 snippet += l[4:] |
15434
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
14 c = compile(snippet, '<heredoc>', 'single') |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
15 try: |
22564
9599e86159ac
heredoctest: use the same dict for local/global contexts as in doctest
Yuya Nishihara <yuya@tcha.org>
parents:
15434
diff
changeset
|
16 exec c in globalvars |
15434
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
17 except Exception, inst: |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
18 print repr(inst) |