author | Idan Kamara <idankk86@gmail.com> |
Thu, 13 Oct 2011 17:54:35 +0200 | |
branch | stable |
changeset 1108 | 168da136346a |
parent 1107 | 943253aadddb |
child 1109 | 8458561f6f94 |
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__": |
943253aadddb
tests: add helper script for processing doctests read from stdin
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
4 |
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
|
5 |
|
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
6 |
try: |
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
7 |
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
|
8 |
os.close(fd) |
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
9 |
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
|
10 |
if failures: |
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
11 |
sys.exit(1) |
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
12 |
finally: |
168da136346a
tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents:
1107
diff
changeset
|
13 |
os.remove(name) |