author | Brodie Rao <brodie@bitheap.org> |
Tue, 01 Nov 2011 12:25:54 -0700 | |
branch | stable |
changeset 1109 | 8458561f6f94 |
parent 1108 | 168da136346a |
child 1110 | d5b3404b82ce |
permissions | -rw-r--r-- |
1107
943253aadddb
tests: add helper script for processing doctests read from stdin
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
1 |
import doctest, tempfile, os, sys |
943253aadddb
tests: add helper script for processing doctests read from stdin
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
2 |
|
943253aadddb
tests: add helper script for processing doctests read from stdin
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
3 |
if __name__ == "__main__": |
1109
8458561f6f94
tests: fix readline escape characters in heredoctest.py/test-url.py
Brodie Rao <brodie@bitheap.org>
parents:
1108
diff
changeset
|
4 |
if 'TERM' in os.environ: |
8458561f6f94
tests: fix readline escape characters in heredoctest.py/test-url.py
Brodie Rao <brodie@bitheap.org>
parents:
1108
diff
changeset
|
5 |
del os.environ['TERM'] |
8458561f6f94
tests: fix readline escape characters in heredoctest.py/test-url.py
Brodie Rao <brodie@bitheap.org>
parents:
1108
diff
changeset
|
6 |
|
1107
943253aadddb
tests: add helper script for processing doctests read from stdin
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
7 |
fd, name = tempfile.mkstemp(suffix='hg-tst') |
1108
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
8 |
|
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
9 |
try: |
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
10 |
os.write(fd, sys.stdin.read()) |
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
11 |
os.close(fd) |
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
12 |
failures, _ = doctest.testfile(name, module_relative=False) |
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
13 |
if failures: |
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
14 |
sys.exit(1) |
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
15 |
finally: |
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
16 |
os.remove(name) |