changeset 15235:f7044da7a793

tests: add helper script for processing doctests read from stdin Writes stdin to a temp file and doctests it. In the future we might want to spare the temp file and directly call into doctest. Also, with some tweaking it seems possible to adjust the line numbers reported in an error report so they match the ones in the original file.
author Idan Kamara <idankk86@gmail.com>
date Wed, 12 Oct 2011 22:01:13 +0200
parents 5d700b7edd85
children 4fae5df4b1bb
files tests/heredoctest.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/heredoctest.py	Wed Oct 12 22:01:13 2011 +0200
@@ -0,0 +1,9 @@
+import doctest, tempfile, os, sys
+
+if __name__ == "__main__":
+    fd, name = tempfile.mkstemp(suffix='hg-tst')
+    os.write(fd, sys.stdin.read())
+    os.close(fd)
+    failures, _ = doctest.testfile(name, module_relative=False)
+    if failures:
+        sys.exit(1)