summaryrefslogtreecommitdiff
path: root/test/pathological_tests.py
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-11-29 18:32:44 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-11-29 18:32:44 -0800
commit9fedb89af38b5a43eb0f7944e938dbbdb17a499d (patch)
tree6b69dd19edcd3abc5b0a673bcbb31e592262bdaa /test/pathological_tests.py
parent2570a08178f95dc9340f13924d412169dd57fdbb (diff)
Factored out cmark.py from test programs.
Diffstat (limited to 'test/pathological_tests.py')
-rw-r--r--test/pathological_tests.py32
1 files changed, 3 insertions, 29 deletions
diff --git a/test/pathological_tests.py b/test/pathological_tests.py
index 999a467..3cf1662 100644
--- a/test/pathological_tests.py
+++ b/test/pathological_tests.py
@@ -1,12 +1,11 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from ctypes import CDLL, c_char_p, c_long
-from subprocess import *
import re
import argparse
import sys
import platform
+from cmark import CMark
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Run cmark tests.')
@@ -16,32 +15,7 @@ if __name__ == "__main__":
default=None, help='directory containing dynamic library')
args = parser.parse_args(sys.argv[1:])
-if not args.program:
- sysname = platform.system()
- libname = "libcmark"
- if sysname == 'Darwin':
- libname += ".dylib"
- elif sysname == 'Windows':
- libname += ".dll"
- else:
- libname += ".so"
- if args and args.library_dir:
- libpath = args.library_dir + "/" + libname
- else:
- libpath = "build/src/" + libname
- cmark = CDLL(libpath)
-
- markdown = cmark.cmark_markdown_to_html
- markdown.restype = c_char_p
- markdown.argtypes = [c_char_p, c_long]
-
-def md2html(text, prog):
- if prog:
- p1 = Popen(prog.split(), stdout=PIPE, stdin=PIPE, stderr=PIPE)
- [result, err] = p1.communicate(input=text)
- return [p1.returncode, result, err]
- else:
- return [0, markdown(text, len(text)), '']
+cmark = CMark(prog=args.program, library_dir=args.library_dir)
pathological = {
"nested strong emph":
@@ -62,7 +36,7 @@ print "Testing pathological cases:"
for description in pathological:
print description
(inp, expected) = pathological[description]
- [rc, actual, err] = md2html(inp, args.program)
+ [rc, actual, err] = cmark.to_html(inp)
if rc != 0:
errored += 1
print description