aboutsummaryrefslogtreecommitdiff
path: root/lib/cmark/test/entity_tests.py
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-22 20:53:39 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-22 20:53:39 +0200
commit8dbfb0890560fd1cd698d06fa05ac868c4db8576 (patch)
tree57d138d7e9967473b8ed52863dabeb739a34ac8e /lib/cmark/test/entity_tests.py
parent058aeef80e8a33d0e385f284b23eeb117f5ec547 (diff)
downloadkristall-8dbfb0890560fd1cd698d06fa05ac868c4db8576.tar.gz
Removes 'cruft' from cmark. We only care for the source anyways.
Diffstat (limited to 'lib/cmark/test/entity_tests.py')
-rw-r--r--lib/cmark/test/entity_tests.py67
1 files changed, 0 insertions, 67 deletions
diff --git a/lib/cmark/test/entity_tests.py b/lib/cmark/test/entity_tests.py
deleted file mode 100644
index 27b70e6..0000000
--- a/lib/cmark/test/entity_tests.py
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-
-import re
-import os
-import argparse
-import sys
-import platform
-import html
-from cmark import CMark
-
-def get_entities():
- regex = r'^{\(unsigned char\*\)"([^"]+)", \{([^}]+)\}'
- with open(os.path.join(os.path.dirname(__file__), '..', 'src', 'entities.inc')) as f:
- code = f.read()
- entities = []
- for entity, utf8 in re.findall(regex, code, re.MULTILINE):
- utf8 = bytes(map(int, utf8.split(", ")[:-1])).decode('utf-8')
- entities.append((entity, utf8))
- return entities
-
-parser = argparse.ArgumentParser(description='Run cmark tests.')
-parser.add_argument('--program', dest='program', nargs='?', default=None,
- help='program to test')
-parser.add_argument('--library-dir', dest='library_dir', nargs='?',
- default=None, help='directory containing dynamic library')
-args = parser.parse_args(sys.argv[1:])
-
-cmark = CMark(prog=args.program, library_dir=args.library_dir)
-
-entities = get_entities()
-
-passed = 0
-errored = 0
-failed = 0
-
-exceptions = {
- 'quot': '&quot;',
- 'QUOT': '&quot;',
-
- # These are broken, but I'm not too worried about them.
- 'nvlt': '&lt;⃒',
- 'nvgt': '&gt;⃒',
-}
-
-print("Testing entities:")
-for entity, utf8 in entities:
- [rc, actual, err] = cmark.to_html("&{};".format(entity))
- check = exceptions.get(entity, utf8)
-
- if rc != 0:
- errored += 1
- print(entity, '[ERRORED (return code {})]'.format(rc))
- print(err)
- elif check in actual:
- # print(entity, '[PASSED]') # omit noisy success output
- passed += 1
- else:
- print(entity, '[FAILED]')
- print(repr(actual))
- failed += 1
-
-print("{} passed, {} failed, {} errored".format(passed, failed, errored))
-if failed == 0 and errored == 0:
- exit(0)
-else:
- exit(1)