Mercurial > hg
annotate tests/heredoctest.py @ 30235:fe612ab5eeff stable
tests: use "?" to glob both ":" and ";" in output for test portability
If environment variable looks like PATH or so (e.g. any of components
joined by ":" contains "/"), ":" in it is replaced with ";" by MinGW
at spawning Windows native process, to follow path concatenation style
of Windows.
Therefore, "bundle:../full.hg" is converted into "bundle;..\full.hg"
on MinGW.
Difference between "/" and "\" is automatically ignored by "(glob)",
but difference between ":" and ";" should be globed explicitly.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 29 Oct 2016 03:04:54 +0900 |
parents | 6a98f9408a50 |
children | 55fd0fefbec4 |
rev | line source |
---|---|
29485
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27297
diff
changeset
|
1 from __future__ import absolute_import, print_function |
27297
4179d054b3e9
tests: use absolute_import for heredoctest.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25032
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 import sys |
15247
3cd1605e9d8e
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
15235
diff
changeset
|
4 |
15434
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
5 globalvars = {} |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
6 lines = sys.stdin.readlines() |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
7 while lines: |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
8 l = lines.pop(0) |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
9 if l.startswith('SALT'): |
25032
1db2127d2373
heredoctest: 2to3 -w -f numliterals -f except -f print tests/heredoctest.py
Augie Fackler <augie@google.com>
parents:
22565
diff
changeset
|
10 print(l[:-1]) |
15434
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
11 elif l.startswith('>>> '): |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
12 snippet = l[4:] |
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
13 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
|
14 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
|
15 snippet += l[4:] |
15434
5635a4017061
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
15398
diff
changeset
|
16 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
|
17 try: |
25032
1db2127d2373
heredoctest: 2to3 -w -f numliterals -f except -f print tests/heredoctest.py
Augie Fackler <augie@google.com>
parents:
22565
diff
changeset
|
18 exec(c, globalvars) |
1db2127d2373
heredoctest: 2to3 -w -f numliterals -f except -f print tests/heredoctest.py
Augie Fackler <augie@google.com>
parents:
22565
diff
changeset
|
19 except Exception as inst: |
1db2127d2373
heredoctest: 2to3 -w -f numliterals -f except -f print tests/heredoctest.py
Augie Fackler <augie@google.com>
parents:
22565
diff
changeset
|
20 print(repr(inst)) |