aboutsummaryrefslogtreecommitdiffstats
path: root/build_tests.py
diff options
context:
space:
mode:
authorPhilipp A2019-11-12 22:57:02 +0100
committerPhilipp A2019-11-12 22:57:02 +0100
commit271cb95ec3e12d6f97852491bc723c5060ce4b75 (patch)
tree78cb094fb882fd6c56733ff9e4d1a9377713d393 /build_tests.py
parent18fba4a71eeebf3a2df91a6bcfda7f13e6c3f561 (diff)
downloadrust-rst-271cb95ec3e12d6f97852491bc723c5060ce4b75.tar.bz2
Run python tests
Diffstat (limited to 'build_tests.py')
-rw-r--r--build_tests.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/build_tests.py b/build_tests.py
new file mode 100644
index 0000000..3fe4e9a
--- /dev/null
+++ b/build_tests.py
@@ -0,0 +1,27 @@
+import sys
+import json
+from ast import literal_eval
+from urllib.request import urlopen
+
+out = sys.argv[1]
+url_base = 'https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils'
+
+with urlopen(f'{url_base}/test/test_writers/test_html5_polyglot_parts.py?format=raw') as con:
+ code = con.read().decode()
+
+code = code[code.find('totest ='):code.find('if __name__')]
+exec(code)
+with open(out, 'w') as f:
+ t = 0
+ for k, (opts, tests) in totest.items():
+ for rst, result_code in tests:
+ result = literal_eval(result_code)['fragment']
+ rst, result = (r.replace('"', r'\"') for r in (rst, result))
+ f.write(f'''\
+#[test]
+fn test_{t:02}() {{
+ check_renders_to("{rst}", "{result.strip()}");
+}}
+''')
+ t += 1
+