author | Christian Ebert <blacktrash@gmx.net> |
Sat, 22 Mar 2014 08:44:07 +0000 | |
changeset 1362 | a5dabff2e764 |
parent 1110 | d5b3404b82ce |
permissions | -rw-r--r-- |
1110
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
1 |
import sys |
1108
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
2 |
|
1110
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
3 |
globalvars = {} |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
4 |
localvars = {} |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
5 |
lines = sys.stdin.readlines() |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
6 |
while lines: |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
7 |
l = lines.pop(0) |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
8 |
if l.startswith('SALT'): |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
9 |
print l[:-1] |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
10 |
elif l.startswith('>>> '): |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
11 |
snippet = l[4:] |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
12 |
while lines and lines[0].startswith('... '): |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
13 |
l = lines.pop(0) |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
14 |
snippet += "\n" + l[4:] |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
15 |
c = compile(snippet, '<heredoc>', 'single') |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
16 |
try: |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
17 |
exec c in globalvars, localvars |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
18 |
except Exception, inst: |
d5b3404b82ce
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1109
diff
changeset
|
19 |
print repr(inst) |